From 7ea26d7977fc16a1a233e44bdff4e5c2d73e8583 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 31 Jul 2025 15:27:35 +1000 Subject: [PATCH 001/171] Add Session Pro master key derivation --- include/session/ed25519.h | 20 ++++++++++++++ include/session/ed25519.hpp | 16 +++++++++-- src/ed25519.cpp | 42 ++++++++++++++++++++++++++++ tests/test_ed25519.cpp | 55 +++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 2 deletions(-) diff --git a/include/session/ed25519.h b/include/session/ed25519.h index 82abd521..932dc2e2 100644 --- a/include/session/ed25519.h +++ b/include/session/ed25519.h @@ -95,6 +95,26 @@ LIBSESSION_EXPORT bool session_ed25519_verify( const unsigned char* msg, size_t msg_len); +/// API: crypto/session_ed25519_pro_key_pair_for_ed25519_seed +/// +/// Generate the deterministic Master Session Pro key for signing requests to interact with the +/// Session Pro features of the protocol. +/// +/// Inputs: +/// - `ed25519_seed` -- [in] the seed to the long-term key for the Session account to derive the +/// deterministic key from. +/// - `ed25519_pk_out` -- [out] pointer to a buffer of 32 bytes where the public key will be +/// written. +/// - `ed25519_sk_out` -- [out] pointer to a buffer of 64 bytes where the private key will be +/// written. +/// +/// Outputs: +/// - `bool` -- True if the key pair was successfully derived, false if failed. +LIBSESSION_EXPORT bool session_ed25519_pro_key_pair_for_ed25519_seed( + const unsigned char* ed25519_seed, /* 32 bytes */ + unsigned char *ed25519_pk_out, /*32 byte output buffer*/ + unsigned char *ed25519_sk_out /*64 byte output buffer*/); + #ifdef __cplusplus } #endif diff --git a/include/session/ed25519.hpp b/include/session/ed25519.hpp index 264b2000..d4e599db 100644 --- a/include/session/ed25519.hpp +++ b/include/session/ed25519.hpp @@ -4,8 +4,6 @@ #include #include -#include "types.hpp" - namespace session::ed25519 { /// Generates a random Ed25519 key pair @@ -58,4 +56,18 @@ bool verify( std::span pubkey, std::span msg); +/// API: ed25519/ed25519_pro_key_pair_for_ed25519_seed +/// +/// Generate the deterministic Master Session Pro key for signing requests to interact with the +/// Session Pro features of the protocol. +/// +/// Inputs: +/// - `ed25519_seed` -- the seed to the long-term key for the Session account to derive the +/// deterministic key from. +/// +/// Outputs: +/// - The Master Session Pro ed25519 key +std::pair, std::array> +ed25519_pro_key_pair_for_ed25519_seed(std::span ed25519_seed); + } // namespace session::ed25519 diff --git a/src/ed25519.cpp b/src/ed25519.cpp index 0cde00e3..3ed15be5 100644 --- a/src/ed25519.cpp +++ b/src/ed25519.cpp @@ -1,5 +1,6 @@ #include "session/ed25519.hpp" +#include #include #include @@ -14,6 +15,8 @@ template using cleared_array = sodium_cleared>; using uc32 = std::array; +using uc64 = std::array; +using cleared_uc32 = cleared_array<32>; using cleared_uc64 = cleared_array<64>; std::pair, std::array> ed25519_key_pair() { @@ -86,6 +89,29 @@ bool verify( crypto_sign_ed25519_verify_detached(sig.data(), msg.data(), msg.size(), pubkey.data())); } +std::pair, std::array> +ed25519_pro_key_pair_for_ed25519_seed(std::span ed25519_seed) { + if (ed25519_seed.size() != 32) + throw std::invalid_argument{"Invalid ed25519_seed: expected 32 bytes"}; + + // Construct master key + // s2 = Blake2b32(s, key="SessionProRandom") + // b/B = Ed25519FromSeed(s2) + constexpr std::string_view BLAKE2B_KEY = "SessionProRandom"; + uc32 s2 = {}; + int hash_result = crypto_generichash_blake2b( + s2.data(), + s2.size(), + ed25519_seed.data(), + ed25519_seed.size(), + reinterpret_cast(BLAKE2B_KEY.data()), + BLAKE2B_KEY.size()); + assert(hash_result == 0); // This function can't return 0 unless misused + + std::pair result = ed25519_key_pair(s2); + return result; +} + } // namespace session::ed25519 using namespace session; @@ -157,3 +183,19 @@ LIBSESSION_C_API bool session_ed25519_verify( std::span{pubkey, 32}, std::span{msg, msg_len}); } + +LIBSESSION_C_API bool session_ed25519_pro_key_pair_for_ed25519_seed( + const unsigned char* ed25519_seed, + unsigned char* ed25519_pk_out, + unsigned char* ed25519_sk_out) { + try { + auto seed = std::span(ed25519_seed, 32); + auto result = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed); + auto [ed_pk, ed_sk] = result; + std::memcpy(ed25519_pk_out, ed_pk.data(), ed_pk.size()); + std::memcpy(ed25519_sk_out, ed_sk.data(), ed_sk.size()); + return true; + } catch (...) { + return false; + } +} diff --git a/tests/test_ed25519.cpp b/tests/test_ed25519.cpp index fa715b27..ad31097c 100644 --- a/tests/test_ed25519.cpp +++ b/tests/test_ed25519.cpp @@ -67,6 +67,61 @@ TEST_CASE("Ed25519 seed for private key", "[ed25519][seed]") { "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"); } +TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { + using namespace session; + + // Test vectors generated from Python + // + // clang-format off + // + // import nacl.bindings + // import hashlib + // import os + // + // seed0 = os.urandom(32) + // seed1 = hashlib.blake2b(seed0, key=b'SessionProRandom', digest_size=32).digest() + // (pkey, skey) = nacl.bindings.crypto_sign_seed_keypair(seed=seed0) + // (pro_pkey, pro_skey) = nacl.bindings.crypto_sign_seed_keypair(seed=seed1) + // + // print(f'Seed1: {seed1.hex()}') + // print(f'Pro: {bytes(pro_skey)[:32].hex()} / {bytes(pro_pkey).hex()}') + // + // Output + // + // Seed0: e5481635020d6f7b327e94e6d63e33a431fccabc4d2775845c43a8486a9f2884 + // Pro: a4ec87e2346b25ee6394211cb682640a09dd8d297016fe241fe5b06fefef416c / b6d20c075eddd2edb69d4d7da9b7e580f187ce0537585da2b5e454b77980d0c8 + // + // Seed0: 743d646706b6b04b97b752036dd6cf5f2adc4b339fcfdfb4b496f0764bb93a84 + // Pro: 7da256ba427cf5419cefea81f8ebb3395c261e4dfc2c91ee4d3ce9def67aa21c / 539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8 + // + // clang-format on + + auto ed_seed1 = "e5481635020d6f7b327e94e6d63e33a431fccabc4d2775845c43a8486a9f2884"_hexbytes; + auto ed_seed2 = "743d646706b6b04b97b752036dd6cf5f2adc4b339fcfdfb4b496f0764bb93a84"_hexbytes; + auto ed_seed_invalid = "010203040506070809"_hexbytes; + + auto kp1 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(to_span(ed_seed1)); + auto kp2 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(to_span(ed_seed2)); + CHECK_THROWS(session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(to_span(ed_seed_invalid))); + + CHECK(kp1.first.size() == 32); + CHECK(kp1.second.size() == 64); + CHECK(kp1.first != kp2.first); + CHECK(kp1.second != kp2.second); + CHECK(oxenc::to_hex(kp1.first) == "b6d20c075eddd2edb69d4d7da9b7e580f187ce0537585da2b5e454b77980d0c8"); + CHECK(oxenc::to_hex(kp2.first) == "539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8"); + + auto kp_sk1 = + "a4ec87e2346b25ee6394211cb682640a09dd8d297016fe241fe5b06fefef416c" + "b6d20c075eddd2edb69d4d7da9b7e580f187ce0537585da2b5e454b77980d0c8"; + auto kp_sk2 = + "7da256ba427cf5419cefea81f8ebb3395c261e4dfc2c91ee4d3ce9def67aa21c" + "539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8"; + + CHECK(oxenc::to_hex(kp1.second) == kp_sk1); + CHECK(oxenc::to_hex(kp2.second) == kp_sk2); +} + TEST_CASE("Ed25519", "[ed25519][signature]") { using namespace session; From bb1c6067610628defcc10cfb082d63a7cb4edd05 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 1 Aug 2025 11:17:52 +1000 Subject: [PATCH 002/171] Only give 64b skey from session pro keygen This simplifies the API and minimises the API surface with code interacting with it since the public key is already bundled with the secret. - Add helper function to derive keys from the original seed - Use _hex_u literals to simplify test construction code --- include/session/ed25519.h | 7 ++-- include/session/ed25519.hpp | 6 ++-- src/ed25519.cpp | 66 ++++++++++++++++++++----------------- tests/test_ed25519.cpp | 26 +++++++-------- 4 files changed, 51 insertions(+), 54 deletions(-) diff --git a/include/session/ed25519.h b/include/session/ed25519.h index 932dc2e2..9418154d 100644 --- a/include/session/ed25519.h +++ b/include/session/ed25519.h @@ -103,17 +103,14 @@ LIBSESSION_EXPORT bool session_ed25519_verify( /// Inputs: /// - `ed25519_seed` -- [in] the seed to the long-term key for the Session account to derive the /// deterministic key from. -/// - `ed25519_pk_out` -- [out] pointer to a buffer of 32 bytes where the public key will be -/// written. /// - `ed25519_sk_out` -- [out] pointer to a buffer of 64 bytes where the private key will be -/// written. +/// written. /// /// Outputs: /// - `bool` -- True if the key pair was successfully derived, false if failed. LIBSESSION_EXPORT bool session_ed25519_pro_key_pair_for_ed25519_seed( const unsigned char* ed25519_seed, /* 32 bytes */ - unsigned char *ed25519_pk_out, /*32 byte output buffer*/ - unsigned char *ed25519_sk_out /*64 byte output buffer*/); + unsigned char* ed25519_sk_out /*64 byte output buffer*/); #ifdef __cplusplus } diff --git a/include/session/ed25519.hpp b/include/session/ed25519.hpp index d4e599db..d4a7b892 100644 --- a/include/session/ed25519.hpp +++ b/include/session/ed25519.hpp @@ -66,8 +66,8 @@ bool verify( /// deterministic key from. /// /// Outputs: -/// - The Master Session Pro ed25519 key -std::pair, std::array> -ed25519_pro_key_pair_for_ed25519_seed(std::span ed25519_seed); +/// - The libsodium-style Master Session Pro Ed25519 secret key, 64 bytes. +std::array ed25519_pro_key_pair_for_ed25519_seed( + std::span ed25519_seed); } // namespace session::ed25519 diff --git a/src/ed25519.cpp b/src/ed25519.cpp index 3ed15be5..d537e39a 100644 --- a/src/ed25519.cpp +++ b/src/ed25519.cpp @@ -7,18 +7,44 @@ #include #include "session/export.h" -#include "session/sodium_array.hpp" -namespace session::ed25519 { +#include "session/sodium_array.hpp" template -using cleared_array = sodium_cleared>; +using cleared_array = session::sodium_cleared>; using uc32 = std::array; using uc64 = std::array; using cleared_uc32 = cleared_array<32>; using cleared_uc64 = cleared_array<64>; +namespace { +uc64 derived_ed25519_keypair( + std::span ed25519_seed, std::string_view key) { + if (ed25519_seed.size() != 32 && ed25519_seed.size() != 64) + throw std::invalid_argument{ + "Invalid ed25519_seed: expected 32 bytes or libsodium style 64 bytes seed"}; + + // Construct seed for derived key + // new_seed = Blake2b32(ed25519_seed, key=) + // b/B = Ed25519FromSeed(new_seed) + cleared_uc32 s2 = {}; + int hash_result = crypto_generichash_blake2b( + s2.data(), + s2.size(), + ed25519_seed.data(), + ed25519_seed.size(), + reinterpret_cast(key.data()), + key.size()); + assert(hash_result == 0); // This function can't return 0 unless misused + + auto [pubkey, privkey] = session::ed25519::ed25519_key_pair(s2); + return privkey; +} +} + +namespace session::ed25519 { + std::pair, std::array> ed25519_key_pair() { std::array ed_pk; std::array ed_sk; @@ -89,29 +115,11 @@ bool verify( crypto_sign_ed25519_verify_detached(sig.data(), msg.data(), msg.size(), pubkey.data())); } -std::pair, std::array> -ed25519_pro_key_pair_for_ed25519_seed(std::span ed25519_seed) { - if (ed25519_seed.size() != 32) - throw std::invalid_argument{"Invalid ed25519_seed: expected 32 bytes"}; - - // Construct master key - // s2 = Blake2b32(s, key="SessionProRandom") - // b/B = Ed25519FromSeed(s2) - constexpr std::string_view BLAKE2B_KEY = "SessionProRandom"; - uc32 s2 = {}; - int hash_result = crypto_generichash_blake2b( - s2.data(), - s2.size(), - ed25519_seed.data(), - ed25519_seed.size(), - reinterpret_cast(BLAKE2B_KEY.data()), - BLAKE2B_KEY.size()); - assert(hash_result == 0); // This function can't return 0 unless misused - - std::pair result = ed25519_key_pair(s2); +std::array ed25519_pro_key_pair_for_ed25519_seed( + std::span ed25519_seed) { + auto result = derived_ed25519_keypair(ed25519_seed, "SessionProRandom"); return result; } - } // namespace session::ed25519 using namespace session; @@ -185,15 +193,11 @@ LIBSESSION_C_API bool session_ed25519_verify( } LIBSESSION_C_API bool session_ed25519_pro_key_pair_for_ed25519_seed( - const unsigned char* ed25519_seed, - unsigned char* ed25519_pk_out, - unsigned char* ed25519_sk_out) { + const unsigned char* ed25519_seed, unsigned char* ed25519_sk_out) { try { auto seed = std::span(ed25519_seed, 32); - auto result = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed); - auto [ed_pk, ed_sk] = result; - std::memcpy(ed25519_pk_out, ed_pk.data(), ed_pk.size()); - std::memcpy(ed25519_sk_out, ed_sk.data(), ed_sk.size()); + uc64 sk = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed); + std::memcpy(ed25519_sk_out, sk.data(), sk.size()); return true; } catch (...) { return false; diff --git a/tests/test_ed25519.cpp b/tests/test_ed25519.cpp index ad31097c..4fcddddc 100644 --- a/tests/test_ed25519.cpp +++ b/tests/test_ed25519.cpp @@ -83,7 +83,7 @@ TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { // (pkey, skey) = nacl.bindings.crypto_sign_seed_keypair(seed=seed0) // (pro_pkey, pro_skey) = nacl.bindings.crypto_sign_seed_keypair(seed=seed1) // - // print(f'Seed1: {seed1.hex()}') + // print(f'Seed0: {seed0.hex()}') // print(f'Pro: {bytes(pro_skey)[:32].hex()} / {bytes(pro_pkey).hex()}') // // Output @@ -96,20 +96,16 @@ TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { // // clang-format on - auto ed_seed1 = "e5481635020d6f7b327e94e6d63e33a431fccabc4d2775845c43a8486a9f2884"_hexbytes; - auto ed_seed2 = "743d646706b6b04b97b752036dd6cf5f2adc4b339fcfdfb4b496f0764bb93a84"_hexbytes; - auto ed_seed_invalid = "010203040506070809"_hexbytes; + constexpr auto seed1 = "e5481635020d6f7b327e94e6d63e33a431fccabc4d2775845c43a8486a9f2884"_hex_u; + constexpr auto seed2 = "743d646706b6b04b97b752036dd6cf5f2adc4b339fcfdfb4b496f0764bb93a84"_hex_u; + constexpr auto seed_invalid = "010203040506070809"_hex_u; - auto kp1 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(to_span(ed_seed1)); - auto kp2 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(to_span(ed_seed2)); - CHECK_THROWS(session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(to_span(ed_seed_invalid))); + auto sk1 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed1); + auto sk2 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed2); + CHECK_THROWS(session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed_invalid)); - CHECK(kp1.first.size() == 32); - CHECK(kp1.second.size() == 64); - CHECK(kp1.first != kp2.first); - CHECK(kp1.second != kp2.second); - CHECK(oxenc::to_hex(kp1.first) == "b6d20c075eddd2edb69d4d7da9b7e580f187ce0537585da2b5e454b77980d0c8"); - CHECK(oxenc::to_hex(kp2.first) == "539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8"); + CHECK(sk1.size() == 64); + CHECK(sk1 != sk2); auto kp_sk1 = "a4ec87e2346b25ee6394211cb682640a09dd8d297016fe241fe5b06fefef416c" @@ -118,8 +114,8 @@ TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { "7da256ba427cf5419cefea81f8ebb3395c261e4dfc2c91ee4d3ce9def67aa21c" "539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8"; - CHECK(oxenc::to_hex(kp1.second) == kp_sk1); - CHECK(oxenc::to_hex(kp2.second) == kp_sk2); + CHECK(oxenc::to_hex(sk1) == kp_sk1); + CHECK(oxenc::to_hex(sk2) == kp_sk2); } TEST_CASE("Ed25519", "[ed25519][signature]") { From f389098fad289e23a265a66664b2eb88d271f5f3 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 1 Aug 2025 11:32:15 +1000 Subject: [PATCH 003/171] Apply _hex_u changes to rest of ed25519 tests --- tests/test_ed25519.cpp | 84 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/tests/test_ed25519.cpp b/tests/test_ed25519.cpp index 4fcddddc..eb5f4ec1 100644 --- a/tests/test_ed25519.cpp +++ b/tests/test_ed25519.cpp @@ -3,40 +3,36 @@ #include #include -#include "session/ed25519.h" #include "session/ed25519.hpp" -#include "utils.hpp" TEST_CASE("Ed25519 key pair generation", "[ed25519][keypair]") { // Generate two random key pairs and make sure they don't match - auto kp1 = session::ed25519::ed25519_key_pair(); - auto kp2 = session::ed25519::ed25519_key_pair(); + auto [pk1, sk1] = session::ed25519::ed25519_key_pair(); + auto [pk2, sk2] = session::ed25519::ed25519_key_pair(); - CHECK(kp1.first.size() == 32); - CHECK(kp1.second.size() == 64); - CHECK(kp1.first != kp2.first); - CHECK(kp1.second != kp2.second); + CHECK(pk1.size() == 32); + CHECK(sk1.size() == 64); + CHECK(pk1 != pk2); + CHECK(sk1 != sk2); } TEST_CASE("Ed25519 key pair generation seed", "[ed25519][keypair]") { using namespace session; - auto ed_seed1 = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hexbytes; - auto ed_seed2 = "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"_hexbytes; - auto ed_seed_invalid = "010203040506070809"_hexbytes; + constexpr auto ed_seed1 = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hex_u; + constexpr auto ed_seed2 = "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"_hex_u; + constexpr auto ed_seed_invalid = "010203040506070809"_hex_u; - auto kp1 = session::ed25519::ed25519_key_pair(to_span(ed_seed1)); - auto kp2 = session::ed25519::ed25519_key_pair(to_span(ed_seed2)); - CHECK_THROWS(session::ed25519::ed25519_key_pair(to_span(ed_seed_invalid))); + auto [pk1, sk1] = session::ed25519::ed25519_key_pair(ed_seed1); + auto [pk2, sk2] = session::ed25519::ed25519_key_pair(ed_seed2); + CHECK_THROWS(session::ed25519::ed25519_key_pair(ed_seed_invalid)); - CHECK(kp1.first.size() == 32); - CHECK(kp1.second.size() == 64); - CHECK(kp1.first != kp2.first); - CHECK(kp1.second != kp2.second); - CHECK(oxenc::to_hex(kp1.first.begin(), kp1.first.end()) == - "8862834829a87e0afadfed763fa8785e893dbde7f2c001ff1071aa55005c347f"); - CHECK(oxenc::to_hex(kp2.first.begin(), kp2.first.end()) == - "cd83ca3d13ad8a954d5011aa7861abe3a29ac25b70c4ed5234aff74d34ef5786"); + CHECK(pk1.size() == 32); + CHECK(sk1.size() == 64); + CHECK(pk1 != pk2); + CHECK(sk1 != sk2); + CHECK(oxenc::to_hex(pk1) == "8862834829a87e0afadfed763fa8785e893dbde7f2c001ff1071aa55005c347f"); + CHECK(oxenc::to_hex(pk2) == "cd83ca3d13ad8a954d5011aa7861abe3a29ac25b70c4ed5234aff74d34ef5786"); auto kp_sk1 = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab78862834829a" @@ -44,26 +40,27 @@ TEST_CASE("Ed25519 key pair generation seed", "[ed25519][keypair]") { auto kp_sk2 = "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876cd83ca3d13a" "d8a954d5011aa7861abe3a29ac25b70c4ed5234aff74d34ef5786"; - CHECK(oxenc::to_hex(kp1.second.begin(), kp1.second.end()) == kp_sk1); - CHECK(oxenc::to_hex(kp2.second.begin(), kp2.second.end()) == kp_sk2); + CHECK(oxenc::to_hex(sk1) == kp_sk1); + CHECK(oxenc::to_hex(sk2) == kp_sk2); } TEST_CASE("Ed25519 seed for private key", "[ed25519][seed]") { using namespace session; - auto ed_sk1 = + constexpr auto ed_sk1 = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab78862834829a" - "87e0afadfed763fa8785e893dbde7f2c001ff1071aa55005c347f"_hexbytes; - auto ed_sk2 = "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"_hexbytes; - auto ed_sk_invalid = "010203040506070809"_hexbytes; + "87e0afadfed763fa8785e893dbde7f2c001ff1071aa55005c347f"_hex_u; + constexpr auto ed_sk2 = + "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"_hex_u; + constexpr auto ed_sk_invalid = "010203040506070809"_hex_u; - auto seed1 = session::ed25519::seed_for_ed_privkey(to_span(ed_sk1)); - auto seed2 = session::ed25519::seed_for_ed_privkey(to_span(ed_sk2)); - CHECK_THROWS(session::ed25519::seed_for_ed_privkey(to_span(ed_sk_invalid))); + auto seed1 = session::ed25519::seed_for_ed_privkey(ed_sk1); + auto seed2 = session::ed25519::seed_for_ed_privkey(ed_sk2); + CHECK_THROWS(session::ed25519::seed_for_ed_privkey(ed_sk_invalid)); - CHECK(oxenc::to_hex(seed1.begin(), seed1.end()) == + CHECK(oxenc::to_hex(seed1) == "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"); - CHECK(oxenc::to_hex(seed2.begin(), seed2.end()) == + CHECK(oxenc::to_hex(seed2) == "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"); } @@ -108,11 +105,11 @@ TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { CHECK(sk1 != sk2); auto kp_sk1 = - "a4ec87e2346b25ee6394211cb682640a09dd8d297016fe241fe5b06fefef416c" - "b6d20c075eddd2edb69d4d7da9b7e580f187ce0537585da2b5e454b77980d0c8"; + "a4ec87e2346b25ee6394211cb682640a09dd8d297016fe241fe5b06fefef416c" + "b6d20c075eddd2edb69d4d7da9b7e580f187ce0537585da2b5e454b77980d0c8"; auto kp_sk2 = - "7da256ba427cf5419cefea81f8ebb3395c261e4dfc2c91ee4d3ce9def67aa21c" - "539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8"; + "7da256ba427cf5419cefea81f8ebb3395c261e4dfc2c91ee4d3ce9def67aa21c" + "539d0a3be9658ebb6ba3ce97b25d4f6b716f7ef6d6ae6343bd0733519f5a51e8"; CHECK(oxenc::to_hex(sk1) == kp_sk1); CHECK(oxenc::to_hex(sk2) == kp_sk2); @@ -121,17 +118,18 @@ TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { TEST_CASE("Ed25519", "[ed25519][signature]") { using namespace session; - auto ed_seed = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hexbytes; - auto ed_pk = "8862834829a87e0afadfed763fa8785e893dbde7f2c001ff1071aa55005c347f"_hexbytes; - auto ed_invalid = "010203040506070809"_hexbytes; + constexpr auto ed_seed = + "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hex_u; + constexpr auto ed_pk = "8862834829a87e0afadfed763fa8785e893dbde7f2c001ff1071aa55005c347f"_hex_u; + constexpr auto ed_invalid = "010203040506070809"_hex_u; - auto sig1 = session::ed25519::sign(to_span(ed_seed), to_span("hello")); - CHECK_THROWS(session::ed25519::sign(to_span(ed_invalid), to_span("hello"))); + auto sig1 = session::ed25519::sign(ed_seed, to_span("hello")); + CHECK_THROWS(session::ed25519::sign(ed_invalid, to_span("hello"))); auto expected_sig_hex = "e03b6e87a53d83f202f2501e9b52193dbe4a64c6503f88244948dee53271" "85011574589aa7b59bc9757f9b9c31b7be9c9212b92ac7c81e029ee21c338ee12405"; - CHECK(oxenc::to_hex(sig1.begin(), sig1.end()) == expected_sig_hex); + CHECK(oxenc::to_hex(sig1) == expected_sig_hex); CHECK(session::ed25519::verify(sig1, ed_pk, to_span("hello"))); CHECK_THROWS(session::ed25519::verify(ed_invalid, ed_pk, to_span("hello"))); From 3f7b161185ed6056176d7787fe168c2ad8fb811f Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 1 Aug 2025 11:38:15 +1000 Subject: [PATCH 004/171] Use cleared_u32 and 64 from sodium_array header --- src/ed25519.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ed25519.cpp b/src/ed25519.cpp index d537e39a..2ba8cff2 100644 --- a/src/ed25519.cpp +++ b/src/ed25519.cpp @@ -11,12 +11,8 @@ #include "session/sodium_array.hpp" template -using cleared_array = session::sodium_cleared>; - using uc32 = std::array; using uc64 = std::array; -using cleared_uc32 = cleared_array<32>; -using cleared_uc64 = cleared_array<64>; namespace { uc64 derived_ed25519_keypair( @@ -28,7 +24,7 @@ uc64 derived_ed25519_keypair( // Construct seed for derived key // new_seed = Blake2b32(ed25519_seed, key=) // b/B = Ed25519FromSeed(new_seed) - cleared_uc32 s2 = {}; + session::cleared_uc32 s2 = {}; int hash_result = crypto_generichash_blake2b( s2.data(), s2.size(), From 99cb28071cc64ce76289b47f5890233c8a732ced Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 1 Aug 2025 13:28:27 +1000 Subject: [PATCH 005/171] Linting fix --- src/ed25519.cpp | 8 +++----- tests/test_ed25519.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ed25519.cpp b/src/ed25519.cpp index 2ba8cff2..3cc5dc17 100644 --- a/src/ed25519.cpp +++ b/src/ed25519.cpp @@ -7,7 +7,6 @@ #include #include "session/export.h" - #include "session/sodium_array.hpp" template @@ -15,8 +14,7 @@ using uc32 = std::array; using uc64 = std::array; namespace { -uc64 derived_ed25519_keypair( - std::span ed25519_seed, std::string_view key) { +uc64 derived_ed25519_keypair(std::span ed25519_seed, std::string_view key) { if (ed25519_seed.size() != 32 && ed25519_seed.size() != 64) throw std::invalid_argument{ "Invalid ed25519_seed: expected 32 bytes or libsodium style 64 bytes seed"}; @@ -30,14 +28,14 @@ uc64 derived_ed25519_keypair( s2.size(), ed25519_seed.data(), ed25519_seed.size(), - reinterpret_cast(key.data()), + reinterpret_cast(key.data()), key.size()); assert(hash_result == 0); // This function can't return 0 unless misused auto [pubkey, privkey] = session::ed25519::ed25519_key_pair(s2); return privkey; } -} +} // namespace namespace session::ed25519 { diff --git a/tests/test_ed25519.cpp b/tests/test_ed25519.cpp index eb5f4ec1..c04bf2cb 100644 --- a/tests/test_ed25519.cpp +++ b/tests/test_ed25519.cpp @@ -19,8 +19,10 @@ TEST_CASE("Ed25519 key pair generation", "[ed25519][keypair]") { TEST_CASE("Ed25519 key pair generation seed", "[ed25519][keypair]") { using namespace session; - constexpr auto ed_seed1 = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hex_u; - constexpr auto ed_seed2 = "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"_hex_u; + constexpr auto ed_seed1 = + "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hex_u; + constexpr auto ed_seed2 = + "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"_hex_u; constexpr auto ed_seed_invalid = "010203040506070809"_hex_u; auto [pk1, sk1] = session::ed25519::ed25519_key_pair(ed_seed1); From 445c7f3f52d2bf7b71191af90e8ab827e78be089 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 31 Jul 2025 17:11:49 +1000 Subject: [PATCH 006/171] Add basic pro proof verification functions --- src/CMakeLists.txt | 1 + src/pro.cpp | 179 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 src/pro.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b4e66b7..5fc071a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,6 +53,7 @@ add_libsession_util_library(crypto session_encrypt.cpp sodium_array.cpp xed25519.cpp + pro.cpp ) add_libsession_util_library(config diff --git a/src/pro.cpp b/src/pro.cpp new file mode 100644 index 00000000..4d078810 --- /dev/null +++ b/src/pro.cpp @@ -0,0 +1,179 @@ +#include +#include +#include +#include +#include + +#include + +namespace session::pro { + +constexpr std::array BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static_assert(BACKEND_PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + +struct proof { + uint8_t version; + std::array gen_index_hash; + std::array rotating_pubkey; + std::chrono::seconds expiry_unix_ts; + std::array sig; +}; +static_assert(sizeof(((proof *)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert(sizeof(((proof *)0)->sig) == crypto_sign_ed25519_BYTES); + +struct add_payment_request { + uint8_t version; + std::array master_pkey; + std::array rotating_pkey; + std::array payment_token; + std::array master_sig; + std::array rotating_sig; + std::string to_json() const; +}; + +struct get_proof_request { + uint8_t version; + std::array master_pkey; + std::array rotating_pkey; + std::chrono::seconds unix_ts_s; + std::array master_sig; + std::array rotating_sig; + std::string to_json() const; +}; + +struct master_rotating_sigs { + std::array master_sig; + std::array rotating_sig; +}; + +struct revocation_item { + std::array gen_index_hash; + std::chrono::seconds expiry_unix_ts; +}; + +bool verify_proof(const proof& item); +master_rotating_sigs build_get_proof_sigs(std::array master_privkey, std::array rotating_privkey, std::chrono::seconds unix_ts); +master_rotating_sigs build_add_payment_sigs(std::array master_privkey, std::array rotating_privkey, std::array payment_token_hash, std::chrono::seconds unix_ts); + + +bool verify_proof(const proof& item) { + uint64_t expiry_unix_ts_u64 = item.expiry_unix_ts.count(); + std::array hash = {}; + crypto_generichash_blake2b_state state; + crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash.max_size()); + crypto_generichash_blake2b_update(&state, &item.version, sizeof(item.version)); + crypto_generichash_blake2b_update( + &state, item.gen_index_hash.data(), item.gen_index_hash.size()); + crypto_generichash_blake2b_update( + &state, item.rotating_pubkey.data(), item.rotating_pubkey.size()); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&expiry_unix_ts_u64), sizeof(expiry_unix_ts_u64)); + crypto_generichash_blake2b_final(&state, hash.data(), hash.size()); + + int verify_result = crypto_sign_ed25519_verify_detached( + item.sig.data(), hash.data(), hash.size(), BACKEND_PUBKEY.data()); + bool result = verify_result == 0; + return result; +} + +master_rotating_sigs build_get_proof_sigs( + std::array master_privkey, + std::array rotating_privkey, + std::chrono::seconds unix_ts) { + // Derive the public keys + std::array master_pubkey; + std::array rotating_pubkey; + crypto_sign_ed25519_sk_to_pk(master_pubkey.data(), master_privkey.data()); + crypto_sign_ed25519_sk_to_pk(rotating_pubkey.data(), rotating_privkey.data()); + + // Hash components to 32 bytes + uint8_t version = 0; + uint64_t unix_ts_s = unix_ts.count(); + std::array hash_to_sign = {}; + crypto_generichash_blake2b_state state; + crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update(&state, master_pubkey.data(), master_pubkey.size()); + crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); + crypto_generichash_blake2b_update(&state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); + + // Sign the hash with both keys + master_rotating_sigs result = {}; + crypto_sign_ed25519_detached(result.master_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), master_privkey.data()); + crypto_sign_ed25519_detached(result.rotating_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), rotating_privkey.data()); + return result; +} + +master_rotating_sigs build_add_payment_sigs( + std::array master_privkey, + std::array rotating_privkey, + std::array payment_token_hash, + std::chrono::seconds unix_ts) { + // Derive the public keys + std::array master_pubkey; + std::array rotating_pubkey; + crypto_sign_ed25519_sk_to_pk(master_pubkey.data(), master_privkey.data()); + crypto_sign_ed25519_sk_to_pk(rotating_pubkey.data(), rotating_privkey.data()); + + // Hash components to 32 bytes + uint8_t version = 0; + std::array hash_to_sign = {}; + crypto_generichash_blake2b_state state; + crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update(&state, master_pubkey.data(), master_pubkey.size()); + crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); + crypto_generichash_blake2b_update(&state, payment_token_hash.data(), payment_token_hash.size()); + crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); + + // Sign the hash with both keys + master_rotating_sigs result = {}; + crypto_sign_ed25519_detached(result.master_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), master_privkey.data()); + crypto_sign_ed25519_detached(result.rotating_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), rotating_privkey.data()); + return result; +} + +std::string get_proof_request::to_json() const { + // TODO: Cleanup + std::string result = fmt::format( + R"({{ + "version": {}, + "master_pkey": "{}", + "rotating_pkey": "{}", + "unix_ts_s": {}, + "master_sig": "{}", + "rotating_sig": "{}", +}})", + 0, + oxenc::to_hex(master_pkey), + oxenc::to_hex(rotating_pkey), + unix_ts_s.count(), + oxenc::to_hex(master_sig), + oxenc::to_hex(rotating_sig)); + return result; +} + +std::string add_payment_request::to_json() const { + // TODO: Cleanup + std::string result = fmt::format( + R"({{ + "version": {}, + "master_pkey": "{}", + "rotating_pkey": "{}", + "payment_token": "{}", + "master_sig": "{}", + "rotating_sig": "{}", +}})", + 0, + oxenc::to_hex(master_pkey), + oxenc::to_hex(rotating_pkey), + oxenc::to_hex(payment_token), + oxenc::to_hex(master_sig), + oxenc::to_hex(rotating_sig)); + return result; +} +} // namespace session::pro From d222dd8ed4f5abe5621bea8bb070b0392227b933 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 4 Aug 2025 16:39:59 +1000 Subject: [PATCH 007/171] Reformat the string split in test_config_userprofile --- tests/test_config_userprofile.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/test_config_userprofile.cpp b/tests/test_config_userprofile.cpp index 2d84a54c..e8f2b5f2 100644 --- a/tests/test_config_userprofile.cpp +++ b/tests/test_config_userprofile.cpp @@ -63,28 +63,24 @@ TEST_CASE("UserProfile", "[config][user_profile]") { session::config::UserProfile profile{std::span{seed}, std::nullopt}; - CHECK_THROWS( - profile.set_name("123456789012345678901234567890123456789012345678901234567890123456789" - "01" - "23456789012345678901234567890A")); - CHECK_NOTHROW( - profile.set_name_truncated("12345678901234567890123456789012345678901234567890123456789" - "01" - "234567890123456789012345678901234567890A")); + CHECK_THROWS(profile.set_name( + "123456789012345678901234567890123456789012345678901234567890123456789" + "0123456789012345678901234567890A")); + CHECK_NOTHROW(profile.set_name_truncated( + "12345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890A")); CHECK(profile.get_name() == "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" "901234567890"); - CHECK_NOTHROW( - profile.set_name_truncated("12345678901234567890123456789012345678901234567890123456789" - "01" - "234567890123456789012345678901234567🎂")); + CHECK_NOTHROW(profile.set_name_truncated( + "12345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567🎂")); CHECK(profile.get_name() == "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" "901234567"); - CHECK_NOTHROW( - profile.set_name_truncated("12345678901234567890123456789012345678901234567890123456789" - "01" - "2345678901234567890123456789012345🎂🎂")); + CHECK_NOTHROW(profile.set_name_truncated( + "12345678901234567890123456789012345678901234567890123456789" + "012345678901234567890123456789012345🎂🎂")); CHECK(profile.get_name() == "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" "9012345🎂"); From b719549e12ff44c5cc6517a3b54a6b4a462f747b Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 4 Aug 2025 16:43:08 +1000 Subject: [PATCH 008/171] Add pro proof and rotating key pair to user profile --- include/session/config/pro.hpp | 93 +++++++++++++++++++++ include/session/config/user_profile.hpp | 26 +++++- proto/SessionProtos.proto | 10 +++ src/CMakeLists.txt | 1 + src/config/pro.cpp | 103 ++++++++++++++++++++++++ src/config/user_profile.cpp | 23 ++++++ src/pro.cpp | 37 +-------- tests/CMakeLists.txt | 1 + tests/test_config_pro.cpp | 103 ++++++++++++++++++++++++ 9 files changed, 360 insertions(+), 37 deletions(-) create mode 100644 include/session/config/pro.hpp create mode 100644 src/config/pro.cpp create mode 100644 tests/test_config_pro.cpp diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp new file mode 100644 index 00000000..13f5bef5 --- /dev/null +++ b/include/session/config/pro.hpp @@ -0,0 +1,93 @@ +#include +#include +#include + +#include +#include + +namespace session::config { + +/// keys used currently or in the past (so that we don't reuse): +/// +/// v - version +/// g - gen_index_hash +/// r - rotating ed25519 pubkey +/// e - expiry unix timestamp (in seconds) +/// s - proof signature, signed by the Session Pro Backend's ed25519 key +class Proof { + public: + /// Version of the proof set by the Session Pro Backend + uint8_t version; + + /// Hash of the generation index set by the Session Pro Backend + std::array gen_index_hash; + + /// The public key that the Session client registers their Session Pro entitlement under. + /// Session clients must sign messages with this key along side the sending of this proof for + /// the network to authenticate their usage of the proof + std::array rotating_pubkey; + + /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid to + std::chrono::sys_seconds expiry_unix_ts; + + /// Signature over the contents of the proof. It is signed by the Session Pro Backend key which + /// is the entity responsible for issueing tamper-proof Sesison Pro certificates for Session + /// clients. + std::array sig; + + /// API: pro/Proof::verify + /// + /// Verify that the proof's contents was not tampered with by hashing the proof and checking + /// that the hash was signed by the secret key of the given Ed25519 public key. + /// + /// For Session Pro intents and purposes, we expect proofs to be signed by the Session Pro + /// Backend public key. + /// + /// Inputs: + /// - `verify_pubkey` -- Ed25519 public key of the corresponding secret key to check if they are + /// the original signatory of the proof. + /// + /// Outputs: + /// - `bool` - True if the given key was the signatory of the proof, false otherwise + bool verify(const std::array& verify_pubkey) const; + + /// API: pro/Proof::hash + /// + /// Create a 32-byte hash from the proof. This hash is the payload that is signed in the proof. + std::array hash() const; + + bool load(const dict& root); +}; + +/// keys used currently or in the past (so that we don't reuse): +/// +/// r - rotating ed25519 privkey +/// p - proof +class Pro { + public: + /// Private key for the public key key specified in the proof. This is synced between clients + /// to allow multiple clients to synchronise the Session Pro Proof and also the keys necessary + /// to use the proof. + std::array rotating_privkey; + + /// A cryptographic proof for entitling an Ed25519 key to Session Pro + Proof proof; + + /// API: pro/Pro::verify + /// + /// Verify the proof and that the proof's rotating public key matches the public key of the + /// `rotating_privkey` + /// + /// Inputs: + /// - `verify_pubkey` -- Ed25519 public key of the corresponding secret key to check if they are + /// the original signatory of the proof. + /// + /// Outputs: + /// - `bool` - True if the proof was verified and the proof's rotating public key corresponds to + /// the public component of the `rotating_privkey`. + bool verify(const std::array& verify_pubkey) const; + + bool load(const dict& root); +}; + +}; // namespace session::config diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index c9601086..c3b775a6 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -8,6 +8,7 @@ #include "base.hpp" #include "namespaces.hpp" #include "profile_pic.hpp" +#include "pro.hpp" namespace session::config { @@ -24,6 +25,7 @@ using namespace std::literals; /// M - set to 1 if blinded message request retrieval is enabled, 0 if retrieval is *disabled*, and /// omitted if the setting has not been explicitly set (or has been explicitly cleared for some /// reason). +/// s - session pro data /// t - The unix timestamp (seconds) that the user last explicitly updated their profile information /// (automatically updates when changing `name`, `profile_pic` or `set_blinded_msgreqs`). /// P - user profile url after re-uploading (should take precedence over `p` when `T > t`). @@ -31,7 +33,6 @@ using namespace std::literals; /// when `T > t`). /// T - The unix timestamp (seconds) that the user last re-uploaded their profile information /// (automatically updates when calling `set_reupload_profile_pic`). - class UserProfile : public ConfigBase { public: @@ -166,7 +167,7 @@ class UserProfile : public ConfigBase { /// Inputs: None /// /// Outputs: - /// - `int` - Returns a numeric representing prioritity + /// - `int` -- Returns a numeric representing prioritity int get_nts_priority() const; /// API: user_profile/UserProfile::set_nts_priority @@ -186,7 +187,7 @@ class UserProfile : public ConfigBase { /// Inputs: None /// /// Outputs: - /// - `std::optional` - Returns the timestamp representing the message + /// - `std::optional` -- Returns the timestamp representing the message /// expiry timer if the timer is set std::optional get_nts_expiry() const; @@ -242,6 +243,25 @@ class UserProfile : public ConfigBase { std::chrono::sys_seconds get_profile_updated() const; bool accepts_protobuf() const override { return true; } + + /// API: user_profile/UserProfile::get_pro_data + /// + /// Get the Session Pro data if any, for the current user profile. This may be missing if the + /// user does not have any entitlement to Session Pro data. + /// + /// Inputs: None + std::optional get_pro_data() const; + + /// API: user_profile/UserProfile::set_pro_data + /// + /// Attach the Session Pro components to the user profile including the proof entitling the user + /// to use Session Pro features as well as the Ed25519 key pair known as the Rotating Session + /// Pro key authorised to use the proof. + /// + /// Inputs: + /// - `pro` -- The Session Pro components to assign to the current user profile. This will + /// overwrite any existing Session Pro data if it exists. No verification of `pro` is done. + void set_pro_data(const Pro& pro); }; } // namespace session::config diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index d112322b..a9d434b0 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -234,12 +234,22 @@ message ConfigurationMessage { optional bool didApproveMe = 7; // added for msg requests } + message ProProof { + required uint32 version = 1; + required bytes genIndexHash = 2; + required bytes rotatingPublicKey = 3; + required uint64 expiryUnixTs = 4; + required bytes sig = 5; + } + repeated ClosedGroup closedGroups = 1; repeated string openGroups = 2; optional string displayName = 3; optional string profilePicture = 4; optional bytes profileKey = 5; repeated Contact contacts = 6; + optional bytes proRotatingKey = 7; + optional ProProof proProof = 8; } message ReceiptMessage { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5fc071a1..f0a406de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,6 +71,7 @@ add_libsession_util_library(config config/internal.cpp config/local.cpp config/protos.cpp + config/pro.cpp config/user_groups.cpp config/user_profile.cpp fields.cpp diff --git a/src/config/pro.cpp b/src/config/pro.cpp new file mode 100644 index 00000000..72ac707d --- /dev/null +++ b/src/config/pro.cpp @@ -0,0 +1,103 @@ +#include +#include + +#include +#include + +#include "internal.hpp" + +namespace session::config { + +static_assert(sizeof(((Proof *)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert(sizeof(((Proof *)0)->sig) == crypto_sign_ed25519_BYTES); + +bool Proof::verify(const std::array& verify_pubkey) const +{ + std::array hash_to_sign = hash(); + int verify_result = crypto_sign_ed25519_verify_detached( + sig.data(), hash_to_sign.data(), hash_to_sign.size(), verify_pubkey.data()); + bool result = verify_result == 0; + return result; +} + +std::array Proof::hash() const +{ + // TODO: Check why does sys_time have a time since epoch? Is it counting some other duration? + uint64_t expiry_unix_ts_u64 = expiry_unix_ts.time_since_epoch().count(); + std::array result = {}; + crypto_generichash_blake2b_state state; + crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update( + &state, gen_index_hash.data(), gen_index_hash.size()); + crypto_generichash_blake2b_update( + &state, rotating_pubkey.data(), rotating_pubkey.size()); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&expiry_unix_ts_u64), sizeof(expiry_unix_ts_u64)); + crypto_generichash_blake2b_final(&state, result.data(), result.size()); + return result; +} + +bool Proof::load(const dict& root) +{ + std::optional version = maybe_int(root, "v"); + std::optional> maybe_gen_index_hash = maybe_vector(root, "g"); + std::optional> maybe_rotating_pubkey = maybe_vector(root, "r"); + std::optional maybe_expiry_unix_ts = maybe_ts(root, "e"); + std::optional> maybe_sig = maybe_vector(root, "s"); + + if (!version) + return false; + if (!maybe_gen_index_hash || maybe_gen_index_hash->size() != gen_index_hash.size()) + return false; + if (!maybe_rotating_pubkey || maybe_rotating_pubkey->size() != rotating_pubkey.max_size()) + return false; + if (!maybe_sig || maybe_sig->size() != sig.max_size()) + return false; + + version = *version; + std::memcpy(gen_index_hash.data(), maybe_gen_index_hash->data(), gen_index_hash.size()); + std::memcpy(rotating_pubkey.data(), maybe_rotating_pubkey->data(), rotating_pubkey.size()); + expiry_unix_ts = *maybe_expiry_unix_ts; + std::memcpy(sig.data(), maybe_sig->data(), sig.size()); + + return true; +} + +bool Pro::verify(const std::array& verify_pubkey) const +{ + if (!proof.verify(verify_pubkey)) + return false; + + std::array rederived_pk; + [[maybe_unused]] session::cleared_uc32 rederived_sk; + crypto_sign_ed25519_seed_keypair( + rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); + bool result = rederived_pk == proof.rotating_pubkey; + return result; +} + +bool Pro::load(const dict& root) +{ + // Get proof fields sitting in 'p' dictionary + auto p_it = root.find("p"); + if (p_it == root.end()) + return false; + + // Lookup and get 'p' + const config::dict* p = std::get_if(&p_it->second); + if (!p) + return false; + + std::optional> maybe_rotating_privkey = maybe_vector(root, "r"); + if (!maybe_rotating_privkey || maybe_rotating_privkey->size() != rotating_privkey.max_size()) + return false; + + if (!proof.load(*p)) + return false; + + std::memcpy(rotating_privkey.data(), maybe_rotating_privkey->data(), rotating_privkey.size()); + return true; +} + +}; // namespace session::config diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index a569e36a..3e7ffc24 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -147,6 +147,29 @@ std::chrono::sys_seconds UserProfile::get_profile_updated() const { return std::chrono::sys_seconds{}; } +std::optional UserProfile::get_pro_data() const { + std::optional result = {}; + if (const config::dict* s = data["s"].dict(); s) { + Pro pro = {}; + if (pro.load(*s)) + result = std::move(pro); + } + return result; +} + +void UserProfile::set_pro_data(Pro const &pro) { + auto root = data["s"]; + root["r"] = pro.rotating_privkey; + + const Proof& pro_proof = pro.proof; + auto proof_dict = root["p"]; + proof_dict["v"] = pro_proof.version; + proof_dict["g"] = pro_proof.gen_index_hash; + proof_dict["r"] = pro_proof.rotating_pubkey; + proof_dict["e"] = pro_proof.expiry_unix_ts.time_since_epoch().count(); + proof_dict["s"] = pro_proof.sig; +} + extern "C" { using namespace session; diff --git a/src/pro.cpp b/src/pro.cpp index 4d078810..d07d4eb9 100644 --- a/src/pro.cpp +++ b/src/pro.cpp @@ -1,10 +1,11 @@ +#include +#include #include #include #include -#include -#include #include +#include namespace session::pro { @@ -14,16 +15,6 @@ constexpr std::array BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static_assert(BACKEND_PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); -struct proof { - uint8_t version; - std::array gen_index_hash; - std::array rotating_pubkey; - std::chrono::seconds expiry_unix_ts; - std::array sig; -}; -static_assert(sizeof(((proof *)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); -static_assert(sizeof(((proof *)0)->sig) == crypto_sign_ed25519_BYTES); - struct add_payment_request { uint8_t version; std::array master_pkey; @@ -54,31 +45,9 @@ struct revocation_item { std::chrono::seconds expiry_unix_ts; }; -bool verify_proof(const proof& item); master_rotating_sigs build_get_proof_sigs(std::array master_privkey, std::array rotating_privkey, std::chrono::seconds unix_ts); master_rotating_sigs build_add_payment_sigs(std::array master_privkey, std::array rotating_privkey, std::array payment_token_hash, std::chrono::seconds unix_ts); - -bool verify_proof(const proof& item) { - uint64_t expiry_unix_ts_u64 = item.expiry_unix_ts.count(); - std::array hash = {}; - crypto_generichash_blake2b_state state; - crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash.max_size()); - crypto_generichash_blake2b_update(&state, &item.version, sizeof(item.version)); - crypto_generichash_blake2b_update( - &state, item.gen_index_hash.data(), item.gen_index_hash.size()); - crypto_generichash_blake2b_update( - &state, item.rotating_pubkey.data(), item.rotating_pubkey.size()); - crypto_generichash_blake2b_update( - &state, reinterpret_cast(&expiry_unix_ts_u64), sizeof(expiry_unix_ts_u64)); - crypto_generichash_blake2b_final(&state, hash.data(), hash.size()); - - int verify_result = crypto_sign_ed25519_verify_detached( - item.sig.data(), hash.data(), hash.size(), BACKEND_PUBKEY.data()); - bool result = verify_result == 0; - return result; -} - master_rotating_sigs build_get_proof_sigs( std::array master_privkey, std::array rotating_privkey, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 77afe5c2..5be475bb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,6 +16,7 @@ set(LIB_SESSION_UTESTS_SOURCES test_config_contacts.cpp test_config_convo_info_volatile.cpp test_config_local.cpp + test_config_pro.cpp test_curve25519.cpp test_ed25519.cpp test_encrypt.cpp diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp new file mode 100644 index 00000000..da46fcc9 --- /dev/null +++ b/tests/test_config_pro.cpp @@ -0,0 +1,103 @@ +#include +#include + +#include +#include + +using namespace oxenc::literals; + +TEST_CASE("Pro", "[config][pro]") { + // Setup keys + std::array rotating_pk, signing_pk; + std::array rotating_sk, signing_sk; + { + crypto_sign_ed25519_keypair(rotating_pk.data(), rotating_sk.data()); + crypto_sign_ed25519_keypair(signing_pk.data(), signing_sk.data()); + } + + // Setup the Pro data structure + session::config::Pro pro = {}; + { + pro.rotating_privkey = rotating_sk; + pro.proof.version = 0; + pro.proof.rotating_pubkey = rotating_pk; + pro.proof.expiry_unix_ts = std::chrono::sys_seconds(1s); + + constexpr auto gen_index_hash = + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hex_u; + static_assert(pro.proof.gen_index_hash.max_size() == gen_index_hash.size()); + std::memcpy(pro.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); + } + + // Do the signing + { + static_assert(crypto_sign_ed25519_BYTES == pro.proof.sig.max_size()); + std::array hash_to_sign = pro.proof.hash(); + int sig_result = crypto_sign_ed25519_detached( + pro.proof.sig.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + signing_sk.data()); + CHECK(sig_result == 0); + } + + // Verify the proof + { + CHECK_FALSE(pro.verify(rotating_pk)); + CHECK(pro.verify(signing_pk)); + } + + // Try loading the proof from dict + session::config::dict good_dict; + { + // clang-format off + const session::config::Proof& proof = pro.proof; + good_dict = { + {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, + {"p", session::config::dict{ + /*version*/ {"v", 0}, + /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, + /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, + /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, + /*signature*/ {"s", std::string{reinterpret_cast(proof.sig.data()), proof.sig.size()}}, + }} + }; + // clang-format on + + session::config::Pro loaded_pro = {}; + CHECK(loaded_pro.load(good_dict)); + CHECK(loaded_pro.rotating_privkey == pro.rotating_privkey); + CHECK(loaded_pro.proof.version == pro.proof.version); + CHECK(loaded_pro.proof.gen_index_hash == pro.proof.gen_index_hash); + CHECK(loaded_pro.proof.rotating_pubkey == pro.proof.rotating_pubkey); + CHECK(loaded_pro.proof.expiry_unix_ts == pro.proof.expiry_unix_ts); + CHECK(loaded_pro.proof.sig == pro.proof.sig); + CHECK(loaded_pro.verify(signing_pk)); + } + + // Try loading a proof with a bad signature in it from dict + { + session::config::dict bad_dict = good_dict; + std::array broken_sig = pro.proof.sig; + broken_sig[0] = ~broken_sig[0]; // Break the sig + + // clang-format off + const session::config::Proof& proof = pro.proof; + bad_dict = { + {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, + {"p", session::config::dict{ + /*version*/ {"v", 0}, + /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, + /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, + /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, + /*signature*/ {"s", std::string{reinterpret_cast(broken_sig.data()), broken_sig.size()}}, + }} + }; + // clang-format on + + session::config::Pro loaded_pro = {}; + CHECK(loaded_pro.load(bad_dict)); + CHECK_FALSE(loaded_pro.verify(signing_pk)); + } +} From 8ac19ba1b961fc83992349eba1b76afded569f31 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 5 Aug 2025 11:37:20 +1000 Subject: [PATCH 009/171] Add c wrappers for Session Pro and proofs --- include/session/config/pro.h | 31 +++++++ src/config/pro.cpp | 162 +++++++++++++++++++++++++++-------- 2 files changed, 157 insertions(+), 36 deletions(-) create mode 100644 include/session/config/pro.h diff --git a/include/session/config/pro.h b/include/session/config/pro.h new file mode 100644 index 00000000..06d2f3c7 --- /dev/null +++ b/include/session/config/pro.h @@ -0,0 +1,31 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include "../export.h" + +struct pro_proof { + uint8_t version; + uint8_t gen_index_hash[32]; + uint8_t rotating_pubkey[32]; + uint64_t expiry_unix_ts; + uint8_t sig[64]; +}; + +struct pro_pro { + uint8_t rotating_privkey[64]; + pro_proof proof; +}; + +LIBSESSION_EXPORT bool proof_verify(pro_proof const *proof, uint8_t const *verify_pubkey); + +LIBSESSION_EXPORT bool pro_verify(pro_pro const *pro, uint8_t const *verify_pubkey); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 72ac707d..a2e3d937 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -6,40 +7,87 @@ #include "internal.hpp" +namespace { +std::array proof_hash_internal( + uint8_t version, + std::span gen_index_hash, + std::span rotating_pubkey, + uint64_t expiry_unix_ts) { + std::array result = {}; + crypto_generichash_blake2b_state state; + crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); + crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&expiry_unix_ts), sizeof(expiry_unix_ts)); + crypto_generichash_blake2b_final(&state, result.data(), result.size()); + return result; +} + +bool proof_verify_internal( + std::span hash, + std::span sig, + std::span verify_pubkey) { + // The C/C++ interface verifies that the payloads are the correct size using the type system so + // only need asserts here. + assert(hash.size() == 32); + assert(sig.size() == crypto_sign_ed25519_BYTES); + assert(verify_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + int verify_result = crypto_sign_ed25519_verify_detached( + sig.data(), hash.data(), hash.size(), verify_pubkey.data()); + bool result = verify_result == 0; + return result; +} + +bool pro_verify_internal( + std::span rotating_privkey, + std::span verify_pubkey, + uint8_t version, + std::span gen_index_hash, + std::span rotating_pubkey, + uint64_t expiry_unix_ts, + std::span sig) { + + std::array hash = + proof_hash_internal(version, gen_index_hash, rotating_pubkey, expiry_unix_ts); + if (!proof_verify_internal(hash, sig, verify_pubkey)) + return false; + + std::array rederived_pk; + [[maybe_unused]] session::cleared_uc32 rederived_sk; + crypto_sign_ed25519_seed_keypair( + rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); + + bool result = false; + if (rederived_pk.size() == rotating_pubkey.size()) + result = std::memcmp(rederived_pk.data(), rotating_pubkey.data(), rederived_pk.size()) == 0; + + return result; +} + +} // namespace + namespace session::config { -static_assert(sizeof(((Proof *)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); -static_assert(sizeof(((Proof *)0)->sig) == crypto_sign_ed25519_BYTES); +static_assert(sizeof(((Pro*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); +static_assert(sizeof(((Proof*)0)->gen_index_hash) == 32); +static_assert(sizeof(((Proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert(sizeof(((Proof*)0)->sig) == crypto_sign_ed25519_BYTES); -bool Proof::verify(const std::array& verify_pubkey) const -{ +bool Proof::verify(const std::array& verify_pubkey) const { std::array hash_to_sign = hash(); - int verify_result = crypto_sign_ed25519_verify_detached( - sig.data(), hash_to_sign.data(), hash_to_sign.size(), verify_pubkey.data()); - bool result = verify_result == 0; + bool result = proof_verify_internal(hash_to_sign, sig, verify_pubkey); return result; } -std::array Proof::hash() const -{ - // TODO: Check why does sys_time have a time since epoch? Is it counting some other duration? - uint64_t expiry_unix_ts_u64 = expiry_unix_ts.time_since_epoch().count(); - std::array result = {}; - crypto_generichash_blake2b_state state; - crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); - crypto_generichash_blake2b_update(&state, &version, sizeof(version)); - crypto_generichash_blake2b_update( - &state, gen_index_hash.data(), gen_index_hash.size()); - crypto_generichash_blake2b_update( - &state, rotating_pubkey.data(), rotating_pubkey.size()); - crypto_generichash_blake2b_update( - &state, reinterpret_cast(&expiry_unix_ts_u64), sizeof(expiry_unix_ts_u64)); - crypto_generichash_blake2b_final(&state, result.data(), result.size()); +std::array Proof::hash() const { + std::array result = proof_hash_internal( + version, gen_index_hash, rotating_pubkey, expiry_unix_ts.time_since_epoch().count()); return result; } -bool Proof::load(const dict& root) -{ +bool Proof::load(const dict& root) { std::optional version = maybe_int(root, "v"); std::optional> maybe_gen_index_hash = maybe_vector(root, "g"); std::optional> maybe_rotating_pubkey = maybe_vector(root, "r"); @@ -64,21 +112,20 @@ bool Proof::load(const dict& root) return true; } -bool Pro::verify(const std::array& verify_pubkey) const -{ - if (!proof.verify(verify_pubkey)) - return false; - - std::array rederived_pk; - [[maybe_unused]] session::cleared_uc32 rederived_sk; - crypto_sign_ed25519_seed_keypair( - rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); - bool result = rederived_pk == proof.rotating_pubkey; +bool Pro::verify(const std::array& verify_pubkey) const { + uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); + bool result = pro_verify_internal( + rotating_privkey, + verify_pubkey, + proof.version, + proof.gen_index_hash, + proof.rotating_pubkey, + expiry_unix_ts, + proof.sig); return result; } -bool Pro::load(const dict& root) -{ +bool Pro::load(const dict& root) { // Get proof fields sitting in 'p' dictionary auto p_it = root.find("p"); if (p_it == root.end()) @@ -101,3 +148,46 @@ bool Pro::load(const dict& root) } }; // namespace session::config + +// Ensure these are byte buffers and we can just use sizeof to build std::spans to interop with C++ +static_assert((sizeof((pro_pro*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); +static_assert((sizeof((pro_proof*)0)->gen_index_hash) == 32); +static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); + +LIBSESSION_C_API bool proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey) { + auto verify_pubkey_span = + std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); + auto gen_index_hash = + std::span(proof->gen_index_hash, sizeof proof->gen_index_hash); + auto rotating_pubkey = + std::span(proof->rotating_pubkey, sizeof proof->rotating_pubkey); + auto sig = std::span(proof->sig, sizeof proof->sig); + + std::array hash = proof_hash_internal( + proof->version, gen_index_hash, rotating_pubkey, proof->expiry_unix_ts); + bool result = proof_verify_internal(hash, sig, verify_pubkey_span); + return result; +} + +LIBSESSION_C_API bool pro_verify(pro_pro const* pro, uint8_t const* verify_pubkey) { + auto verify_pubkey_span = + std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); + auto rotating_privkey = + std::span(pro->rotating_privkey, sizeof pro->rotating_privkey); + auto gen_index_hash = + std::span(pro->proof.gen_index_hash, sizeof pro->proof.gen_index_hash); + auto rotating_pubkey = + std::span(pro->proof.rotating_pubkey, sizeof pro->proof.rotating_pubkey); + auto sig = std::span(pro->proof.sig, sizeof pro->proof.sig); + + bool result = pro_verify_internal( + rotating_privkey, + verify_pubkey_span, + pro->proof.version, + gen_index_hash, + rotating_pubkey, + pro->proof.expiry_unix_ts, + sig); + return result; +} From aab2209af4cbf746b3e5177defb2a11f6727afc1 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 5 Aug 2025 11:48:20 +1000 Subject: [PATCH 010/171] Update protobufs for Pro and pro proofs --- proto/SessionProtos.pb.cc | 1184 +++++++++++++++++++++++++++++++------ proto/SessionProtos.pb.h | 926 ++++++++++++++++++++++++++++- proto/SessionProtos.proto | 8 +- 3 files changed, 1924 insertions(+), 194 deletions(-) diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index cd353a0f..f58247a3 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -352,6 +352,39 @@ struct ConfigurationMessage_ContactDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ContactDefaultTypeInternal _ConfigurationMessage_Contact_default_instance_; +PROTOBUF_CONSTEXPR ConfigurationMessage_ProProof::ConfigurationMessage_ProProof( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.genindexhash_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.rotatingpublickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.sig_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.expiryunixts_)*/uint64_t{0u} + , /*decltype(_impl_.version_)*/0u} {} +struct ConfigurationMessage_ProProofDefaultTypeInternal { + PROTOBUF_CONSTEXPR ConfigurationMessage_ProProofDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ConfigurationMessage_ProProofDefaultTypeInternal() {} + union { + ConfigurationMessage_ProProof _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ProProofDefaultTypeInternal _ConfigurationMessage_ProProof_default_instance_; +PROTOBUF_CONSTEXPR ConfigurationMessage_Pro::ConfigurationMessage_Pro( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.rotatingprivkey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.proof_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} +struct ConfigurationMessage_ProDefaultTypeInternal { + PROTOBUF_CONSTEXPR ConfigurationMessage_ProDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ConfigurationMessage_ProDefaultTypeInternal() {} + union { + ConfigurationMessage_Pro _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ProDefaultTypeInternal _ConfigurationMessage_Pro_default_instance_; PROTOBUF_CONSTEXPR ConfigurationMessage::ConfigurationMessage( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -361,7 +394,8 @@ PROTOBUF_CONSTEXPR ConfigurationMessage::ConfigurationMessage( , /*decltype(_impl_.contacts_)*/{} , /*decltype(_impl_.displayname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.profilepicture_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.profilekey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} + , /*decltype(_impl_.profilekey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.pro_)*/nullptr} {} struct ConfigurationMessageDefaultTypeInternal { PROTOBUF_CONSTEXPR ConfigurationMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -8345,97 +8379,107 @@ std::string ConfigurationMessage_Contact::GetTypeName() const { // =================================================================== -class ConfigurationMessage::_Internal { +class ConfigurationMessage_ProProof::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_displayname(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_version(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_genindexhash(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_profilepicture(HasBits* has_bits) { + static void set_has_rotatingpublickey(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_profilekey(HasBits* has_bits) { + static void set_has_expiryunixts(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_sig(HasBits* has_bits) { (*has_bits)[0] |= 4u; } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000001f) ^ 0x0000001f) != 0; + } }; -ConfigurationMessage::ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +ConfigurationMessage_ProProof::ConfigurationMessage_ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.ProProof) } -ConfigurationMessage::ConfigurationMessage(const ConfigurationMessage& from) +ConfigurationMessage_ProProof::ConfigurationMessage_ProProof(const ConfigurationMessage_ProProof& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage* const _this = this; (void)_this; + ConfigurationMessage_ProProof* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.closedgroups_){from._impl_.closedgroups_} - , decltype(_impl_.opengroups_){from._impl_.opengroups_} - , decltype(_impl_.contacts_){from._impl_.contacts_} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){} - , decltype(_impl_.profilekey_){}}; + , decltype(_impl_.genindexhash_){} + , decltype(_impl_.rotatingpublickey_){} + , decltype(_impl_.sig_){} + , decltype(_impl_.expiryunixts_){} + , decltype(_impl_.version_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.displayname_.InitDefault(); + _impl_.genindexhash_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); + _impl_.genindexhash_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_displayname()) { - _this->_impl_.displayname_.Set(from._internal_displayname(), + if (from._internal_has_genindexhash()) { + _this->_impl_.genindexhash_.Set(from._internal_genindexhash(), _this->GetArenaForAllocation()); } - _impl_.profilepicture_.InitDefault(); + _impl_.rotatingpublickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilepicture()) { - _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + if (from._internal_has_rotatingpublickey()) { + _this->_impl_.rotatingpublickey_.Set(from._internal_rotatingpublickey(), _this->GetArenaForAllocation()); } - _impl_.profilekey_.InitDefault(); + _impl_.sig_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.sig_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilekey()) { - _this->_impl_.profilekey_.Set(from._internal_profilekey(), + if (from._internal_has_sig()) { + _this->_impl_.sig_.Set(from._internal_sig(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage) + ::memcpy(&_impl_.expiryunixts_, &from._impl_.expiryunixts_, + static_cast(reinterpret_cast(&_impl_.version_) - + reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.ProProof) } -inline void ConfigurationMessage::SharedCtor( +inline void ConfigurationMessage_ProProof::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.closedgroups_){arena} - , decltype(_impl_.opengroups_){arena} - , decltype(_impl_.contacts_){arena} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){} - , decltype(_impl_.profilekey_){} + , decltype(_impl_.genindexhash_){} + , decltype(_impl_.rotatingpublickey_){} + , decltype(_impl_.sig_){} + , decltype(_impl_.expiryunixts_){uint64_t{0u}} + , decltype(_impl_.version_){0u} }; - _impl_.displayname_.InitDefault(); + _impl_.genindexhash_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); + _impl_.genindexhash_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.InitDefault(); + _impl_.rotatingpublickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.InitDefault(); + _impl_.sig_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.sig_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage::~ConfigurationMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage) +ConfigurationMessage_ProProof::~ConfigurationMessage_ProProof() { + // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.ProProof) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -8443,119 +8487,96 @@ ConfigurationMessage::~ConfigurationMessage() { SharedDtor(); } -inline void ConfigurationMessage::SharedDtor() { +inline void ConfigurationMessage_ProProof::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.closedgroups_.~RepeatedPtrField(); - _impl_.opengroups_.~RepeatedPtrField(); - _impl_.contacts_.~RepeatedPtrField(); - _impl_.displayname_.Destroy(); - _impl_.profilepicture_.Destroy(); - _impl_.profilekey_.Destroy(); + _impl_.genindexhash_.Destroy(); + _impl_.rotatingpublickey_.Destroy(); + _impl_.sig_.Destroy(); } -void ConfigurationMessage::SetCachedSize(int size) const { +void ConfigurationMessage_ProProof::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage) +void ConfigurationMessage_ProProof::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.ProProof) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.closedgroups_.Clear(); - _impl_.opengroups_.Clear(); - _impl_.contacts_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _impl_.displayname_.ClearNonDefaultToEmpty(); + _impl_.genindexhash_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.profilepicture_.ClearNonDefaultToEmpty(); + _impl_.rotatingpublickey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - _impl_.profilekey_.ClearNonDefaultToEmpty(); + _impl_.sig_.ClearNonDefaultToEmpty(); } } + if (cached_has_bits & 0x00000018u) { + ::memset(&_impl_.expiryunixts_, 0, static_cast( + reinterpret_cast(&_impl_.version_) - + reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); + } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ConfigurationMessage_ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; + // required uint32 version = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_closedgroups(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _Internal::set_has_version(&has_bits); + _impl_.version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); } else goto handle_unusual; continue; - // repeated string openGroups = 2; + // required bytes genIndexHash = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_opengroups(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + auto str = _internal_mutable_genindexhash(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); } else goto handle_unusual; continue; - // optional string displayName = 3; + // required bytes rotatingPublicKey = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_displayname(); + auto str = _internal_mutable_rotatingpublickey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional string profilePicture = 4; + // required uint64 expiryUnixTs = 4; case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - auto str = _internal_mutable_profilepicture(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_expiryunixts(&has_bits); + _impl_.expiryunixts_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional bytes profileKey = 5; + // required bytes sig = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_profilekey(); + auto str = _internal_mutable_sig(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_contacts(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -8580,115 +8601,121 @@ const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseC #undef CHK_ } -uint8_t* ConfigurationMessage::_InternalSerialize( +uint8_t* ConfigurationMessage_ProProof::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.ProProof) uint32_t cached_has_bits = 0; (void) cached_has_bits; - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; - for (unsigned i = 0, - n = static_cast(this->_internal_closedgroups_size()); i < n; i++) { - const auto& repfield = this->_internal_closedgroups(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); - } - - // repeated string openGroups = 2; - for (int i = 0, n = this->_internal_opengroups_size(); i < n; i++) { - const auto& s = this->_internal_opengroups(i); - target = stream->WriteString(2, s, target); + cached_has_bits = _impl_._has_bits_[0]; + // required uint32 version = 1; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_version(), target); } - cached_has_bits = _impl_._has_bits_[0]; - // optional string displayName = 3; + // required bytes genIndexHash = 2; if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_displayname(), target); + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_genindexhash(), target); } - // optional string profilePicture = 4; + // required bytes rotatingPublicKey = 3; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 4, this->_internal_profilepicture(), target); + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_rotatingpublickey(), target); } - // optional bytes profileKey = 5; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteBytesMaybeAliased( - 5, this->_internal_profilekey(), target); + // required uint64 expiryUnixTs = 4; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_expiryunixts(), target); } - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - for (unsigned i = 0, - n = static_cast(this->_internal_contacts_size()); i < n; i++) { - const auto& repfield = this->_internal_contacts(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); + // required bytes sig = 5; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 5, this->_internal_sig(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.ProProof) return target; } -size_t ConfigurationMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage) +size_t ConfigurationMessage_ProProof::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.ProProof) size_t total_size = 0; - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + if (_internal_has_genindexhash()) { + // required bytes genIndexHash = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); + } - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; - total_size += 1UL * this->_internal_closedgroups_size(); - for (const auto& msg : this->_impl_.closedgroups_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + if (_internal_has_rotatingpublickey()) { + // required bytes rotatingPublicKey = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); } - // repeated string openGroups = 2; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.opengroups_.size()); - for (int i = 0, n = _impl_.opengroups_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.opengroups_.Get(i)); + if (_internal_has_sig()) { + // required bytes sig = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); } - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - total_size += 1UL * this->_internal_contacts_size(); - for (const auto& msg : this->_impl_.contacts_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + if (_internal_has_expiryunixts()) { + // required uint64 expiryUnixTs = 4; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); } - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { - // optional string displayName = 3; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_displayname()); - } + if (_internal_has_version()) { + // required uint32 version = 1; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + } - // optional string profilePicture = 4; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_profilepicture()); - } + return total_size; +} +size_t ConfigurationMessage_ProProof::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.ProProof) + size_t total_size = 0; - // optional bytes profileKey = 5; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_profilekey()); - } + if (((_impl_._has_bits_[0] & 0x0000001f) ^ 0x0000001f) == 0) { // All required fields are present. + // required bytes genIndexHash = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); + + // required bytes rotatingPublicKey = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); + // required bytes sig = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); + + // required uint64 expiryUnixTs = 4; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + + // required uint32 version = 1; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -8697,49 +8724,821 @@ size_t ConfigurationMessage::ByteSizeLong() const { return total_size; } -void ConfigurationMessage::CheckTypeAndMergeFrom( +void ConfigurationMessage_ProProof::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void ConfigurationMessage::MergeFrom(const ConfigurationMessage& from) { - ConfigurationMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage) +void ConfigurationMessage_ProProof::MergeFrom(const ConfigurationMessage_ProProof& from) { + ConfigurationMessage_ProProof* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.ProProof) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.closedgroups_.MergeFrom(from._impl_.closedgroups_); - _this->_impl_.opengroups_.MergeFrom(from._impl_.opengroups_); - _this->_impl_.contacts_.MergeFrom(from._impl_.contacts_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_displayname(from._internal_displayname()); + _this->_internal_set_genindexhash(from._internal_genindexhash()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_profilepicture(from._internal_profilepicture()); + _this->_internal_set_rotatingpublickey(from._internal_rotatingpublickey()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_set_profilekey(from._internal_profilekey()); + _this->_internal_set_sig(from._internal_sig()); } + if (cached_has_bits & 0x00000008u) { + _this->_impl_.expiryunixts_ = from._impl_.expiryunixts_; + } + if (cached_has_bits & 0x00000010u) { + _this->_impl_.version_ = from._impl_.version_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void ConfigurationMessage::CopyFrom(const ConfigurationMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage) +void ConfigurationMessage_ProProof::CopyFrom(const ConfigurationMessage_ProProof& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.ProProof) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage::IsInitialized() const { +bool ConfigurationMessage_ProProof::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + return true; +} + +void ConfigurationMessage_ProProof::InternalSwap(ConfigurationMessage_ProProof* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.genindexhash_, lhs_arena, + &other->_impl_.genindexhash_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.rotatingpublickey_, lhs_arena, + &other->_impl_.rotatingpublickey_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.sig_, lhs_arena, + &other->_impl_.sig_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ProProof, _impl_.version_) + + sizeof(ConfigurationMessage_ProProof::_impl_.version_) + - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ProProof, _impl_.expiryunixts_)>( + reinterpret_cast(&_impl_.expiryunixts_), + reinterpret_cast(&other->_impl_.expiryunixts_)); +} + +std::string ConfigurationMessage_ProProof::GetTypeName() const { + return "SessionProtos.ConfigurationMessage.ProProof"; +} + + +// =================================================================== + +class ConfigurationMessage_Pro::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_rotatingprivkey(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_proof(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +ConfigurationMessage_Pro::ConfigurationMessage_Pro(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.Pro) +} +ConfigurationMessage_Pro::ConfigurationMessage_Pro(const ConfigurationMessage_Pro& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + ConfigurationMessage_Pro* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.rotatingprivkey_){} + , decltype(_impl_.proof_){}}; + + _internal_metadata_.MergeFrom(from._internal_metadata_); + _impl_.rotatingprivkey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_rotatingprivkey()) { + _this->_impl_.rotatingprivkey_.Set(from._internal_rotatingprivkey(), + _this->GetArenaForAllocation()); + } + _impl_.proof_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.proof_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_proof()) { + _this->_impl_.proof_.Set(from._internal_proof(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.Pro) +} + +inline void ConfigurationMessage_Pro::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.rotatingprivkey_){} + , decltype(_impl_.proof_){} + }; + _impl_.rotatingprivkey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.proof_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.proof_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +ConfigurationMessage_Pro::~ConfigurationMessage_Pro() { + // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.Pro) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void ConfigurationMessage_Pro::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.rotatingprivkey_.Destroy(); + _impl_.proof_.Destroy(); +} + +void ConfigurationMessage_Pro::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void ConfigurationMessage_Pro::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.Pro) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _impl_.rotatingprivkey_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.proof_.ClearNonDefaultToEmpty(); + } + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +const char* ConfigurationMessage_Pro::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required bytes rotatingPrivKey = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_rotatingprivkey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bytes proof = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_proof(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* ConfigurationMessage_Pro::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.Pro) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // required bytes rotatingPrivKey = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteBytesMaybeAliased( + 1, this->_internal_rotatingprivkey(), target); + } + + // required bytes proof = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_proof(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.Pro) + return target; +} + +size_t ConfigurationMessage_Pro::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.Pro) + size_t total_size = 0; + + if (_internal_has_rotatingprivkey()) { + // required bytes rotatingPrivKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingprivkey()); + } + + if (_internal_has_proof()) { + // required bytes proof = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_proof()); + } + + return total_size; +} +size_t ConfigurationMessage_Pro::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.Pro) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required bytes rotatingPrivKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingprivkey()); + + // required bytes proof = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_proof()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ConfigurationMessage_Pro::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} + +void ConfigurationMessage_Pro::MergeFrom(const ConfigurationMessage_Pro& from) { + ConfigurationMessage_Pro* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.Pro) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_rotatingprivkey(from._internal_rotatingprivkey()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_proof(from._internal_proof()); + } + } + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} + +void ConfigurationMessage_Pro::CopyFrom(const ConfigurationMessage_Pro& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.Pro) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ConfigurationMessage_Pro::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + return true; +} + +void ConfigurationMessage_Pro::InternalSwap(ConfigurationMessage_Pro* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.rotatingprivkey_, lhs_arena, + &other->_impl_.rotatingprivkey_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.proof_, lhs_arena, + &other->_impl_.proof_, rhs_arena + ); +} + +std::string ConfigurationMessage_Pro::GetTypeName() const { + return "SessionProtos.ConfigurationMessage.Pro"; +} + + +// =================================================================== + +class ConfigurationMessage::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_displayname(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_profilepicture(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_profilekey(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static const ::SessionProtos::ConfigurationMessage_Pro& pro(const ConfigurationMessage* msg); + static void set_has_pro(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } +}; + +const ::SessionProtos::ConfigurationMessage_Pro& +ConfigurationMessage::_Internal::pro(const ConfigurationMessage* msg) { + return *msg->_impl_.pro_; +} +ConfigurationMessage::ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage) +} +ConfigurationMessage::ConfigurationMessage(const ConfigurationMessage& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + ConfigurationMessage* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.closedgroups_){from._impl_.closedgroups_} + , decltype(_impl_.opengroups_){from._impl_.opengroups_} + , decltype(_impl_.contacts_){from._impl_.contacts_} + , decltype(_impl_.displayname_){} + , decltype(_impl_.profilepicture_){} + , decltype(_impl_.profilekey_){} + , decltype(_impl_.pro_){nullptr}}; + + _internal_metadata_.MergeFrom(from._internal_metadata_); + _impl_.displayname_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.displayname_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_displayname()) { + _this->_impl_.displayname_.Set(from._internal_displayname(), + _this->GetArenaForAllocation()); + } + _impl_.profilepicture_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_profilepicture()) { + _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + _this->GetArenaForAllocation()); + } + _impl_.profilekey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilekey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_profilekey()) { + _this->_impl_.profilekey_.Set(from._internal_profilekey(), + _this->GetArenaForAllocation()); + } + if (from._internal_has_pro()) { + _this->_impl_.pro_ = new ::SessionProtos::ConfigurationMessage_Pro(*from._impl_.pro_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage) +} + +inline void ConfigurationMessage::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.closedgroups_){arena} + , decltype(_impl_.opengroups_){arena} + , decltype(_impl_.contacts_){arena} + , decltype(_impl_.displayname_){} + , decltype(_impl_.profilepicture_){} + , decltype(_impl_.profilekey_){} + , decltype(_impl_.pro_){nullptr} + }; + _impl_.displayname_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.displayname_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilekey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilekey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +ConfigurationMessage::~ConfigurationMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void ConfigurationMessage::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.closedgroups_.~RepeatedPtrField(); + _impl_.opengroups_.~RepeatedPtrField(); + _impl_.contacts_.~RepeatedPtrField(); + _impl_.displayname_.Destroy(); + _impl_.profilepicture_.Destroy(); + _impl_.profilekey_.Destroy(); + if (this != internal_default_instance()) delete _impl_.pro_; +} + +void ConfigurationMessage::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void ConfigurationMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.closedgroups_.Clear(); + _impl_.opengroups_.Clear(); + _impl_.contacts_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _impl_.displayname_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.profilepicture_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + _impl_.profilekey_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000008u) { + GOOGLE_DCHECK(_impl_.pro_ != nullptr); + _impl_.pro_->Clear(); + } + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_closedgroups(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else + goto handle_unusual; + continue; + // repeated string openGroups = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_opengroups(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else + goto handle_unusual; + continue; + // optional string displayName = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_displayname(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string profilePicture = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_profilepicture(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes profileKey = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_profilekey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_contacts(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { + ptr = ctx->ParseMessage(_internal_mutable_pro(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* ConfigurationMessage::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; + for (unsigned i = 0, + n = static_cast(this->_internal_closedgroups_size()); i < n; i++) { + const auto& repfield = this->_internal_closedgroups(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); + } + + // repeated string openGroups = 2; + for (int i = 0, n = this->_internal_opengroups_size(); i < n; i++) { + const auto& s = this->_internal_opengroups(i); + target = stream->WriteString(2, s, target); + } + + cached_has_bits = _impl_._has_bits_[0]; + // optional string displayName = 3; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteStringMaybeAliased( + 3, this->_internal_displayname(), target); + } + + // optional string profilePicture = 4; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteStringMaybeAliased( + 4, this->_internal_profilepicture(), target); + } + + // optional bytes profileKey = 5; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 5, this->_internal_profilekey(), target); + } + + // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; + for (unsigned i = 0, + n = static_cast(this->_internal_contacts_size()); i < n; i++) { + const auto& repfield = this->_internal_contacts(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); + } + + // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + if (cached_has_bits & 0x00000008u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(7, _Internal::pro(this), + _Internal::pro(this).GetCachedSize(), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage) + return target; +} + +size_t ConfigurationMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; + total_size += 1UL * this->_internal_closedgroups_size(); + for (const auto& msg : this->_impl_.closedgroups_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated string openGroups = 2; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.opengroups_.size()); + for (int i = 0, n = _impl_.opengroups_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.opengroups_.Get(i)); + } + + // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; + total_size += 1UL * this->_internal_contacts_size(); + for (const auto& msg : this->_impl_.contacts_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + // optional string displayName = 3; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_displayname()); + } + + // optional string profilePicture = 4; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_profilepicture()); + } + + // optional bytes profileKey = 5; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_profilekey()); + } + + // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.pro_); + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ConfigurationMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} + +void ConfigurationMessage::MergeFrom(const ConfigurationMessage& from) { + ConfigurationMessage* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.closedgroups_.MergeFrom(from._impl_.closedgroups_); + _this->_impl_.opengroups_.MergeFrom(from._impl_.opengroups_); + _this->_impl_.contacts_.MergeFrom(from._impl_.contacts_); + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_displayname(from._internal_displayname()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_profilepicture(from._internal_profilepicture()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_profilekey(from._internal_profilekey()); + } + if (cached_has_bits & 0x00000008u) { + _this->_internal_mutable_pro()->::SessionProtos::ConfigurationMessage_Pro::MergeFrom( + from._internal_pro()); + } + } + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} + +void ConfigurationMessage::CopyFrom(const ConfigurationMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ConfigurationMessage::IsInitialized() const { if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.closedgroups_)) return false; if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.contacts_)) return false; + if (_internal_has_pro()) { + if (!_impl_.pro_->IsInitialized()) return false; + } return true; } @@ -8764,6 +9563,7 @@ void ConfigurationMessage::InternalSwap(ConfigurationMessage* other) { &_impl_.profilekey_, lhs_arena, &other->_impl_.profilekey_, rhs_arena ); + swap(_impl_.pro_, other->_impl_.pro_); } std::string ConfigurationMessage::GetTypeName() const { @@ -10089,6 +10889,14 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_Contact* Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_Contact >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_Contact >(arena); } +template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_ProProof* +Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_ProProof >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_ProProof >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_Pro* +Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_Pro >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_Pro >(arena); +} template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage* Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage >(arena); diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index e75a5652..e05be469 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -58,6 +58,12 @@ extern ConfigurationMessage_ClosedGroupDefaultTypeInternal _ConfigurationMessage class ConfigurationMessage_Contact; struct ConfigurationMessage_ContactDefaultTypeInternal; extern ConfigurationMessage_ContactDefaultTypeInternal _ConfigurationMessage_Contact_default_instance_; +class ConfigurationMessage_Pro; +struct ConfigurationMessage_ProDefaultTypeInternal; +extern ConfigurationMessage_ProDefaultTypeInternal _ConfigurationMessage_Pro_default_instance_; +class ConfigurationMessage_ProProof; +struct ConfigurationMessage_ProProofDefaultTypeInternal; +extern ConfigurationMessage_ProProofDefaultTypeInternal _ConfigurationMessage_ProProof_default_instance_; class Content; struct ContentDefaultTypeInternal; extern ContentDefaultTypeInternal _Content_default_instance_; @@ -119,6 +125,8 @@ template<> ::SessionProtos::CallMessage* Arena::CreateMaybeMessage<::SessionProt template<> ::SessionProtos::ConfigurationMessage* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage>(Arena*); template<> ::SessionProtos::ConfigurationMessage_ClosedGroup* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_ClosedGroup>(Arena*); template<> ::SessionProtos::ConfigurationMessage_Contact* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Contact>(Arena*); +template<> ::SessionProtos::ConfigurationMessage_Pro* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Pro>(Arena*); +template<> ::SessionProtos::ConfigurationMessage_ProProof* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_ProProof>(Arena*); template<> ::SessionProtos::Content* Arena::CreateMaybeMessage<::SessionProtos::Content>(Arena*); template<> ::SessionProtos::DataExtractionNotification* Arena::CreateMaybeMessage<::SessionProtos::DataExtractionNotification>(Arena*); template<> ::SessionProtos::DataMessage* Arena::CreateMaybeMessage<::SessionProtos::DataMessage>(Arena*); @@ -4689,6 +4697,396 @@ class ConfigurationMessage_Contact final : }; // ------------------------------------------------------------------- +class ConfigurationMessage_ProProof final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.ProProof) */ { + public: + inline ConfigurationMessage_ProProof() : ConfigurationMessage_ProProof(nullptr) {} + ~ConfigurationMessage_ProProof() override; + explicit PROTOBUF_CONSTEXPR ConfigurationMessage_ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + ConfigurationMessage_ProProof(const ConfigurationMessage_ProProof& from); + ConfigurationMessage_ProProof(ConfigurationMessage_ProProof&& from) noexcept + : ConfigurationMessage_ProProof() { + *this = ::std::move(from); + } + + inline ConfigurationMessage_ProProof& operator=(const ConfigurationMessage_ProProof& from) { + CopyFrom(from); + return *this; + } + inline ConfigurationMessage_ProProof& operator=(ConfigurationMessage_ProProof&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + } + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ConfigurationMessage_ProProof& default_instance() { + return *internal_default_instance(); + } + static inline const ConfigurationMessage_ProProof* internal_default_instance() { + return reinterpret_cast( + &_ConfigurationMessage_ProProof_default_instance_); + } + static constexpr int kIndexInFileMessages = + 19; + + friend void swap(ConfigurationMessage_ProProof& a, ConfigurationMessage_ProProof& b) { + a.Swap(&b); + } + inline void Swap(ConfigurationMessage_ProProof* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ConfigurationMessage_ProProof* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ConfigurationMessage_ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const ConfigurationMessage_ProProof& from); + void MergeFrom(const ConfigurationMessage_ProProof& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ConfigurationMessage_ProProof* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.ConfigurationMessage.ProProof"; + } + protected: + explicit ConfigurationMessage_ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kGenIndexHashFieldNumber = 2, + kRotatingPublicKeyFieldNumber = 3, + kSigFieldNumber = 5, + kExpiryUnixTsFieldNumber = 4, + kVersionFieldNumber = 1, + }; + // required bytes genIndexHash = 2; + bool has_genindexhash() const; + private: + bool _internal_has_genindexhash() const; + public: + void clear_genindexhash(); + const std::string& genindexhash() const; + template + void set_genindexhash(ArgT0&& arg0, ArgT... args); + std::string* mutable_genindexhash(); + PROTOBUF_NODISCARD std::string* release_genindexhash(); + void set_allocated_genindexhash(std::string* genindexhash); + private: + const std::string& _internal_genindexhash() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); + std::string* _internal_mutable_genindexhash(); + public: + + // required bytes rotatingPublicKey = 3; + bool has_rotatingpublickey() const; + private: + bool _internal_has_rotatingpublickey() const; + public: + void clear_rotatingpublickey(); + const std::string& rotatingpublickey() const; + template + void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingpublickey(); + PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); + void set_allocated_rotatingpublickey(std::string* rotatingpublickey); + private: + const std::string& _internal_rotatingpublickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); + std::string* _internal_mutable_rotatingpublickey(); + public: + + // required bytes sig = 5; + bool has_sig() const; + private: + bool _internal_has_sig() const; + public: + void clear_sig(); + const std::string& sig() const; + template + void set_sig(ArgT0&& arg0, ArgT... args); + std::string* mutable_sig(); + PROTOBUF_NODISCARD std::string* release_sig(); + void set_allocated_sig(std::string* sig); + private: + const std::string& _internal_sig() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); + std::string* _internal_mutable_sig(); + public: + + // required uint64 expiryUnixTs = 4; + bool has_expiryunixts() const; + private: + bool _internal_has_expiryunixts() const; + public: + void clear_expiryunixts(); + uint64_t expiryunixts() const; + void set_expiryunixts(uint64_t value); + private: + uint64_t _internal_expiryunixts() const; + void _internal_set_expiryunixts(uint64_t value); + public: + + // required uint32 version = 1; + bool has_version() const; + private: + bool _internal_has_version() const; + public: + void clear_version(); + uint32_t version() const; + void set_version(uint32_t value); + private: + uint32_t _internal_version() const; + void _internal_set_version(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.ProProof) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; + uint64_t expiryunixts_; + uint32_t version_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + +class ConfigurationMessage_Pro final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.Pro) */ { + public: + inline ConfigurationMessage_Pro() : ConfigurationMessage_Pro(nullptr) {} + ~ConfigurationMessage_Pro() override; + explicit PROTOBUF_CONSTEXPR ConfigurationMessage_Pro(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + ConfigurationMessage_Pro(const ConfigurationMessage_Pro& from); + ConfigurationMessage_Pro(ConfigurationMessage_Pro&& from) noexcept + : ConfigurationMessage_Pro() { + *this = ::std::move(from); + } + + inline ConfigurationMessage_Pro& operator=(const ConfigurationMessage_Pro& from) { + CopyFrom(from); + return *this; + } + inline ConfigurationMessage_Pro& operator=(ConfigurationMessage_Pro&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + } + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ConfigurationMessage_Pro& default_instance() { + return *internal_default_instance(); + } + static inline const ConfigurationMessage_Pro* internal_default_instance() { + return reinterpret_cast( + &_ConfigurationMessage_Pro_default_instance_); + } + static constexpr int kIndexInFileMessages = + 20; + + friend void swap(ConfigurationMessage_Pro& a, ConfigurationMessage_Pro& b) { + a.Swap(&b); + } + inline void Swap(ConfigurationMessage_Pro* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ConfigurationMessage_Pro* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ConfigurationMessage_Pro* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const ConfigurationMessage_Pro& from); + void MergeFrom(const ConfigurationMessage_Pro& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(ConfigurationMessage_Pro* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.ConfigurationMessage.Pro"; + } + protected: + explicit ConfigurationMessage_Pro(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRotatingPrivKeyFieldNumber = 1, + kProofFieldNumber = 2, + }; + // required bytes rotatingPrivKey = 1; + bool has_rotatingprivkey() const; + private: + bool _internal_has_rotatingprivkey() const; + public: + void clear_rotatingprivkey(); + const std::string& rotatingprivkey() const; + template + void set_rotatingprivkey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingprivkey(); + PROTOBUF_NODISCARD std::string* release_rotatingprivkey(); + void set_allocated_rotatingprivkey(std::string* rotatingprivkey); + private: + const std::string& _internal_rotatingprivkey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingprivkey(const std::string& value); + std::string* _internal_mutable_rotatingprivkey(); + public: + + // required bytes proof = 2; + bool has_proof() const; + private: + bool _internal_has_proof() const; + public: + void clear_proof(); + const std::string& proof() const; + template + void set_proof(ArgT0&& arg0, ArgT... args); + std::string* mutable_proof(); + PROTOBUF_NODISCARD std::string* release_proof(); + void set_allocated_proof(std::string* proof); + private: + const std::string& _internal_proof() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_proof(const std::string& value); + std::string* _internal_mutable_proof(); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.Pro) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingprivkey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr proof_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + class ConfigurationMessage final : public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage) */ { public: @@ -4735,7 +5133,7 @@ class ConfigurationMessage final : &_ConfigurationMessage_default_instance_); } static constexpr int kIndexInFileMessages = - 19; + 21; friend void swap(ConfigurationMessage& a, ConfigurationMessage& b) { a.Swap(&b); @@ -4798,6 +5196,8 @@ class ConfigurationMessage final : typedef ConfigurationMessage_ClosedGroup ClosedGroup; typedef ConfigurationMessage_Contact Contact; + typedef ConfigurationMessage_ProProof ProProof; + typedef ConfigurationMessage_Pro Pro; // accessors ------------------------------------------------------- @@ -4808,6 +5208,7 @@ class ConfigurationMessage final : kDisplayNameFieldNumber = 3, kProfilePictureFieldNumber = 4, kProfileKeyFieldNumber = 5, + kProFieldNumber = 7, }; // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; int closedgroups_size() const; @@ -4923,6 +5324,24 @@ class ConfigurationMessage final : std::string* _internal_mutable_profilekey(); public: + // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + bool has_pro() const; + private: + bool _internal_has_pro() const; + public: + void clear_pro(); + const ::SessionProtos::ConfigurationMessage_Pro& pro() const; + PROTOBUF_NODISCARD ::SessionProtos::ConfigurationMessage_Pro* release_pro(); + ::SessionProtos::ConfigurationMessage_Pro* mutable_pro(); + void set_allocated_pro(::SessionProtos::ConfigurationMessage_Pro* pro); + private: + const ::SessionProtos::ConfigurationMessage_Pro& _internal_pro() const; + ::SessionProtos::ConfigurationMessage_Pro* _internal_mutable_pro(); + public: + void unsafe_arena_set_allocated_pro( + ::SessionProtos::ConfigurationMessage_Pro* pro); + ::SessionProtos::ConfigurationMessage_Pro* unsafe_arena_release_pro(); + // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage) private: class _Internal; @@ -4939,6 +5358,7 @@ class ConfigurationMessage final : ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; + ::SessionProtos::ConfigurationMessage_Pro* pro_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; @@ -4991,7 +5411,7 @@ class ReceiptMessage final : &_ReceiptMessage_default_instance_); } static constexpr int kIndexInFileMessages = - 20; + 22; friend void swap(ReceiptMessage& a, ReceiptMessage& b) { a.Swap(&b); @@ -5183,7 +5603,7 @@ class AttachmentPointer final : &_AttachmentPointer_default_instance_); } static constexpr int kIndexInFileMessages = - 21; + 23; friend void swap(AttachmentPointer& a, AttachmentPointer& b) { a.Swap(&b); @@ -5549,7 +5969,7 @@ class SharedConfigMessage final : &_SharedConfigMessage_default_instance_); } static constexpr int kIndexInFileMessages = - 22; + 24; friend void swap(SharedConfigMessage& a, SharedConfigMessage& b) { a.Swap(&b); @@ -11045,6 +11465,410 @@ inline void ConfigurationMessage_Contact::set_didapproveme(bool value) { // ------------------------------------------------------------------- +// ConfigurationMessage_ProProof + +// required uint32 version = 1; +inline bool ConfigurationMessage_ProProof::_internal_has_version() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool ConfigurationMessage_ProProof::has_version() const { + return _internal_has_version(); +} +inline void ConfigurationMessage_ProProof::clear_version() { + _impl_.version_ = 0u; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline uint32_t ConfigurationMessage_ProProof::_internal_version() const { + return _impl_.version_; +} +inline uint32_t ConfigurationMessage_ProProof::version() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.version) + return _internal_version(); +} +inline void ConfigurationMessage_ProProof::_internal_set_version(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.version_ = value; +} +inline void ConfigurationMessage_ProProof::set_version(uint32_t value) { + _internal_set_version(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.version) +} + +// required bytes genIndexHash = 2; +inline bool ConfigurationMessage_ProProof::_internal_has_genindexhash() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool ConfigurationMessage_ProProof::has_genindexhash() const { + return _internal_has_genindexhash(); +} +inline void ConfigurationMessage_ProProof::clear_genindexhash() { + _impl_.genindexhash_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& ConfigurationMessage_ProProof::genindexhash() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) + return _internal_genindexhash(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ConfigurationMessage_ProProof::set_genindexhash(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.genindexhash_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) +} +inline std::string* ConfigurationMessage_ProProof::mutable_genindexhash() { + std::string* _s = _internal_mutable_genindexhash(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) + return _s; +} +inline const std::string& ConfigurationMessage_ProProof::_internal_genindexhash() const { + return _impl_.genindexhash_.Get(); +} +inline void ConfigurationMessage_ProProof::_internal_set_genindexhash(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.genindexhash_.Set(value, GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_ProProof::_internal_mutable_genindexhash() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.genindexhash_.Mutable(GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_ProProof::release_genindexhash() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) + if (!_internal_has_genindexhash()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.genindexhash_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.genindexhash_.IsDefault()) { + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ConfigurationMessage_ProProof::set_allocated_genindexhash(std::string* genindexhash) { + if (genindexhash != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.genindexhash_.SetAllocated(genindexhash, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.genindexhash_.IsDefault()) { + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) +} + +// required bytes rotatingPublicKey = 3; +inline bool ConfigurationMessage_ProProof::_internal_has_rotatingpublickey() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool ConfigurationMessage_ProProof::has_rotatingpublickey() const { + return _internal_has_rotatingpublickey(); +} +inline void ConfigurationMessage_ProProof::clear_rotatingpublickey() { + _impl_.rotatingpublickey_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& ConfigurationMessage_ProProof::rotatingpublickey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) + return _internal_rotatingpublickey(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ConfigurationMessage_ProProof::set_rotatingpublickey(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.rotatingpublickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) +} +inline std::string* ConfigurationMessage_ProProof::mutable_rotatingpublickey() { + std::string* _s = _internal_mutable_rotatingpublickey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) + return _s; +} +inline const std::string& ConfigurationMessage_ProProof::_internal_rotatingpublickey() const { + return _impl_.rotatingpublickey_.Get(); +} +inline void ConfigurationMessage_ProProof::_internal_set_rotatingpublickey(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.rotatingpublickey_.Set(value, GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_ProProof::_internal_mutable_rotatingpublickey() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.rotatingpublickey_.Mutable(GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_ProProof::release_rotatingpublickey() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) + if (!_internal_has_rotatingpublickey()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.rotatingpublickey_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.rotatingpublickey_.IsDefault()) { + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ConfigurationMessage_ProProof::set_allocated_rotatingpublickey(std::string* rotatingpublickey) { + if (rotatingpublickey != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.rotatingpublickey_.SetAllocated(rotatingpublickey, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.rotatingpublickey_.IsDefault()) { + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) +} + +// required uint64 expiryUnixTs = 4; +inline bool ConfigurationMessage_ProProof::_internal_has_expiryunixts() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool ConfigurationMessage_ProProof::has_expiryunixts() const { + return _internal_has_expiryunixts(); +} +inline void ConfigurationMessage_ProProof::clear_expiryunixts() { + _impl_.expiryunixts_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline uint64_t ConfigurationMessage_ProProof::_internal_expiryunixts() const { + return _impl_.expiryunixts_; +} +inline uint64_t ConfigurationMessage_ProProof::expiryunixts() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.expiryUnixTs) + return _internal_expiryunixts(); +} +inline void ConfigurationMessage_ProProof::_internal_set_expiryunixts(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.expiryunixts_ = value; +} +inline void ConfigurationMessage_ProProof::set_expiryunixts(uint64_t value) { + _internal_set_expiryunixts(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.expiryUnixTs) +} + +// required bytes sig = 5; +inline bool ConfigurationMessage_ProProof::_internal_has_sig() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool ConfigurationMessage_ProProof::has_sig() const { + return _internal_has_sig(); +} +inline void ConfigurationMessage_ProProof::clear_sig() { + _impl_.sig_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline const std::string& ConfigurationMessage_ProProof::sig() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.sig) + return _internal_sig(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ConfigurationMessage_ProProof::set_sig(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.sig_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.sig) +} +inline std::string* ConfigurationMessage_ProProof::mutable_sig() { + std::string* _s = _internal_mutable_sig(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ProProof.sig) + return _s; +} +inline const std::string& ConfigurationMessage_ProProof::_internal_sig() const { + return _impl_.sig_.Get(); +} +inline void ConfigurationMessage_ProProof::_internal_set_sig(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.sig_.Set(value, GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_ProProof::_internal_mutable_sig() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.sig_.Mutable(GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_ProProof::release_sig() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ProProof.sig) + if (!_internal_has_sig()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.sig_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.sig_.IsDefault()) { + _impl_.sig_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ConfigurationMessage_ProProof::set_allocated_sig(std::string* sig) { + if (sig != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.sig_.SetAllocated(sig, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.sig_.IsDefault()) { + _impl_.sig_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ProProof.sig) +} + +// ------------------------------------------------------------------- + +// ConfigurationMessage_Pro + +// required bytes rotatingPrivKey = 1; +inline bool ConfigurationMessage_Pro::_internal_has_rotatingprivkey() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool ConfigurationMessage_Pro::has_rotatingprivkey() const { + return _internal_has_rotatingprivkey(); +} +inline void ConfigurationMessage_Pro::clear_rotatingprivkey() { + _impl_.rotatingprivkey_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& ConfigurationMessage_Pro::rotatingprivkey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) + return _internal_rotatingprivkey(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ConfigurationMessage_Pro::set_rotatingprivkey(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.rotatingprivkey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) +} +inline std::string* ConfigurationMessage_Pro::mutable_rotatingprivkey() { + std::string* _s = _internal_mutable_rotatingprivkey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) + return _s; +} +inline const std::string& ConfigurationMessage_Pro::_internal_rotatingprivkey() const { + return _impl_.rotatingprivkey_.Get(); +} +inline void ConfigurationMessage_Pro::_internal_set_rotatingprivkey(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.rotatingprivkey_.Set(value, GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_Pro::_internal_mutable_rotatingprivkey() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.rotatingprivkey_.Mutable(GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_Pro::release_rotatingprivkey() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) + if (!_internal_has_rotatingprivkey()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.rotatingprivkey_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.rotatingprivkey_.IsDefault()) { + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ConfigurationMessage_Pro::set_allocated_rotatingprivkey(std::string* rotatingprivkey) { + if (rotatingprivkey != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.rotatingprivkey_.SetAllocated(rotatingprivkey, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.rotatingprivkey_.IsDefault()) { + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) +} + +// required bytes proof = 2; +inline bool ConfigurationMessage_Pro::_internal_has_proof() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool ConfigurationMessage_Pro::has_proof() const { + return _internal_has_proof(); +} +inline void ConfigurationMessage_Pro::clear_proof() { + _impl_.proof_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& ConfigurationMessage_Pro::proof() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Pro.proof) + return _internal_proof(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ConfigurationMessage_Pro::set_proof(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.proof_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Pro.proof) +} +inline std::string* ConfigurationMessage_Pro::mutable_proof() { + std::string* _s = _internal_mutable_proof(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Pro.proof) + return _s; +} +inline const std::string& ConfigurationMessage_Pro::_internal_proof() const { + return _impl_.proof_.Get(); +} +inline void ConfigurationMessage_Pro::_internal_set_proof(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.proof_.Set(value, GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_Pro::_internal_mutable_proof() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.proof_.Mutable(GetArenaForAllocation()); +} +inline std::string* ConfigurationMessage_Pro::release_proof() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Pro.proof) + if (!_internal_has_proof()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.proof_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.proof_.IsDefault()) { + _impl_.proof_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ConfigurationMessage_Pro::set_allocated_proof(std::string* proof) { + if (proof != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.proof_.SetAllocated(proof, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.proof_.IsDefault()) { + _impl_.proof_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Pro.proof) +} + +// ------------------------------------------------------------------- + // ConfigurationMessage // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; @@ -11406,6 +12230,96 @@ ConfigurationMessage::contacts() const { return _impl_.contacts_; } +// optional .SessionProtos.ConfigurationMessage.Pro pro = 7; +inline bool ConfigurationMessage::_internal_has_pro() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.pro_ != nullptr); + return value; +} +inline bool ConfigurationMessage::has_pro() const { + return _internal_has_pro(); +} +inline void ConfigurationMessage::clear_pro() { + if (_impl_.pro_ != nullptr) _impl_.pro_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline const ::SessionProtos::ConfigurationMessage_Pro& ConfigurationMessage::_internal_pro() const { + const ::SessionProtos::ConfigurationMessage_Pro* p = _impl_.pro_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ConfigurationMessage_Pro_default_instance_); +} +inline const ::SessionProtos::ConfigurationMessage_Pro& ConfigurationMessage::pro() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.pro) + return _internal_pro(); +} +inline void ConfigurationMessage::unsafe_arena_set_allocated_pro( + ::SessionProtos::ConfigurationMessage_Pro* pro) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.pro_); + } + _impl_.pro_ = pro; + if (pro) { + _impl_._has_bits_[0] |= 0x00000008u; + } else { + _impl_._has_bits_[0] &= ~0x00000008u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.pro) +} +inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::release_pro() { + _impl_._has_bits_[0] &= ~0x00000008u; + ::SessionProtos::ConfigurationMessage_Pro* temp = _impl_.pro_; + _impl_.pro_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::unsafe_arena_release_pro() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.pro) + _impl_._has_bits_[0] &= ~0x00000008u; + ::SessionProtos::ConfigurationMessage_Pro* temp = _impl_.pro_; + _impl_.pro_ = nullptr; + return temp; +} +inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::_internal_mutable_pro() { + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.pro_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Pro>(GetArenaForAllocation()); + _impl_.pro_ = p; + } + return _impl_.pro_; +} +inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::mutable_pro() { + ::SessionProtos::ConfigurationMessage_Pro* _msg = _internal_mutable_pro(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.pro) + return _msg; +} +inline void ConfigurationMessage::set_allocated_pro(::SessionProtos::ConfigurationMessage_Pro* pro) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.pro_; + } + if (pro) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(pro); + if (message_arena != submessage_arena) { + pro = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, pro, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000008u; + } else { + _impl_._has_bits_[0] &= ~0x00000008u; + } + _impl_.pro_ = pro; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.pro) +} + // ------------------------------------------------------------------- // ReceiptMessage @@ -12282,6 +13196,10 @@ inline void SharedConfigMessage::set_allocated_data(std::string* data) { // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index a9d434b0..cdac33c4 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -242,14 +242,18 @@ message ConfigurationMessage { required bytes sig = 5; } + message Pro { + required bytes rotatingPrivKey = 1; + required bytes proof = 2; + } + repeated ClosedGroup closedGroups = 1; repeated string openGroups = 2; optional string displayName = 3; optional string profilePicture = 4; optional bytes profileKey = 5; repeated Contact contacts = 6; - optional bytes proRotatingKey = 7; - optional ProProof proProof = 8; + optional Pro pro = 7; } message ReceiptMessage { From d4233d14d24330748e9fb8762e0f026fa6fff350 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 5 Aug 2025 12:12:54 +1000 Subject: [PATCH 011/171] Typedef array u8x32, add it to types.hpp anad use it in new code --- include/session/config/pro.hpp | 25 +++++----- include/session/session_encrypt.hpp | 3 +- include/session/types.hpp | 14 +++--- src/config/pro.cpp | 73 ++++++++++++++--------------- src/pro.cpp | 65 +++++++++++++------------ tests/test_config_pro.cpp | 2 +- 6 files changed, 89 insertions(+), 93 deletions(-) diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 13f5bef5..25d4a98b 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -1,9 +1,9 @@ +#include +#include #include #include -#include - -#include -#include +#include +#include namespace session::config { @@ -17,15 +17,15 @@ namespace session::config { class Proof { public: /// Version of the proof set by the Session Pro Backend - uint8_t version; + std::uint8_t version; /// Hash of the generation index set by the Session Pro Backend - std::array gen_index_hash; + array_uc32 gen_index_hash; /// The public key that the Session client registers their Session Pro entitlement under. /// Session clients must sign messages with this key along side the sending of this proof for /// the network to authenticate their usage of the proof - std::array rotating_pubkey; + array_uc32 rotating_pubkey; /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid to std::chrono::sys_seconds expiry_unix_ts; @@ -33,7 +33,7 @@ class Proof { /// Signature over the contents of the proof. It is signed by the Session Pro Backend key which /// is the entity responsible for issueing tamper-proof Sesison Pro certificates for Session /// clients. - std::array sig; + array_uc64 sig; /// API: pro/Proof::verify /// @@ -49,12 +49,12 @@ class Proof { /// /// Outputs: /// - `bool` - True if the given key was the signatory of the proof, false otherwise - bool verify(const std::array& verify_pubkey) const; + bool verify(const array_uc32& verify_pubkey) const; /// API: pro/Proof::hash /// /// Create a 32-byte hash from the proof. This hash is the payload that is signed in the proof. - std::array hash() const; + array_uc32 hash() const; bool load(const dict& root); }; @@ -68,7 +68,7 @@ class Pro { /// Private key for the public key key specified in the proof. This is synced between clients /// to allow multiple clients to synchronise the Session Pro Proof and also the keys necessary /// to use the proof. - std::array rotating_privkey; + cleared_uc64 rotating_privkey; /// A cryptographic proof for entitling an Ed25519 key to Session Pro Proof proof; @@ -85,9 +85,8 @@ class Pro { /// Outputs: /// - `bool` - True if the proof was verified and the proof's rotating public key corresponds to /// the public component of the `rotating_privkey`. - bool verify(const std::array& verify_pubkey) const; + bool verify(const array_uc32& verify_pubkey) const; bool load(const dict& root); }; - }; // namespace session::config diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index c357a2f0..b4b6f5ed 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -2,10 +2,9 @@ #include #include +#include #include -#include "types.hpp" - // Helper functions for the "Session Protocol" encryption mechanism. This is the encryption used // for DMs sent from one Session user to another. // diff --git a/include/session/types.hpp b/include/session/types.hpp index 2f361c49..a33aaaf8 100644 --- a/include/session/types.hpp +++ b/include/session/types.hpp @@ -1,13 +1,13 @@ #pragma once #include -#include -#include -#include -#include +#include -namespace session { namespace config { +namespace session { +using array_uc32 = std::array; +using array_uc64 = std::array; +namespace config { using seqno_t = std::int64_t; - -}} // namespace session::config +} +} // namespace session diff --git a/src/config/pro.cpp b/src/config/pro.cpp index a2e3d937..d090f217 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -3,17 +3,16 @@ #include #include -#include #include "internal.hpp" namespace { -std::array proof_hash_internal( - uint8_t version, - std::span gen_index_hash, - std::span rotating_pubkey, - uint64_t expiry_unix_ts) { - std::array result = {}; +session::array_uc32 proof_hash_internal( + std::uint8_t version, + std::span gen_index_hash, + std::span rotating_pubkey, + std::uint64_t expiry_unix_ts) { + session::array_uc32 result = {}; crypto_generichash_blake2b_state state; crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); @@ -26,9 +25,9 @@ std::array proof_hash_internal( } bool proof_verify_internal( - std::span hash, - std::span sig, - std::span verify_pubkey) { + std::span hash, + std::span sig, + std::span verify_pubkey) { // The C/C++ interface verifies that the payloads are the correct size using the type system so // only need asserts here. assert(hash.size() == 32); @@ -41,20 +40,20 @@ bool proof_verify_internal( } bool pro_verify_internal( - std::span rotating_privkey, - std::span verify_pubkey, - uint8_t version, - std::span gen_index_hash, - std::span rotating_pubkey, - uint64_t expiry_unix_ts, - std::span sig) { - - std::array hash = + std::span rotating_privkey, + std::span verify_pubkey, + std::uint8_t version, + std::span gen_index_hash, + std::span rotating_pubkey, + std::uint64_t expiry_unix_ts, + std::span sig) { + + session::array_uc32 hash = proof_hash_internal(version, gen_index_hash, rotating_pubkey, expiry_unix_ts); if (!proof_verify_internal(hash, sig, verify_pubkey)) return false; - std::array rederived_pk; + session::array_uc32 rederived_pk; [[maybe_unused]] session::cleared_uc32 rederived_sk; crypto_sign_ed25519_seed_keypair( rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); @@ -75,14 +74,14 @@ static_assert(sizeof(((Proof*)0)->gen_index_hash) == 32); static_assert(sizeof(((Proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); static_assert(sizeof(((Proof*)0)->sig) == crypto_sign_ed25519_BYTES); -bool Proof::verify(const std::array& verify_pubkey) const { - std::array hash_to_sign = hash(); +bool Proof::verify(const array_uc32& verify_pubkey) const { + array_uc32 hash_to_sign = hash(); bool result = proof_verify_internal(hash_to_sign, sig, verify_pubkey); return result; } -std::array Proof::hash() const { - std::array result = proof_hash_internal( +array_uc32 Proof::hash() const { + array_uc32 result = proof_hash_internal( version, gen_index_hash, rotating_pubkey, expiry_unix_ts.time_since_epoch().count()); return result; } @@ -112,7 +111,7 @@ bool Proof::load(const dict& root) { return true; } -bool Pro::verify(const std::array& verify_pubkey) const { +bool Pro::verify(const array_uc32& verify_pubkey) const { uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); bool result = pro_verify_internal( rotating_privkey, @@ -157,14 +156,14 @@ static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); LIBSESSION_C_API bool proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey) { auto verify_pubkey_span = - std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); + std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); auto gen_index_hash = - std::span(proof->gen_index_hash, sizeof proof->gen_index_hash); + std::span(proof->gen_index_hash, sizeof proof->gen_index_hash); auto rotating_pubkey = - std::span(proof->rotating_pubkey, sizeof proof->rotating_pubkey); - auto sig = std::span(proof->sig, sizeof proof->sig); + std::span(proof->rotating_pubkey, sizeof proof->rotating_pubkey); + auto sig = std::span(proof->sig, sizeof proof->sig); - std::array hash = proof_hash_internal( + session::array_uc32 hash = proof_hash_internal( proof->version, gen_index_hash, rotating_pubkey, proof->expiry_unix_ts); bool result = proof_verify_internal(hash, sig, verify_pubkey_span); return result; @@ -172,14 +171,14 @@ LIBSESSION_C_API bool proof_verify(pro_proof const* proof, uint8_t const* verify LIBSESSION_C_API bool pro_verify(pro_pro const* pro, uint8_t const* verify_pubkey) { auto verify_pubkey_span = - std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); + std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); auto rotating_privkey = - std::span(pro->rotating_privkey, sizeof pro->rotating_privkey); - auto gen_index_hash = - std::span(pro->proof.gen_index_hash, sizeof pro->proof.gen_index_hash); - auto rotating_pubkey = - std::span(pro->proof.rotating_pubkey, sizeof pro->proof.rotating_pubkey); - auto sig = std::span(pro->proof.sig, sizeof pro->proof.sig); + std::span(pro->rotating_privkey, sizeof pro->rotating_privkey); + auto gen_index_hash = std::span( + pro->proof.gen_index_hash, sizeof pro->proof.gen_index_hash); + auto rotating_pubkey = std::span( + pro->proof.rotating_pubkey, sizeof pro->proof.rotating_pubkey); + auto sig = std::span(pro->proof.sig, sizeof pro->proof.sig); bool result = pro_verify_internal( rotating_privkey, diff --git a/src/pro.cpp b/src/pro.cpp index d07d4eb9..37ae59b5 100644 --- a/src/pro.cpp +++ b/src/pro.cpp @@ -2,66 +2,65 @@ #include #include #include -#include #include #include +#include namespace session::pro { -constexpr std::array BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +constexpr array_uc32 BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static_assert(BACKEND_PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); struct add_payment_request { - uint8_t version; - std::array master_pkey; - std::array rotating_pkey; - std::array payment_token; - std::array master_sig; - std::array rotating_sig; + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + array_uc32 payment_token; + array_uc32 master_sig; + array_uc32 rotating_sig; std::string to_json() const; }; struct get_proof_request { - uint8_t version; - std::array master_pkey; - std::array rotating_pkey; + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; std::chrono::seconds unix_ts_s; - std::array master_sig; - std::array rotating_sig; + array_uc32 master_sig; + array_uc32 rotating_sig; std::string to_json() const; }; struct master_rotating_sigs { - std::array master_sig; - std::array rotating_sig; + array_uc64 master_sig; + array_uc64 rotating_sig; }; struct revocation_item { - std::array gen_index_hash; + array_uc32 gen_index_hash; std::chrono::seconds expiry_unix_ts; }; -master_rotating_sigs build_get_proof_sigs(std::array master_privkey, std::array rotating_privkey, std::chrono::seconds unix_ts); -master_rotating_sigs build_add_payment_sigs(std::array master_privkey, std::array rotating_privkey, std::array payment_token_hash, std::chrono::seconds unix_ts); +master_rotating_sigs build_get_proof_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts); +master_rotating_sigs build_add_payment_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); master_rotating_sigs build_get_proof_sigs( - std::array master_privkey, - std::array rotating_privkey, - std::chrono::seconds unix_ts) { + const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts) { // Derive the public keys - std::array master_pubkey; - std::array rotating_pubkey; + array_uc32 master_pubkey; + array_uc32 rotating_pubkey; crypto_sign_ed25519_sk_to_pk(master_pubkey.data(), master_privkey.data()); crypto_sign_ed25519_sk_to_pk(rotating_pubkey.data(), rotating_privkey.data()); // Hash components to 32 bytes uint8_t version = 0; uint64_t unix_ts_s = unix_ts.count(); - std::array hash_to_sign = {}; + array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state; crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); @@ -78,19 +77,19 @@ master_rotating_sigs build_get_proof_sigs( } master_rotating_sigs build_add_payment_sigs( - std::array master_privkey, - std::array rotating_privkey, - std::array payment_token_hash, + const array_uc64& master_privkey, + const array_uc64& rotating_privkey, + const array_uc32& payment_token_hash, std::chrono::seconds unix_ts) { // Derive the public keys - std::array master_pubkey; - std::array rotating_pubkey; + array_uc32 master_pubkey; + array_uc32 rotating_pubkey; crypto_sign_ed25519_sk_to_pk(master_pubkey.data(), master_privkey.data()); crypto_sign_ed25519_sk_to_pk(rotating_pubkey.data(), rotating_privkey.data()); // Hash components to 32 bytes uint8_t version = 0; - std::array hash_to_sign = {}; + array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state; crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index da46fcc9..bc803974 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -9,7 +9,7 @@ using namespace oxenc::literals; TEST_CASE("Pro", "[config][pro]") { // Setup keys std::array rotating_pk, signing_pk; - std::array rotating_sk, signing_sk; + session::cleared_uc64 rotating_sk, signing_sk; { crypto_sign_ed25519_keypair(rotating_pk.data(), rotating_sk.data()); crypto_sign_ed25519_keypair(signing_pk.data(), signing_sk.data()); From 4c4847c91eaaffb26d58c7e23a492ce40d118775 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 6 Aug 2025 16:06:44 +1000 Subject: [PATCH 012/171] Add Pro message to Content and decrypt it --- include/session/config/pro.hpp | 10 +- include/session/config/user_profile.hpp | 4 +- include/session/pro.hpp | 72 + proto/SessionProtos.pb.cc | 6816 ++++++++-------- proto/SessionProtos.pb.h | 9407 ++++++++++++----------- proto/SessionProtos.proto | 33 +- src/CMakeLists.txt | 1 + src/config/pro.cpp | 18 +- src/config/user_profile.cpp | 10 +- src/pro.cpp | 108 +- tests/test_config_pro.cpp | 10 +- 11 files changed, 8682 insertions(+), 7807 deletions(-) create mode 100644 include/session/pro.hpp diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 25d4a98b..678b1e09 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -1,3 +1,5 @@ +#pragma once + #include #include #include @@ -7,6 +9,8 @@ namespace session::config { +enum ProProofVersion { ProProofVersion_v0 }; + /// keys used currently or in the past (so that we don't reuse): /// /// v - version @@ -14,7 +18,7 @@ namespace session::config { /// r - rotating ed25519 pubkey /// e - expiry unix timestamp (in seconds) /// s - proof signature, signed by the Session Pro Backend's ed25519 key -class Proof { +class ProProof { public: /// Version of the proof set by the Session Pro Backend std::uint8_t version; @@ -63,7 +67,7 @@ class Proof { /// /// r - rotating ed25519 privkey /// p - proof -class Pro { +class ProConfig { public: /// Private key for the public key key specified in the proof. This is synced between clients /// to allow multiple clients to synchronise the Session Pro Proof and also the keys necessary @@ -71,7 +75,7 @@ class Pro { cleared_uc64 rotating_privkey; /// A cryptographic proof for entitling an Ed25519 key to Session Pro - Proof proof; + ProProof proof; /// API: pro/Pro::verify /// diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index c3b775a6..d7c9cb71 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -250,7 +250,7 @@ class UserProfile : public ConfigBase { /// user does not have any entitlement to Session Pro data. /// /// Inputs: None - std::optional get_pro_data() const; + std::optional get_pro_data() const; /// API: user_profile/UserProfile::set_pro_data /// @@ -261,7 +261,7 @@ class UserProfile : public ConfigBase { /// Inputs: /// - `pro` -- The Session Pro components to assign to the current user profile. This will /// overwrite any existing Session Pro data if it exists. No verification of `pro` is done. - void set_pro_data(const Pro& pro); + void set_pro_data(const ProConfig& pro); }; } // namespace session::config diff --git a/include/session/pro.hpp b/include/session/pro.hpp new file mode 100644 index 00000000..92d1b2e1 --- /dev/null +++ b/include/session/pro.hpp @@ -0,0 +1,72 @@ +#pragma once + +#include +#include + +namespace session::pro { + +struct add_payment_request { + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + array_uc32 payment_token; + array_uc32 master_sig; + array_uc32 rotating_sig; + std::string to_json() const; +}; + +struct get_proof_request { + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + std::chrono::seconds unix_ts_s; + array_uc32 master_sig; + array_uc32 rotating_sig; + std::string to_json() const; +}; + +struct master_rotating_sigs { + array_uc64 master_sig; + array_uc64 rotating_sig; +}; + +struct revocation_item { + array_uc32 gen_index_hash; + std::chrono::seconds expiry_unix_ts; +}; + +enum class Status { + Nil, // Pro proof was not set + Invalid, // Pro proof was set; signature validation failed + Valid, // Pro proof was set, is verified; has not expired + Expired, // Pro proof was set, is verified; has expired +}; + +typedef std::uint32_t FeatureFlag; +enum FeatureFlag_ { + FeatureFlag_HigherCharacterLimit = 0 << 1, + FeatureFlag_ProBadge = 1 << 1, + FeatureFlag_AnimatedAvatar = 2 << 1, + FeatureFlag_All = + FeatureFlag_HigherCharacterLimit | FeatureFlag_ProBadge | FeatureFlag_AnimatedAvatar, +}; + +struct DecryptIncomingWithPro +{ + std::vector plaintext; + std::vector ed25519_pubkey; + config::ProProof pro_proof; + Status pro_status; + FeatureFlag pro_flags; +}; + +master_rotating_sigs build_get_proof_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts); +master_rotating_sigs build_add_payment_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); + +constexpr array_uc32 BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + +} // namespace session::pro diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index f58247a3..c65c09b5 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -83,6 +83,54 @@ struct MessageRequestResponseDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageRequestResponseDefaultTypeInternal _MessageRequestResponse_default_instance_; +PROTOBUF_CONSTEXPR ProProof::ProProof( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.genindexhash_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.rotatingpublickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.sig_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.expiryunixts_)*/uint64_t{0u} + , /*decltype(_impl_.version_)*/0u} {} +struct ProProofDefaultTypeInternal { + PROTOBUF_CONSTEXPR ProProofDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ProProofDefaultTypeInternal() {} + union { + ProProof _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProProofDefaultTypeInternal _ProProof_default_instance_; +PROTOBUF_CONSTEXPR ProConfig::ProConfig( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.rotatingprivkey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.proof_)*/nullptr} {} +struct ProConfigDefaultTypeInternal { + PROTOBUF_CONSTEXPR ProConfigDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ProConfigDefaultTypeInternal() {} + union { + ProConfig _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProConfigDefaultTypeInternal _ProConfig_default_instance_; +PROTOBUF_CONSTEXPR ProMessageConfig::ProMessageConfig( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.proof_)*/nullptr + , /*decltype(_impl_.flags_)*/0u} {} +struct ProMessageConfigDefaultTypeInternal { + PROTOBUF_CONSTEXPR ProMessageConfigDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ProMessageConfigDefaultTypeInternal() {} + union { + ProMessageConfig _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProMessageConfigDefaultTypeInternal _ProMessageConfig_default_instance_; PROTOBUF_CONSTEXPR Content::Content( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -95,7 +143,8 @@ PROTOBUF_CONSTEXPR Content::Content( , /*decltype(_impl_.dataextractionnotification_)*/nullptr , /*decltype(_impl_.unsendrequest_)*/nullptr , /*decltype(_impl_.messagerequestresponse_)*/nullptr - , /*decltype(_impl_.sharedconfigmessage_)*/nullptr} {} + , /*decltype(_impl_.sharedconfigmessage_)*/nullptr + , /*decltype(_impl_.promessageconfig_)*/nullptr} {} struct ContentDefaultTypeInternal { PROTOBUF_CONSTEXPR ContentDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -352,39 +401,6 @@ struct ConfigurationMessage_ContactDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ContactDefaultTypeInternal _ConfigurationMessage_Contact_default_instance_; -PROTOBUF_CONSTEXPR ConfigurationMessage_ProProof::ConfigurationMessage_ProProof( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.genindexhash_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.rotatingpublickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.sig_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.expiryunixts_)*/uint64_t{0u} - , /*decltype(_impl_.version_)*/0u} {} -struct ConfigurationMessage_ProProofDefaultTypeInternal { - PROTOBUF_CONSTEXPR ConfigurationMessage_ProProofDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ConfigurationMessage_ProProofDefaultTypeInternal() {} - union { - ConfigurationMessage_ProProof _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ProProofDefaultTypeInternal _ConfigurationMessage_ProProof_default_instance_; -PROTOBUF_CONSTEXPR ConfigurationMessage_Pro::ConfigurationMessage_Pro( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.rotatingprivkey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.proof_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} -struct ConfigurationMessage_ProDefaultTypeInternal { - PROTOBUF_CONSTEXPR ConfigurationMessage_ProDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ConfigurationMessage_ProDefaultTypeInternal() {} - union { - ConfigurationMessage_Pro _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ProDefaultTypeInternal _ConfigurationMessage_Pro_default_instance_; PROTOBUF_CONSTEXPR ConfigurationMessage::ConfigurationMessage( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -395,7 +411,7 @@ PROTOBUF_CONSTEXPR ConfigurationMessage::ConfigurationMessage( , /*decltype(_impl_.displayname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.profilepicture_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.profilekey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.pro_)*/nullptr} {} + , /*decltype(_impl_.proconfig_)*/nullptr} {} struct ConfigurationMessageDefaultTypeInternal { PROTOBUF_CONSTEXPR ConfigurationMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -2414,157 +2430,107 @@ std::string MessageRequestResponse::GetTypeName() const { // =================================================================== -class Content::_Internal { +class ProProof::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static const ::SessionProtos::DataMessage& datamessage(const Content* msg); - static void set_has_datamessage(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_version(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_genindexhash(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static const ::SessionProtos::CallMessage& callmessage(const Content* msg); - static void set_has_callmessage(HasBits* has_bits) { + static void set_has_rotatingpublickey(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::ReceiptMessage& receiptmessage(const Content* msg); - static void set_has_receiptmessage(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static const ::SessionProtos::TypingMessage& typingmessage(const Content* msg); - static void set_has_typingmessage(HasBits* has_bits) { + static void set_has_expiryunixts(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static const ::SessionProtos::ConfigurationMessage& configurationmessage(const Content* msg); - static void set_has_configurationmessage(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static const ::SessionProtos::DataExtractionNotification& dataextractionnotification(const Content* msg); - static void set_has_dataextractionnotification(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static const ::SessionProtos::UnsendRequest& unsendrequest(const Content* msg); - static void set_has_unsendrequest(HasBits* has_bits) { - (*has_bits)[0] |= 64u; - } - static const ::SessionProtos::MessageRequestResponse& messagerequestresponse(const Content* msg); - static void set_has_messagerequestresponse(HasBits* has_bits) { - (*has_bits)[0] |= 128u; + static void set_has_sig(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static const ::SessionProtos::SharedConfigMessage& sharedconfigmessage(const Content* msg); - static void set_has_sharedconfigmessage(HasBits* has_bits) { - (*has_bits)[0] |= 256u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000001f) ^ 0x0000001f) != 0; } }; -const ::SessionProtos::DataMessage& -Content::_Internal::datamessage(const Content* msg) { - return *msg->_impl_.datamessage_; -} -const ::SessionProtos::CallMessage& -Content::_Internal::callmessage(const Content* msg) { - return *msg->_impl_.callmessage_; -} -const ::SessionProtos::ReceiptMessage& -Content::_Internal::receiptmessage(const Content* msg) { - return *msg->_impl_.receiptmessage_; -} -const ::SessionProtos::TypingMessage& -Content::_Internal::typingmessage(const Content* msg) { - return *msg->_impl_.typingmessage_; -} -const ::SessionProtos::ConfigurationMessage& -Content::_Internal::configurationmessage(const Content* msg) { - return *msg->_impl_.configurationmessage_; -} -const ::SessionProtos::DataExtractionNotification& -Content::_Internal::dataextractionnotification(const Content* msg) { - return *msg->_impl_.dataextractionnotification_; -} -const ::SessionProtos::UnsendRequest& -Content::_Internal::unsendrequest(const Content* msg) { - return *msg->_impl_.unsendrequest_; -} -const ::SessionProtos::MessageRequestResponse& -Content::_Internal::messagerequestresponse(const Content* msg) { - return *msg->_impl_.messagerequestresponse_; -} -const ::SessionProtos::SharedConfigMessage& -Content::_Internal::sharedconfigmessage(const Content* msg) { - return *msg->_impl_.sharedconfigmessage_; -} -Content::Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, +ProProof::ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.Content) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ProProof) } -Content::Content(const Content& from) +ProProof::ProProof(const ProProof& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - Content* const _this = this; (void)_this; + ProProof* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.datamessage_){nullptr} - , decltype(_impl_.callmessage_){nullptr} - , decltype(_impl_.receiptmessage_){nullptr} - , decltype(_impl_.typingmessage_){nullptr} - , decltype(_impl_.configurationmessage_){nullptr} - , decltype(_impl_.dataextractionnotification_){nullptr} - , decltype(_impl_.unsendrequest_){nullptr} - , decltype(_impl_.messagerequestresponse_){nullptr} - , decltype(_impl_.sharedconfigmessage_){nullptr}}; + , decltype(_impl_.genindexhash_){} + , decltype(_impl_.rotatingpublickey_){} + , decltype(_impl_.sig_){} + , decltype(_impl_.expiryunixts_){} + , decltype(_impl_.version_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - if (from._internal_has_datamessage()) { - _this->_impl_.datamessage_ = new ::SessionProtos::DataMessage(*from._impl_.datamessage_); - } - if (from._internal_has_callmessage()) { - _this->_impl_.callmessage_ = new ::SessionProtos::CallMessage(*from._impl_.callmessage_); - } - if (from._internal_has_receiptmessage()) { - _this->_impl_.receiptmessage_ = new ::SessionProtos::ReceiptMessage(*from._impl_.receiptmessage_); - } - if (from._internal_has_typingmessage()) { - _this->_impl_.typingmessage_ = new ::SessionProtos::TypingMessage(*from._impl_.typingmessage_); - } - if (from._internal_has_configurationmessage()) { - _this->_impl_.configurationmessage_ = new ::SessionProtos::ConfigurationMessage(*from._impl_.configurationmessage_); - } - if (from._internal_has_dataextractionnotification()) { - _this->_impl_.dataextractionnotification_ = new ::SessionProtos::DataExtractionNotification(*from._impl_.dataextractionnotification_); - } - if (from._internal_has_unsendrequest()) { - _this->_impl_.unsendrequest_ = new ::SessionProtos::UnsendRequest(*from._impl_.unsendrequest_); + _impl_.genindexhash_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_genindexhash()) { + _this->_impl_.genindexhash_.Set(from._internal_genindexhash(), + _this->GetArenaForAllocation()); } - if (from._internal_has_messagerequestresponse()) { - _this->_impl_.messagerequestresponse_ = new ::SessionProtos::MessageRequestResponse(*from._impl_.messagerequestresponse_); + _impl_.rotatingpublickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_rotatingpublickey()) { + _this->_impl_.rotatingpublickey_.Set(from._internal_rotatingpublickey(), + _this->GetArenaForAllocation()); } - if (from._internal_has_sharedconfigmessage()) { - _this->_impl_.sharedconfigmessage_ = new ::SessionProtos::SharedConfigMessage(*from._impl_.sharedconfigmessage_); + _impl_.sig_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.sig_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_sig()) { + _this->_impl_.sig_.Set(from._internal_sig(), + _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.Content) + ::memcpy(&_impl_.expiryunixts_, &from._impl_.expiryunixts_, + static_cast(reinterpret_cast(&_impl_.version_) - + reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.ProProof) } -inline void Content::SharedCtor( +inline void ProProof::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.datamessage_){nullptr} - , decltype(_impl_.callmessage_){nullptr} - , decltype(_impl_.receiptmessage_){nullptr} - , decltype(_impl_.typingmessage_){nullptr} - , decltype(_impl_.configurationmessage_){nullptr} - , decltype(_impl_.dataextractionnotification_){nullptr} - , decltype(_impl_.unsendrequest_){nullptr} - , decltype(_impl_.messagerequestresponse_){nullptr} - , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.genindexhash_){} + , decltype(_impl_.rotatingpublickey_){} + , decltype(_impl_.sig_){} + , decltype(_impl_.expiryunixts_){uint64_t{0u}} + , decltype(_impl_.version_){0u} }; + _impl_.genindexhash_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingpublickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.sig_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.sig_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -Content::~Content() { - // @@protoc_insertion_point(destructor:SessionProtos.Content) +ProProof::~ProProof() { + // @@protoc_insertion_point(destructor:SessionProtos.ProProof) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -2572,147 +2538,92 @@ Content::~Content() { SharedDtor(); } -inline void Content::SharedDtor() { +inline void ProProof::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - if (this != internal_default_instance()) delete _impl_.datamessage_; - if (this != internal_default_instance()) delete _impl_.callmessage_; - if (this != internal_default_instance()) delete _impl_.receiptmessage_; - if (this != internal_default_instance()) delete _impl_.typingmessage_; - if (this != internal_default_instance()) delete _impl_.configurationmessage_; - if (this != internal_default_instance()) delete _impl_.dataextractionnotification_; - if (this != internal_default_instance()) delete _impl_.unsendrequest_; - if (this != internal_default_instance()) delete _impl_.messagerequestresponse_; - if (this != internal_default_instance()) delete _impl_.sharedconfigmessage_; + _impl_.genindexhash_.Destroy(); + _impl_.rotatingpublickey_.Destroy(); + _impl_.sig_.Destroy(); } -void Content::SetCachedSize(int size) const { +void ProProof::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void Content::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.Content) +void ProProof::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ProProof) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(_impl_.datamessage_ != nullptr); - _impl_.datamessage_->Clear(); + _impl_.genindexhash_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(_impl_.callmessage_ != nullptr); - _impl_.callmessage_->Clear(); + _impl_.rotatingpublickey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.receiptmessage_ != nullptr); - _impl_.receiptmessage_->Clear(); - } - if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(_impl_.typingmessage_ != nullptr); - _impl_.typingmessage_->Clear(); - } - if (cached_has_bits & 0x00000010u) { - GOOGLE_DCHECK(_impl_.configurationmessage_ != nullptr); - _impl_.configurationmessage_->Clear(); - } - if (cached_has_bits & 0x00000020u) { - GOOGLE_DCHECK(_impl_.dataextractionnotification_ != nullptr); - _impl_.dataextractionnotification_->Clear(); - } - if (cached_has_bits & 0x00000040u) { - GOOGLE_DCHECK(_impl_.unsendrequest_ != nullptr); - _impl_.unsendrequest_->Clear(); - } - if (cached_has_bits & 0x00000080u) { - GOOGLE_DCHECK(_impl_.messagerequestresponse_ != nullptr); - _impl_.messagerequestresponse_->Clear(); + _impl_.sig_.ClearNonDefaultToEmpty(); } } - if (cached_has_bits & 0x00000100u) { - GOOGLE_DCHECK(_impl_.sharedconfigmessage_ != nullptr); - _impl_.sharedconfigmessage_->Clear(); + if (cached_has_bits & 0x00000018u) { + ::memset(&_impl_.expiryunixts_, 0, static_cast( + reinterpret_cast(&_impl_.version_) - + reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional .SessionProtos.DataMessage dataMessage = 1; + // required uint32 version = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_datamessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.CallMessage callMessage = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_callmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr = ctx->ParseMessage(_internal_mutable_receiptmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.TypingMessage typingMessage = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr = ctx->ParseMessage(_internal_mutable_typingmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - ptr = ctx->ParseMessage(_internal_mutable_configurationmessage(), ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _Internal::set_has_version(&has_bits); + _impl_.version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { - ptr = ctx->ParseMessage(_internal_mutable_dataextractionnotification(), ptr); + // required bytes genIndexHash = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_genindexhash(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - case 9: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { - ptr = ctx->ParseMessage(_internal_mutable_unsendrequest(), ptr); + // required bytes rotatingPublicKey = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_rotatingpublickey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - case 10: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { - ptr = ctx->ParseMessage(_internal_mutable_messagerequestresponse(), ptr); + // required uint64 expiryUnixTs = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_expiryunixts(&has_bits); + _impl_.expiryunixts_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { - ptr = ctx->ParseMessage(_internal_mutable_sharedconfigmessage(), ptr); + // required bytes sig = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_sig(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; @@ -2741,344 +2652,276 @@ const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) #undef CHK_ } -uint8_t* Content::_InternalSerialize( +uint8_t* ProProof::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.Content) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProProof) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional .SessionProtos.DataMessage dataMessage = 1; + // required uint32 version = 1; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_version(), target); + } + + // required bytes genIndexHash = 2; if (cached_has_bits & 0x00000001u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, _Internal::datamessage(this), - _Internal::datamessage(this).GetCachedSize(), target, stream); + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_genindexhash(), target); } - // optional .SessionProtos.CallMessage callMessage = 3; + // required bytes rotatingPublicKey = 3; if (cached_has_bits & 0x00000002u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::callmessage(this), - _Internal::callmessage(this).GetCachedSize(), target, stream); + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_rotatingpublickey(), target); } - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + // required uint64 expiryUnixTs = 4; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_expiryunixts(), target); + } + + // required bytes sig = 5; if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(5, _Internal::receiptmessage(this), - _Internal::receiptmessage(this).GetCachedSize(), target, stream); + target = stream->WriteBytesMaybeAliased( + 5, this->_internal_sig(), target); } - // optional .SessionProtos.TypingMessage typingMessage = 6; - if (cached_has_bits & 0x00000008u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, _Internal::typingmessage(this), - _Internal::typingmessage(this).GetCachedSize(), target, stream); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProProof) + return target; +} - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - if (cached_has_bits & 0x00000010u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, _Internal::configurationmessage(this), - _Internal::configurationmessage(this).GetCachedSize(), target, stream); +size_t ProProof::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProProof) + size_t total_size = 0; + + if (_internal_has_genindexhash()) { + // required bytes genIndexHash = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); } - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - if (cached_has_bits & 0x00000020u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(8, _Internal::dataextractionnotification(this), - _Internal::dataextractionnotification(this).GetCachedSize(), target, stream); + if (_internal_has_rotatingpublickey()) { + // required bytes rotatingPublicKey = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); } - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - if (cached_has_bits & 0x00000040u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(9, _Internal::unsendrequest(this), - _Internal::unsendrequest(this).GetCachedSize(), target, stream); + if (_internal_has_sig()) { + // required bytes sig = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); } - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - if (cached_has_bits & 0x00000080u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(10, _Internal::messagerequestresponse(this), - _Internal::messagerequestresponse(this).GetCachedSize(), target, stream); + if (_internal_has_expiryunixts()) { + // required uint64 expiryUnixTs = 4; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); } - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - if (cached_has_bits & 0x00000100u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(11, _Internal::sharedconfigmessage(this), - _Internal::sharedconfigmessage(this).GetCachedSize(), target, stream); + if (_internal_has_version()) { + // required uint32 version = 1; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + } + + return total_size; +} +size_t ProProof::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProProof) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x0000001f) ^ 0x0000001f) == 0) { // All required fields are present. + // required bytes genIndexHash = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); + + // required bytes rotatingPublicKey = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); + + // required bytes sig = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); + + // required uint64 expiryUnixTs = 4; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + + // required uint32 version = 1; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Content) - return target; + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -size_t Content::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.Content) - size_t total_size = 0; +void ProProof::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} +void ProProof::MergeFrom(const ProProof& from) { + ProProof* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProProof) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - // optional .SessionProtos.DataMessage dataMessage = 1; + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.datamessage_); + _this->_internal_set_genindexhash(from._internal_genindexhash()); } - - // optional .SessionProtos.CallMessage callMessage = 3; if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.callmessage_); + _this->_internal_set_rotatingpublickey(from._internal_rotatingpublickey()); } - - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.receiptmessage_); + _this->_internal_set_sig(from._internal_sig()); } - - // optional .SessionProtos.TypingMessage typingMessage = 6; if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.typingmessage_); - } - - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.configurationmessage_); - } - - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.dataextractionnotification_); - } - - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - if (cached_has_bits & 0x00000040u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.unsendrequest_); - } - - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - if (cached_has_bits & 0x00000080u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.messagerequestresponse_); - } - - } - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - if (cached_has_bits & 0x00000100u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.sharedconfigmessage_); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void Content::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} - -void Content::MergeFrom(const Content& from) { - Content* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Content) - GOOGLE_DCHECK_NE(&from, _this); - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - if (cached_has_bits & 0x00000001u) { - _this->_internal_mutable_datamessage()->::SessionProtos::DataMessage::MergeFrom( - from._internal_datamessage()); - } - if (cached_has_bits & 0x00000002u) { - _this->_internal_mutable_callmessage()->::SessionProtos::CallMessage::MergeFrom( - from._internal_callmessage()); - } - if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_receiptmessage()->::SessionProtos::ReceiptMessage::MergeFrom( - from._internal_receiptmessage()); - } - if (cached_has_bits & 0x00000008u) { - _this->_internal_mutable_typingmessage()->::SessionProtos::TypingMessage::MergeFrom( - from._internal_typingmessage()); + _this->_impl_.expiryunixts_ = from._impl_.expiryunixts_; } if (cached_has_bits & 0x00000010u) { - _this->_internal_mutable_configurationmessage()->::SessionProtos::ConfigurationMessage::MergeFrom( - from._internal_configurationmessage()); - } - if (cached_has_bits & 0x00000020u) { - _this->_internal_mutable_dataextractionnotification()->::SessionProtos::DataExtractionNotification::MergeFrom( - from._internal_dataextractionnotification()); - } - if (cached_has_bits & 0x00000040u) { - _this->_internal_mutable_unsendrequest()->::SessionProtos::UnsendRequest::MergeFrom( - from._internal_unsendrequest()); - } - if (cached_has_bits & 0x00000080u) { - _this->_internal_mutable_messagerequestresponse()->::SessionProtos::MessageRequestResponse::MergeFrom( - from._internal_messagerequestresponse()); + _this->_impl_.version_ = from._impl_.version_; } - } - if (cached_has_bits & 0x00000100u) { - _this->_internal_mutable_sharedconfigmessage()->::SessionProtos::SharedConfigMessage::MergeFrom( - from._internal_sharedconfigmessage()); + _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void Content::CopyFrom(const Content& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.Content) +void ProProof::CopyFrom(const ProProof& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProProof) if (&from == this) return; Clear(); MergeFrom(from); } -bool Content::IsInitialized() const { - if (_internal_has_datamessage()) { - if (!_impl_.datamessage_->IsInitialized()) return false; - } - if (_internal_has_callmessage()) { - if (!_impl_.callmessage_->IsInitialized()) return false; - } - if (_internal_has_receiptmessage()) { - if (!_impl_.receiptmessage_->IsInitialized()) return false; - } - if (_internal_has_typingmessage()) { - if (!_impl_.typingmessage_->IsInitialized()) return false; - } - if (_internal_has_configurationmessage()) { - if (!_impl_.configurationmessage_->IsInitialized()) return false; - } - if (_internal_has_dataextractionnotification()) { - if (!_impl_.dataextractionnotification_->IsInitialized()) return false; - } - if (_internal_has_unsendrequest()) { - if (!_impl_.unsendrequest_->IsInitialized()) return false; - } - if (_internal_has_messagerequestresponse()) { - if (!_impl_.messagerequestresponse_->IsInitialized()) return false; - } - if (_internal_has_sharedconfigmessage()) { - if (!_impl_.sharedconfigmessage_->IsInitialized()) return false; - } +bool ProProof::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void Content::InternalSwap(Content* other) { +void ProProof::InternalSwap(ProProof* other) { using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.genindexhash_, lhs_arena, + &other->_impl_.genindexhash_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.rotatingpublickey_, lhs_arena, + &other->_impl_.rotatingpublickey_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.sig_, lhs_arena, + &other->_impl_.sig_, rhs_arena + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Content, _impl_.sharedconfigmessage_) - + sizeof(Content::_impl_.sharedconfigmessage_) - - PROTOBUF_FIELD_OFFSET(Content, _impl_.datamessage_)>( - reinterpret_cast(&_impl_.datamessage_), - reinterpret_cast(&other->_impl_.datamessage_)); + PROTOBUF_FIELD_OFFSET(ProProof, _impl_.version_) + + sizeof(ProProof::_impl_.version_) + - PROTOBUF_FIELD_OFFSET(ProProof, _impl_.expiryunixts_)>( + reinterpret_cast(&_impl_.expiryunixts_), + reinterpret_cast(&other->_impl_.expiryunixts_)); } -std::string Content::GetTypeName() const { - return "SessionProtos.Content"; +std::string ProProof::GetTypeName() const { + return "SessionProtos.ProProof"; } // =================================================================== -class CallMessage::_Internal { +class ProConfig::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_uuid(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_rotatingprivkey(HasBits* has_bits) { (*has_bits)[0] |= 1u; } + static const ::SessionProtos::ProProof& proof(const ProConfig* msg); + static void set_has_proof(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } static bool MissingRequiredFields(const HasBits& has_bits) { return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -CallMessage::CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::ProProof& +ProConfig::_Internal::proof(const ProConfig* msg) { + return *msg->_impl_.proof_; +} +ProConfig::ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.CallMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ProConfig) } -CallMessage::CallMessage(const CallMessage& from) +ProConfig::ProConfig(const ProConfig& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - CallMessage* const _this = this; (void)_this; + ProConfig* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.sdps_){from._impl_.sdps_} - , decltype(_impl_.sdpmlineindexes_){from._impl_.sdpmlineindexes_} - , decltype(_impl_.sdpmids_){from._impl_.sdpmids_} - , decltype(_impl_.uuid_){} - , decltype(_impl_.type_){}}; + , decltype(_impl_.rotatingprivkey_){} + , decltype(_impl_.proof_){nullptr}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.uuid_.InitDefault(); + _impl_.rotatingprivkey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.uuid_.Set("", GetArenaForAllocation()); + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_uuid()) { - _this->_impl_.uuid_.Set(from._internal_uuid(), + if (from._internal_has_rotatingprivkey()) { + _this->_impl_.rotatingprivkey_.Set(from._internal_rotatingprivkey(), _this->GetArenaForAllocation()); } - _this->_impl_.type_ = from._impl_.type_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.CallMessage) + if (from._internal_has_proof()) { + _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.ProConfig) } -inline void CallMessage::SharedCtor( +inline void ProConfig::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.sdps_){arena} - , decltype(_impl_.sdpmlineindexes_){arena} - , decltype(_impl_.sdpmids_){arena} - , decltype(_impl_.uuid_){} - , decltype(_impl_.type_){6} + , decltype(_impl_.rotatingprivkey_){} + , decltype(_impl_.proof_){nullptr} }; - _impl_.uuid_.InitDefault(); + _impl_.rotatingprivkey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.uuid_.Set("", GetArenaForAllocation()); + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -CallMessage::~CallMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.CallMessage) +ProConfig::~ProConfig() { + // @@protoc_insertion_point(destructor:SessionProtos.ProConfig) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -3086,107 +2929,56 @@ CallMessage::~CallMessage() { SharedDtor(); } -inline void CallMessage::SharedDtor() { +inline void ProConfig::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.sdps_.~RepeatedPtrField(); - _impl_.sdpmlineindexes_.~RepeatedField(); - _impl_.sdpmids_.~RepeatedPtrField(); - _impl_.uuid_.Destroy(); + _impl_.rotatingprivkey_.Destroy(); + if (this != internal_default_instance()) delete _impl_.proof_; } -void CallMessage::SetCachedSize(int size) const { +void ProConfig::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void CallMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.CallMessage) +void ProConfig::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ProConfig) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.sdps_.Clear(); - _impl_.sdpmlineindexes_.Clear(); - _impl_.sdpmids_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.uuid_.ClearNonDefaultToEmpty(); + _impl_.rotatingprivkey_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(_impl_.proof_ != nullptr); + _impl_.proof_->Clear(); } - _impl_.type_ = 6; } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ProConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.CallMessage.Type type = 1; + // required bytes rotatingPrivKey = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_rotatingprivkey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::CallMessage_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::CallMessage_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } } else goto handle_unusual; continue; - // repeated string sdps = 2; + // required .SessionProtos.ProProof proof = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_sdps(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else - goto handle_unusual; - continue; - // repeated uint32 sdpMLineIndexes = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_sdpmlineindexes(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<24>(ptr)); - } else if (static_cast(tag) == 26) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt32Parser(_internal_mutable_sdpmlineindexes(), ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated string sdpMids = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_sdpmids(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else - goto handle_unusual; - continue; - // required string uuid = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_uuid(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); CHK_(ptr); } else goto handle_unusual; @@ -3215,84 +3007,68 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c #undef CHK_ } -uint8_t* CallMessage::_InternalSerialize( +uint8_t* ProConfig::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.CallMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProConfig) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.CallMessage.Type type = 1; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); - } - - // repeated string sdps = 2; - for (int i = 0, n = this->_internal_sdps_size(); i < n; i++) { - const auto& s = this->_internal_sdps(i); - target = stream->WriteString(2, s, target); - } - - // repeated uint32 sdpMLineIndexes = 3; - for (int i = 0, n = this->_internal_sdpmlineindexes_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(3, this->_internal_sdpmlineindexes(i), target); - } - - // repeated string sdpMids = 4; - for (int i = 0, n = this->_internal_sdpmids_size(); i < n; i++) { - const auto& s = this->_internal_sdpmids(i); - target = stream->WriteString(4, s, target); + // required bytes rotatingPrivKey = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteBytesMaybeAliased( + 1, this->_internal_rotatingprivkey(), target); } - // required string uuid = 5; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 5, this->_internal_uuid(), target); + // required .SessionProtos.ProProof proof = 2; + if (cached_has_bits & 0x00000002u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, _Internal::proof(this), + _Internal::proof(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.CallMessage) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProConfig) return target; } -size_t CallMessage::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.CallMessage) +size_t ProConfig::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProConfig) size_t total_size = 0; - if (_internal_has_uuid()) { - // required string uuid = 5; + if (_internal_has_rotatingprivkey()) { + // required bytes rotatingPrivKey = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_uuid()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingprivkey()); } - if (_internal_has_type()) { - // required .SessionProtos.CallMessage.Type type = 1; + if (_internal_has_proof()) { + // required .SessionProtos.ProProof proof = 2; total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); } return total_size; } -size_t CallMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.CallMessage) +size_t ProConfig::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProConfig) size_t total_size = 0; if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string uuid = 5; + // required bytes rotatingPrivKey = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_uuid()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingprivkey()); - // required .SessionProtos.CallMessage.Type type = 1; + // required .SessionProtos.ProProof proof = 2; total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -3301,31 +3077,6 @@ size_t CallMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated string sdps = 2; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdps_.size()); - for (int i = 0, n = _impl_.sdps_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.sdps_.Get(i)); - } - - // repeated uint32 sdpMLineIndexes = 3; - { - size_t data_size = ::_pbi::WireFormatLite:: - UInt32Size(this->_impl_.sdpmlineindexes_); - total_size += 1 * - ::_pbi::FromIntSize(this->_internal_sdpmlineindexes_size()); - total_size += data_size; - } - - // repeated string sdpMids = 4; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdpmids_.size()); - for (int i = 0, n = _impl_.sdpmids_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.sdpmids_.Get(i)); - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -3334,77 +3085,75 @@ size_t CallMessage::ByteSizeLong() const { return total_size; } -void CallMessage::CheckTypeAndMergeFrom( +void ProConfig::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void CallMessage::MergeFrom(const CallMessage& from) { - CallMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.CallMessage) +void ProConfig::MergeFrom(const ProConfig& from) { + ProConfig* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProConfig) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.sdps_.MergeFrom(from._impl_.sdps_); - _this->_impl_.sdpmlineindexes_.MergeFrom(from._impl_.sdpmlineindexes_); - _this->_impl_.sdpmids_.MergeFrom(from._impl_.sdpmids_); cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_uuid(from._internal_uuid()); + _this->_internal_set_rotatingprivkey(from._internal_rotatingprivkey()); } if (cached_has_bits & 0x00000002u) { - _this->_impl_.type_ = from._impl_.type_; + _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( + from._internal_proof()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void CallMessage::CopyFrom(const CallMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.CallMessage) +void ProConfig::CopyFrom(const ProConfig& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProConfig) if (&from == this) return; Clear(); MergeFrom(from); } -bool CallMessage::IsInitialized() const { +bool ProConfig::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (_internal_has_proof()) { + if (!_impl_.proof_->IsInitialized()) return false; + } return true; } -void CallMessage::InternalSwap(CallMessage* other) { +void ProConfig::InternalSwap(ProConfig* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.sdps_.InternalSwap(&other->_impl_.sdps_); - _impl_.sdpmlineindexes_.InternalSwap(&other->_impl_.sdpmlineindexes_); - _impl_.sdpmids_.InternalSwap(&other->_impl_.sdpmids_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.uuid_, lhs_arena, - &other->_impl_.uuid_, rhs_arena + &_impl_.rotatingprivkey_, lhs_arena, + &other->_impl_.rotatingprivkey_, rhs_arena ); - swap(_impl_.type_, other->_impl_.type_); + swap(_impl_.proof_, other->_impl_.proof_); } -std::string CallMessage::GetTypeName() const { - return "SessionProtos.CallMessage"; +std::string ProConfig::GetTypeName() const { + return "SessionProtos.ProConfig"; } // =================================================================== -class KeyPair::_Internal { +class ProMessageConfig::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static const ::SessionProtos::ProProof& proof(const ProMessageConfig* msg); + static void set_has_proof(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_privatekey(HasBits* has_bits) { + static void set_has_flags(HasBits* has_bits) { (*has_bits)[0] |= 2u; } static bool MissingRequiredFields(const HasBits& has_bits) { @@ -3412,63 +3161,47 @@ class KeyPair::_Internal { } }; -KeyPair::KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::ProProof& +ProMessageConfig::_Internal::proof(const ProMessageConfig* msg) { + return *msg->_impl_.proof_; +} +ProMessageConfig::ProMessageConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.KeyPair) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ProMessageConfig) } -KeyPair::KeyPair(const KeyPair& from) +ProMessageConfig::ProMessageConfig(const ProMessageConfig& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - KeyPair* const _this = this; (void)_this; + ProMessageConfig* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.privatekey_){}}; + , decltype(_impl_.proof_){nullptr} + , decltype(_impl_.flags_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), - _this->GetArenaForAllocation()); - } - _impl_.privatekey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.privatekey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_privatekey()) { - _this->_impl_.privatekey_.Set(from._internal_privatekey(), - _this->GetArenaForAllocation()); + if (from._internal_has_proof()) { + _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.KeyPair) + _this->_impl_.flags_ = from._impl_.flags_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.ProMessageConfig) } -inline void KeyPair::SharedCtor( +inline void ProMessageConfig::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.privatekey_){} + , decltype(_impl_.proof_){nullptr} + , decltype(_impl_.flags_){0u} }; - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.privatekey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.privatekey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -KeyPair::~KeyPair() { - // @@protoc_insertion_point(destructor:SessionProtos.KeyPair) +ProMessageConfig::~ProMessageConfig() { + // @@protoc_insertion_point(destructor:SessionProtos.ProMessageConfig) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -3476,56 +3209,51 @@ KeyPair::~KeyPair() { SharedDtor(); } -inline void KeyPair::SharedDtor() { +inline void ProMessageConfig::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.publickey_.Destroy(); - _impl_.privatekey_.Destroy(); + if (this != internal_default_instance()) delete _impl_.proof_; } -void KeyPair::SetCachedSize(int size) const { +void ProMessageConfig::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void KeyPair::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.KeyPair) +void ProMessageConfig::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ProMessageConfig) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.privatekey_.ClearNonDefaultToEmpty(); - } + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(_impl_.proof_ != nullptr); + _impl_.proof_->Clear(); } + _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ProMessageConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes publicKey = 1; + // required .SessionProtos.ProProof proof = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes privateKey = 2; + // required uint32 flags = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_privatekey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3554,67 +3282,64 @@ const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) #undef CHK_ } -uint8_t* KeyPair::_InternalSerialize( +uint8_t* ProMessageConfig::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.KeyPair) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProMessageConfig) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes publicKey = 1; + // required .SessionProtos.ProProof proof = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::proof(this), + _Internal::proof(this).GetCachedSize(), target, stream); } - // required bytes privateKey = 2; + // required uint32 flags = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 2, this->_internal_privatekey(), target); + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_flags(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.KeyPair) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProMessageConfig) return target; } -size_t KeyPair::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.KeyPair) +size_t ProMessageConfig::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProMessageConfig) size_t total_size = 0; - if (_internal_has_publickey()) { - // required bytes publicKey = 1; + if (_internal_has_proof()) { + // required .SessionProtos.ProProof proof = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); } - if (_internal_has_privatekey()) { - // required bytes privateKey = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_privatekey()); + if (_internal_has_flags()) { + // required uint32 flags = 2; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); } return total_size; } -size_t KeyPair::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.KeyPair) +size_t ProMessageConfig::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProMessageConfig) size_t total_size = 0; if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes publicKey = 1; + // required .SessionProtos.ProProof proof = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); - // required bytes privateKey = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_privatekey()); + // required uint32 flags = 2; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -3631,15 +3356,15 @@ size_t KeyPair::ByteSizeLong() const { return total_size; } -void KeyPair::CheckTypeAndMergeFrom( +void ProMessageConfig::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void KeyPair::MergeFrom(const KeyPair& from) { - KeyPair* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.KeyPair) +void ProMessageConfig::MergeFrom(const ProMessageConfig& from) { + ProMessageConfig* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProMessageConfig) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -3647,100 +3372,215 @@ void KeyPair::MergeFrom(const KeyPair& from) { cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( + from._internal_proof()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_privatekey(from._internal_privatekey()); + _this->_impl_.flags_ = from._impl_.flags_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void KeyPair::CopyFrom(const KeyPair& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.KeyPair) +void ProMessageConfig::CopyFrom(const ProMessageConfig& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProMessageConfig) if (&from == this) return; Clear(); MergeFrom(from); } -bool KeyPair::IsInitialized() const { +bool ProMessageConfig::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (_internal_has_proof()) { + if (!_impl_.proof_->IsInitialized()) return false; + } return true; } -void KeyPair::InternalSwap(KeyPair* other) { +void ProMessageConfig::InternalSwap(ProMessageConfig* other) { using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.privatekey_, lhs_arena, - &other->_impl_.privatekey_, rhs_arena - ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ProMessageConfig, _impl_.flags_) + + sizeof(ProMessageConfig::_impl_.flags_) + - PROTOBUF_FIELD_OFFSET(ProMessageConfig, _impl_.proof_)>( + reinterpret_cast(&_impl_.proof_), + reinterpret_cast(&other->_impl_.proof_)); } -std::string KeyPair::GetTypeName() const { - return "SessionProtos.KeyPair"; +std::string ProMessageConfig::GetTypeName() const { + return "SessionProtos.ProMessageConfig"; } // =================================================================== -class DataExtractionNotification::_Internal { +class Content::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static const ::SessionProtos::DataMessage& datamessage(const Content* msg); + static void set_has_datamessage(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::SessionProtos::CallMessage& callmessage(const Content* msg); + static void set_has_callmessage(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_timestamp(HasBits* has_bits) { - (*has_bits)[0] |= 1u; + static const ::SessionProtos::ReceiptMessage& receiptmessage(const Content* msg); + static void set_has_receiptmessage(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000002) ^ 0x00000002) != 0; + static const ::SessionProtos::TypingMessage& typingmessage(const Content* msg); + static void set_has_typingmessage(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static const ::SessionProtos::ConfigurationMessage& configurationmessage(const Content* msg); + static void set_has_configurationmessage(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static const ::SessionProtos::DataExtractionNotification& dataextractionnotification(const Content* msg); + static void set_has_dataextractionnotification(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static const ::SessionProtos::UnsendRequest& unsendrequest(const Content* msg); + static void set_has_unsendrequest(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } + static const ::SessionProtos::MessageRequestResponse& messagerequestresponse(const Content* msg); + static void set_has_messagerequestresponse(HasBits* has_bits) { + (*has_bits)[0] |= 128u; + } + static const ::SessionProtos::SharedConfigMessage& sharedconfigmessage(const Content* msg); + static void set_has_sharedconfigmessage(HasBits* has_bits) { + (*has_bits)[0] |= 256u; + } + static const ::SessionProtos::ProMessageConfig& promessageconfig(const Content* msg); + static void set_has_promessageconfig(HasBits* has_bits) { + (*has_bits)[0] |= 512u; } }; -DataExtractionNotification::DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::DataMessage& +Content::_Internal::datamessage(const Content* msg) { + return *msg->_impl_.datamessage_; +} +const ::SessionProtos::CallMessage& +Content::_Internal::callmessage(const Content* msg) { + return *msg->_impl_.callmessage_; +} +const ::SessionProtos::ReceiptMessage& +Content::_Internal::receiptmessage(const Content* msg) { + return *msg->_impl_.receiptmessage_; +} +const ::SessionProtos::TypingMessage& +Content::_Internal::typingmessage(const Content* msg) { + return *msg->_impl_.typingmessage_; +} +const ::SessionProtos::ConfigurationMessage& +Content::_Internal::configurationmessage(const Content* msg) { + return *msg->_impl_.configurationmessage_; +} +const ::SessionProtos::DataExtractionNotification& +Content::_Internal::dataextractionnotification(const Content* msg) { + return *msg->_impl_.dataextractionnotification_; +} +const ::SessionProtos::UnsendRequest& +Content::_Internal::unsendrequest(const Content* msg) { + return *msg->_impl_.unsendrequest_; +} +const ::SessionProtos::MessageRequestResponse& +Content::_Internal::messagerequestresponse(const Content* msg) { + return *msg->_impl_.messagerequestresponse_; +} +const ::SessionProtos::SharedConfigMessage& +Content::_Internal::sharedconfigmessage(const Content* msg) { + return *msg->_impl_.sharedconfigmessage_; +} +const ::SessionProtos::ProMessageConfig& +Content::_Internal::promessageconfig(const Content* msg) { + return *msg->_impl_.promessageconfig_; +} +Content::Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataExtractionNotification) + // @@protoc_insertion_point(arena_constructor:SessionProtos.Content) } -DataExtractionNotification::DataExtractionNotification(const DataExtractionNotification& from) +Content::Content(const Content& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataExtractionNotification* const _this = this; (void)_this; + Content* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.timestamp_){} - , decltype(_impl_.type_){}}; + , decltype(_impl_.datamessage_){nullptr} + , decltype(_impl_.callmessage_){nullptr} + , decltype(_impl_.receiptmessage_){nullptr} + , decltype(_impl_.typingmessage_){nullptr} + , decltype(_impl_.configurationmessage_){nullptr} + , decltype(_impl_.dataextractionnotification_){nullptr} + , decltype(_impl_.unsendrequest_){nullptr} + , decltype(_impl_.messagerequestresponse_){nullptr} + , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.promessageconfig_){nullptr}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, - static_cast(reinterpret_cast(&_impl_.type_) - - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.type_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataExtractionNotification) + if (from._internal_has_datamessage()) { + _this->_impl_.datamessage_ = new ::SessionProtos::DataMessage(*from._impl_.datamessage_); + } + if (from._internal_has_callmessage()) { + _this->_impl_.callmessage_ = new ::SessionProtos::CallMessage(*from._impl_.callmessage_); + } + if (from._internal_has_receiptmessage()) { + _this->_impl_.receiptmessage_ = new ::SessionProtos::ReceiptMessage(*from._impl_.receiptmessage_); + } + if (from._internal_has_typingmessage()) { + _this->_impl_.typingmessage_ = new ::SessionProtos::TypingMessage(*from._impl_.typingmessage_); + } + if (from._internal_has_configurationmessage()) { + _this->_impl_.configurationmessage_ = new ::SessionProtos::ConfigurationMessage(*from._impl_.configurationmessage_); + } + if (from._internal_has_dataextractionnotification()) { + _this->_impl_.dataextractionnotification_ = new ::SessionProtos::DataExtractionNotification(*from._impl_.dataextractionnotification_); + } + if (from._internal_has_unsendrequest()) { + _this->_impl_.unsendrequest_ = new ::SessionProtos::UnsendRequest(*from._impl_.unsendrequest_); + } + if (from._internal_has_messagerequestresponse()) { + _this->_impl_.messagerequestresponse_ = new ::SessionProtos::MessageRequestResponse(*from._impl_.messagerequestresponse_); + } + if (from._internal_has_sharedconfigmessage()) { + _this->_impl_.sharedconfigmessage_ = new ::SessionProtos::SharedConfigMessage(*from._impl_.sharedconfigmessage_); + } + if (from._internal_has_promessageconfig()) { + _this->_impl_.promessageconfig_ = new ::SessionProtos::ProMessageConfig(*from._impl_.promessageconfig_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.Content) } -inline void DataExtractionNotification::SharedCtor( +inline void Content::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.timestamp_){uint64_t{0u}} - , decltype(_impl_.type_){1} + , decltype(_impl_.datamessage_){nullptr} + , decltype(_impl_.callmessage_){nullptr} + , decltype(_impl_.receiptmessage_){nullptr} + , decltype(_impl_.typingmessage_){nullptr} + , decltype(_impl_.configurationmessage_){nullptr} + , decltype(_impl_.dataextractionnotification_){nullptr} + , decltype(_impl_.unsendrequest_){nullptr} + , decltype(_impl_.messagerequestresponse_){nullptr} + , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.promessageconfig_){nullptr} }; } -DataExtractionNotification::~DataExtractionNotification() { - // @@protoc_insertion_point(destructor:SessionProtos.DataExtractionNotification) +Content::~Content() { + // @@protoc_insertion_point(destructor:SessionProtos.Content) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -3748,75 +3588,183 @@ DataExtractionNotification::~DataExtractionNotification() { SharedDtor(); } -inline void DataExtractionNotification::SharedDtor() { +inline void Content::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + if (this != internal_default_instance()) delete _impl_.datamessage_; + if (this != internal_default_instance()) delete _impl_.callmessage_; + if (this != internal_default_instance()) delete _impl_.receiptmessage_; + if (this != internal_default_instance()) delete _impl_.typingmessage_; + if (this != internal_default_instance()) delete _impl_.configurationmessage_; + if (this != internal_default_instance()) delete _impl_.dataextractionnotification_; + if (this != internal_default_instance()) delete _impl_.unsendrequest_; + if (this != internal_default_instance()) delete _impl_.messagerequestresponse_; + if (this != internal_default_instance()) delete _impl_.sharedconfigmessage_; + if (this != internal_default_instance()) delete _impl_.promessageconfig_; } -void DataExtractionNotification::SetCachedSize(int size) const { +void Content::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataExtractionNotification::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataExtractionNotification) +void Content::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.Content) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - _impl_.timestamp_ = uint64_t{0u}; - _impl_.type_ = 1; + if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(_impl_.datamessage_ != nullptr); + _impl_.datamessage_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(_impl_.callmessage_ != nullptr); + _impl_.callmessage_->Clear(); + } + if (cached_has_bits & 0x00000004u) { + GOOGLE_DCHECK(_impl_.receiptmessage_ != nullptr); + _impl_.receiptmessage_->Clear(); + } + if (cached_has_bits & 0x00000008u) { + GOOGLE_DCHECK(_impl_.typingmessage_ != nullptr); + _impl_.typingmessage_->Clear(); + } + if (cached_has_bits & 0x00000010u) { + GOOGLE_DCHECK(_impl_.configurationmessage_ != nullptr); + _impl_.configurationmessage_->Clear(); + } + if (cached_has_bits & 0x00000020u) { + GOOGLE_DCHECK(_impl_.dataextractionnotification_ != nullptr); + _impl_.dataextractionnotification_->Clear(); + } + if (cached_has_bits & 0x00000040u) { + GOOGLE_DCHECK(_impl_.unsendrequest_ != nullptr); + _impl_.unsendrequest_->Clear(); + } + if (cached_has_bits & 0x00000080u) { + GOOGLE_DCHECK(_impl_.messagerequestresponse_ != nullptr); + _impl_.messagerequestresponse_->Clear(); + } + } + if (cached_has_bits & 0x00000300u) { + if (cached_has_bits & 0x00000100u) { + GOOGLE_DCHECK(_impl_.sharedconfigmessage_ != nullptr); + _impl_.sharedconfigmessage_->Clear(); + } + if (cached_has_bits & 0x00000200u) { + GOOGLE_DCHECK(_impl_.promessageconfig_ != nullptr); + _impl_.promessageconfig_->Clear(); + } } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.DataExtractionNotification.Type type = 1; + // optional .SessionProtos.DataMessage dataMessage = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_datamessage(), ptr); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataExtractionNotification_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::DataExtractionNotification_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } } else goto handle_unusual; continue; - // optional uint64 timestamp = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - _Internal::set_has_timestamp(&has_bits); - _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // optional .SessionProtos.CallMessage callMessage = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_callmessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - _impl_._has_bits_.Or(has_bits); + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + ptr = ctx->ParseMessage(_internal_mutable_receiptmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.TypingMessage typingMessage = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + ptr = ctx->ParseMessage(_internal_mutable_typingmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { + ptr = ctx->ParseMessage(_internal_mutable_configurationmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { + ptr = ctx->ParseMessage(_internal_mutable_dataextractionnotification(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + case 9: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { + ptr = ctx->ParseMessage(_internal_mutable_unsendrequest(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + case 10: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { + ptr = ctx->ParseMessage(_internal_mutable_messagerequestresponse(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { + ptr = ctx->ParseMessage(_internal_mutable_sharedconfigmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; + case 12: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 98)) { + ptr = ctx->ParseMessage(_internal_mutable_promessageconfig(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -3824,53 +3772,174 @@ const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi:: #undef CHK_ } -uint8_t* DataExtractionNotification::_InternalSerialize( +uint8_t* Content::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataExtractionNotification) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.Content) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.DataExtractionNotification.Type type = 1; + // optional .SessionProtos.DataMessage dataMessage = 1; + if (cached_has_bits & 0x00000001u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::datamessage(this), + _Internal::datamessage(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.CallMessage callMessage = 3; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::callmessage(this), + _Internal::callmessage(this).GetCachedSize(), target, stream); } - // optional uint64 timestamp = 2; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_timestamp(), target); + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(5, _Internal::receiptmessage(this), + _Internal::receiptmessage(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.TypingMessage typingMessage = 6; + if (cached_has_bits & 0x00000008u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(6, _Internal::typingmessage(this), + _Internal::typingmessage(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; + if (cached_has_bits & 0x00000010u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(7, _Internal::configurationmessage(this), + _Internal::configurationmessage(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + if (cached_has_bits & 0x00000020u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(8, _Internal::dataextractionnotification(this), + _Internal::dataextractionnotification(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + if (cached_has_bits & 0x00000040u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(9, _Internal::unsendrequest(this), + _Internal::unsendrequest(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + if (cached_has_bits & 0x00000080u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(10, _Internal::messagerequestresponse(this), + _Internal::messagerequestresponse(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + if (cached_has_bits & 0x00000100u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(11, _Internal::sharedconfigmessage(this), + _Internal::sharedconfigmessage(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; + if (cached_has_bits & 0x00000200u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(12, _Internal::promessageconfig(this), + _Internal::promessageconfig(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataExtractionNotification) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Content) return target; } -size_t DataExtractionNotification::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataExtractionNotification) +size_t Content::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.Content) size_t total_size = 0; - // required .SessionProtos.DataExtractionNotification.Type type = 1; - if (_internal_has_type()) { - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // optional uint64 timestamp = 2; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); + if (cached_has_bits & 0x000000ffu) { + // optional .SessionProtos.DataMessage dataMessage = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.datamessage_); + } + + // optional .SessionProtos.CallMessage callMessage = 3; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.callmessage_); + } + + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.receiptmessage_); + } + + // optional .SessionProtos.TypingMessage typingMessage = 6; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.typingmessage_); + } + + // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.configurationmessage_); + } + + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + if (cached_has_bits & 0x00000020u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.dataextractionnotification_); + } + + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + if (cached_has_bits & 0x00000040u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.unsendrequest_); + } + + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + if (cached_has_bits & 0x00000080u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.messagerequestresponse_); + } + } + if (cached_has_bits & 0x00000300u) { + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + if (cached_has_bits & 0x00000100u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.sharedconfigmessage_); + } + + // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; + if (cached_has_bits & 0x00000200u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.promessageconfig_); + } + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -3879,127 +3948,193 @@ size_t DataExtractionNotification::ByteSizeLong() const { return total_size; } -void DataExtractionNotification::CheckTypeAndMergeFrom( +void Content::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataExtractionNotification::MergeFrom(const DataExtractionNotification& from) { - DataExtractionNotification* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataExtractionNotification) +void Content::MergeFrom(const Content& from) { + Content* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Content) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _this->_impl_.timestamp_ = from._impl_.timestamp_; + _this->_internal_mutable_datamessage()->::SessionProtos::DataMessage::MergeFrom( + from._internal_datamessage()); } if (cached_has_bits & 0x00000002u) { - _this->_impl_.type_ = from._impl_.type_; + _this->_internal_mutable_callmessage()->::SessionProtos::CallMessage::MergeFrom( + from._internal_callmessage()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; - } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); -} - -void DataExtractionNotification::CopyFrom(const DataExtractionNotification& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataExtractionNotification) + if (cached_has_bits & 0x00000004u) { + _this->_internal_mutable_receiptmessage()->::SessionProtos::ReceiptMessage::MergeFrom( + from._internal_receiptmessage()); + } + if (cached_has_bits & 0x00000008u) { + _this->_internal_mutable_typingmessage()->::SessionProtos::TypingMessage::MergeFrom( + from._internal_typingmessage()); + } + if (cached_has_bits & 0x00000010u) { + _this->_internal_mutable_configurationmessage()->::SessionProtos::ConfigurationMessage::MergeFrom( + from._internal_configurationmessage()); + } + if (cached_has_bits & 0x00000020u) { + _this->_internal_mutable_dataextractionnotification()->::SessionProtos::DataExtractionNotification::MergeFrom( + from._internal_dataextractionnotification()); + } + if (cached_has_bits & 0x00000040u) { + _this->_internal_mutable_unsendrequest()->::SessionProtos::UnsendRequest::MergeFrom( + from._internal_unsendrequest()); + } + if (cached_has_bits & 0x00000080u) { + _this->_internal_mutable_messagerequestresponse()->::SessionProtos::MessageRequestResponse::MergeFrom( + from._internal_messagerequestresponse()); + } + } + if (cached_has_bits & 0x00000300u) { + if (cached_has_bits & 0x00000100u) { + _this->_internal_mutable_sharedconfigmessage()->::SessionProtos::SharedConfigMessage::MergeFrom( + from._internal_sharedconfigmessage()); + } + if (cached_has_bits & 0x00000200u) { + _this->_internal_mutable_promessageconfig()->::SessionProtos::ProMessageConfig::MergeFrom( + from._internal_promessageconfig()); + } + } + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} + +void Content::CopyFrom(const Content& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.Content) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataExtractionNotification::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool Content::IsInitialized() const { + if (_internal_has_datamessage()) { + if (!_impl_.datamessage_->IsInitialized()) return false; + } + if (_internal_has_callmessage()) { + if (!_impl_.callmessage_->IsInitialized()) return false; + } + if (_internal_has_receiptmessage()) { + if (!_impl_.receiptmessage_->IsInitialized()) return false; + } + if (_internal_has_typingmessage()) { + if (!_impl_.typingmessage_->IsInitialized()) return false; + } + if (_internal_has_configurationmessage()) { + if (!_impl_.configurationmessage_->IsInitialized()) return false; + } + if (_internal_has_dataextractionnotification()) { + if (!_impl_.dataextractionnotification_->IsInitialized()) return false; + } + if (_internal_has_unsendrequest()) { + if (!_impl_.unsendrequest_->IsInitialized()) return false; + } + if (_internal_has_messagerequestresponse()) { + if (!_impl_.messagerequestresponse_->IsInitialized()) return false; + } + if (_internal_has_sharedconfigmessage()) { + if (!_impl_.sharedconfigmessage_->IsInitialized()) return false; + } + if (_internal_has_promessageconfig()) { + if (!_impl_.promessageconfig_->IsInitialized()) return false; + } return true; } -void DataExtractionNotification::InternalSwap(DataExtractionNotification* other) { +void Content::InternalSwap(Content* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - swap(_impl_.timestamp_, other->_impl_.timestamp_); - swap(_impl_.type_, other->_impl_.type_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Content, _impl_.promessageconfig_) + + sizeof(Content::_impl_.promessageconfig_) + - PROTOBUF_FIELD_OFFSET(Content, _impl_.datamessage_)>( + reinterpret_cast(&_impl_.datamessage_), + reinterpret_cast(&other->_impl_.datamessage_)); } -std::string DataExtractionNotification::GetTypeName() const { - return "SessionProtos.DataExtractionNotification"; +std::string Content::GetTypeName() const { + return "SessionProtos.Content"; } // =================================================================== -class LokiProfile::_Internal { +class CallMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_displayname(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_uuid(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_profilepicture(HasBits* has_bits) { - (*has_bits)[0] |= 2u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -LokiProfile::LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, +CallMessage::CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.LokiProfile) + // @@protoc_insertion_point(arena_constructor:SessionProtos.CallMessage) } -LokiProfile::LokiProfile(const LokiProfile& from) +CallMessage::CallMessage(const CallMessage& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - LokiProfile* const _this = this; (void)_this; + CallMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){}}; + , decltype(_impl_.sdps_){from._impl_.sdps_} + , decltype(_impl_.sdpmlineindexes_){from._impl_.sdpmlineindexes_} + , decltype(_impl_.sdpmids_){from._impl_.sdpmids_} + , decltype(_impl_.uuid_){} + , decltype(_impl_.type_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.displayname_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_displayname()) { - _this->_impl_.displayname_.Set(from._internal_displayname(), - _this->GetArenaForAllocation()); - } - _impl_.profilepicture_.InitDefault(); + _impl_.uuid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.uuid_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilepicture()) { - _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + if (from._internal_has_uuid()) { + _this->_impl_.uuid_.Set(from._internal_uuid(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.LokiProfile) + _this->_impl_.type_ = from._impl_.type_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.CallMessage) } -inline void LokiProfile::SharedCtor( +inline void CallMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){} + , decltype(_impl_.sdps_){arena} + , decltype(_impl_.sdpmlineindexes_){arena} + , decltype(_impl_.sdpmids_){arena} + , decltype(_impl_.uuid_){} + , decltype(_impl_.type_){6} }; - _impl_.displayname_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.InitDefault(); + _impl_.uuid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.uuid_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -LokiProfile::~LokiProfile() { - // @@protoc_insertion_point(destructor:SessionProtos.LokiProfile) +CallMessage::~CallMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.CallMessage) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -4007,55 +4142,106 @@ LokiProfile::~LokiProfile() { SharedDtor(); } -inline void LokiProfile::SharedDtor() { +inline void CallMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.displayname_.Destroy(); - _impl_.profilepicture_.Destroy(); + _impl_.sdps_.~RepeatedPtrField(); + _impl_.sdpmlineindexes_.~RepeatedField(); + _impl_.sdpmids_.~RepeatedPtrField(); + _impl_.uuid_.Destroy(); } -void LokiProfile::SetCachedSize(int size) const { +void CallMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void LokiProfile::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.LokiProfile) +void CallMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.CallMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.sdps_.Clear(); + _impl_.sdpmlineindexes_.Clear(); + _impl_.sdpmids_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.displayname_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.profilepicture_.ClearNonDefaultToEmpty(); + _impl_.uuid_.ClearNonDefaultToEmpty(); } + _impl_.type_ = 6; } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional string displayName = 1; + // required .SessionProtos.CallMessage.Type type = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_displayname(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::CallMessage_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::CallMessage_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // optional string profilePicture = 2; + // repeated string sdps = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_profilepicture(); + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_sdps(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else + goto handle_unusual; + continue; + // repeated uint32 sdpMLineIndexes = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_sdpmlineindexes(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<24>(ptr)); + } else if (static_cast(tag) == 26) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt32Parser(_internal_mutable_sdpmlineindexes(), ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // repeated string sdpMids = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_sdpmids(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else + goto handle_unusual; + continue; + // required string uuid = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_uuid(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else @@ -4085,58 +4271,117 @@ const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* c #undef CHK_ } -uint8_t* LokiProfile::_InternalSerialize( +uint8_t* CallMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.LokiProfile) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.CallMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional string displayName = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 1, this->_internal_displayname(), target); - } - - // optional string profilePicture = 2; + // required .SessionProtos.CallMessage.Type type = 1; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_profilepicture(), target); + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + // repeated string sdps = 2; + for (int i = 0, n = this->_internal_sdps_size(); i < n; i++) { + const auto& s = this->_internal_sdps(i); + target = stream->WriteString(2, s, target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.LokiProfile) + + // repeated uint32 sdpMLineIndexes = 3; + for (int i = 0, n = this->_internal_sdpmlineindexes_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(3, this->_internal_sdpmlineindexes(i), target); + } + + // repeated string sdpMids = 4; + for (int i = 0, n = this->_internal_sdpmids_size(); i < n; i++) { + const auto& s = this->_internal_sdpmids(i); + target = stream->WriteString(4, s, target); + } + + // required string uuid = 5; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteStringMaybeAliased( + 5, this->_internal_uuid(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.CallMessage) return target; } -size_t LokiProfile::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.LokiProfile) +size_t CallMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.CallMessage) + size_t total_size = 0; + + if (_internal_has_uuid()) { + // required string uuid = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_uuid()); + } + + if (_internal_has_type()) { + // required .SessionProtos.CallMessage.Type type = 1; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + } + + return total_size; +} +size_t CallMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.CallMessage) size_t total_size = 0; + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string uuid = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_uuid()); + + // required .SessionProtos.CallMessage.Type type = 1; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - // optional string displayName = 1; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_displayname()); - } + // repeated string sdps = 2; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdps_.size()); + for (int i = 0, n = _impl_.sdps_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.sdps_.Get(i)); + } - // optional string profilePicture = 2; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_profilepicture()); - } + // repeated uint32 sdpMLineIndexes = 3; + { + size_t data_size = ::_pbi::WireFormatLite:: + UInt32Size(this->_impl_.sdpmlineindexes_); + total_size += 1 * + ::_pbi::FromIntSize(this->_internal_sdpmlineindexes_size()); + total_size += data_size; + } + // repeated string sdpMids = 4; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdpmids_.size()); + for (int i = 0, n = _impl_.sdpmids_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.sdpmids_.Get(i)); } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -4145,152 +4390,141 @@ size_t LokiProfile::ByteSizeLong() const { return total_size; } -void LokiProfile::CheckTypeAndMergeFrom( +void CallMessage::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void LokiProfile::MergeFrom(const LokiProfile& from) { - LokiProfile* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.LokiProfile) +void CallMessage::MergeFrom(const CallMessage& from) { + CallMessage* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.CallMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; + _this->_impl_.sdps_.MergeFrom(from._impl_.sdps_); + _this->_impl_.sdpmlineindexes_.MergeFrom(from._impl_.sdpmlineindexes_); + _this->_impl_.sdpmids_.MergeFrom(from._impl_.sdpmids_); cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_displayname(from._internal_displayname()); + _this->_internal_set_uuid(from._internal_uuid()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_profilepicture(from._internal_profilepicture()); + _this->_impl_.type_ = from._impl_.type_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void LokiProfile::CopyFrom(const LokiProfile& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.LokiProfile) +void CallMessage::CopyFrom(const CallMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.CallMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool LokiProfile::IsInitialized() const { +bool CallMessage::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void LokiProfile::InternalSwap(LokiProfile* other) { +void CallMessage::InternalSwap(CallMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.sdps_.InternalSwap(&other->_impl_.sdps_); + _impl_.sdpmlineindexes_.InternalSwap(&other->_impl_.sdpmlineindexes_); + _impl_.sdpmids_.InternalSwap(&other->_impl_.sdpmids_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.displayname_, lhs_arena, - &other->_impl_.displayname_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilepicture_, lhs_arena, - &other->_impl_.profilepicture_, rhs_arena + &_impl_.uuid_, lhs_arena, + &other->_impl_.uuid_, rhs_arena ); + swap(_impl_.type_, other->_impl_.type_); } -std::string LokiProfile::GetTypeName() const { - return "SessionProtos.LokiProfile"; +std::string CallMessage::GetTypeName() const { + return "SessionProtos.CallMessage"; } // =================================================================== -class DataMessage_Quote_QuotedAttachment::_Internal { +class KeyPair::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_contenttype(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_publickey(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_filename(HasBits* has_bits) { + static void set_has_privatekey(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::AttachmentPointer& thumbnail(const DataMessage_Quote_QuotedAttachment* msg); - static void set_has_thumbnail(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_flags(HasBits* has_bits) { - (*has_bits)[0] |= 8u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -const ::SessionProtos::AttachmentPointer& -DataMessage_Quote_QuotedAttachment::_Internal::thumbnail(const DataMessage_Quote_QuotedAttachment* msg) { - return *msg->_impl_.thumbnail_; -} -DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, +KeyPair::KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(arena_constructor:SessionProtos.KeyPair) } -DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from) +KeyPair::KeyPair(const KeyPair& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Quote_QuotedAttachment* const _this = this; (void)_this; + KeyPair* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.contenttype_){} - , decltype(_impl_.filename_){} - , decltype(_impl_.thumbnail_){nullptr} - , decltype(_impl_.flags_){}}; + , decltype(_impl_.publickey_){} + , decltype(_impl_.privatekey_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.contenttype_.InitDefault(); + _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.contenttype_.Set("", GetArenaForAllocation()); + _impl_.publickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_contenttype()) { - _this->_impl_.contenttype_.Set(from._internal_contenttype(), + if (from._internal_has_publickey()) { + _this->_impl_.publickey_.Set(from._internal_publickey(), _this->GetArenaForAllocation()); } - _impl_.filename_.InitDefault(); + _impl_.privatekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.Set("", GetArenaForAllocation()); + _impl_.privatekey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_filename()) { - _this->_impl_.filename_.Set(from._internal_filename(), + if (from._internal_has_privatekey()) { + _this->_impl_.privatekey_.Set(from._internal_privatekey(), _this->GetArenaForAllocation()); } - if (from._internal_has_thumbnail()) { - _this->_impl_.thumbnail_ = new ::SessionProtos::AttachmentPointer(*from._impl_.thumbnail_); - } - _this->_impl_.flags_ = from._impl_.flags_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(copy_constructor:SessionProtos.KeyPair) } -inline void DataMessage_Quote_QuotedAttachment::SharedCtor( +inline void KeyPair::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.contenttype_){} - , decltype(_impl_.filename_){} - , decltype(_impl_.thumbnail_){nullptr} - , decltype(_impl_.flags_){0u} + , decltype(_impl_.publickey_){} + , decltype(_impl_.privatekey_){} }; - _impl_.contenttype_.InitDefault(); + _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.contenttype_.Set("", GetArenaForAllocation()); + _impl_.publickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.InitDefault(); + _impl_.privatekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.Set("", GetArenaForAllocation()); + _impl_.privatekey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Quote_QuotedAttachment::~DataMessage_Quote_QuotedAttachment() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote.QuotedAttachment) +KeyPair::~KeyPair() { + // @@protoc_insertion_point(destructor:SessionProtos.KeyPair) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -4298,83 +4532,60 @@ DataMessage_Quote_QuotedAttachment::~DataMessage_Quote_QuotedAttachment() { SharedDtor(); } -inline void DataMessage_Quote_QuotedAttachment::SharedDtor() { +inline void KeyPair::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.contenttype_.Destroy(); - _impl_.filename_.Destroy(); - if (this != internal_default_instance()) delete _impl_.thumbnail_; + _impl_.publickey_.Destroy(); + _impl_.privatekey_.Destroy(); } -void DataMessage_Quote_QuotedAttachment::SetCachedSize(int size) const { +void KeyPair::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Quote_QuotedAttachment::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +void KeyPair::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.KeyPair) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.contenttype_.ClearNonDefaultToEmpty(); + _impl_.publickey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.filename_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.thumbnail_ != nullptr); - _impl_.thumbnail_->Clear(); + _impl_.privatekey_.ClearNonDefaultToEmpty(); } } - _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional string contentType = 1; + // required bytes publicKey = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_contenttype(); + auto str = _internal_mutable_publickey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional string fileName = 2; + // required bytes privateKey = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_filename(); + auto str = _internal_mutable_privatekey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_thumbnail(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 flags = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -4399,83 +4610,75 @@ const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, #undef CHK_ } -uint8_t* DataMessage_Quote_QuotedAttachment::_InternalSerialize( +uint8_t* KeyPair::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.KeyPair) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional string contentType = 1; + // required bytes publicKey = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 1, this->_internal_contenttype(), target); + target = stream->WriteBytesMaybeAliased( + 1, this->_internal_publickey(), target); } - // optional string fileName = 2; + // required bytes privateKey = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_filename(), target); - } - - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::thumbnail(this), - _Internal::thumbnail(this).GetCachedSize(), target, stream); - } - - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_privatekey(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.KeyPair) return target; } -size_t DataMessage_Quote_QuotedAttachment::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +size_t KeyPair::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.KeyPair) size_t total_size = 0; - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + if (_internal_has_publickey()) { + // required bytes publicKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); + } - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional string contentType = 1; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_contenttype()); - } + if (_internal_has_privatekey()) { + // required bytes privateKey = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_privatekey()); + } - // optional string fileName = 2; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_filename()); - } + return total_size; +} +size_t KeyPair::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.KeyPair) + size_t total_size = 0; - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.thumbnail_); - } + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required bytes publicKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000008u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - } + // required bytes privateKey = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_privatekey()); + } else { + total_size += RequiredFieldsByteSizeFallback(); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -4484,161 +4687,116 @@ size_t DataMessage_Quote_QuotedAttachment::ByteSizeLong() const { return total_size; } -void DataMessage_Quote_QuotedAttachment::CheckTypeAndMergeFrom( +void KeyPair::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_Quote_QuotedAttachment::MergeFrom(const DataMessage_Quote_QuotedAttachment& from) { - DataMessage_Quote_QuotedAttachment* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +void KeyPair::MergeFrom(const KeyPair& from) { + KeyPair* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.KeyPair) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_contenttype(from._internal_contenttype()); + _this->_internal_set_publickey(from._internal_publickey()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_filename(from._internal_filename()); - } - if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_thumbnail()->::SessionProtos::AttachmentPointer::MergeFrom( - from._internal_thumbnail()); - } - if (cached_has_bits & 0x00000008u) { - _this->_impl_.flags_ = from._impl_.flags_; + _this->_internal_set_privatekey(from._internal_privatekey()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_Quote_QuotedAttachment::CopyFrom(const DataMessage_Quote_QuotedAttachment& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +void KeyPair::CopyFrom(const KeyPair& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.KeyPair) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Quote_QuotedAttachment::IsInitialized() const { - if (_internal_has_thumbnail()) { - if (!_impl_.thumbnail_->IsInitialized()) return false; - } +bool KeyPair::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage_Quote_QuotedAttachment::InternalSwap(DataMessage_Quote_QuotedAttachment* other) { +void KeyPair::InternalSwap(KeyPair* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.contenttype_, lhs_arena, - &other->_impl_.contenttype_, rhs_arena + &_impl_.publickey_, lhs_arena, + &other->_impl_.publickey_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.filename_, lhs_arena, - &other->_impl_.filename_, rhs_arena + &_impl_.privatekey_, lhs_arena, + &other->_impl_.privatekey_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.flags_) - + sizeof(DataMessage_Quote_QuotedAttachment::_impl_.flags_) - - PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.thumbnail_)>( - reinterpret_cast(&_impl_.thumbnail_), - reinterpret_cast(&other->_impl_.thumbnail_)); } -std::string DataMessage_Quote_QuotedAttachment::GetTypeName() const { - return "SessionProtos.DataMessage.Quote.QuotedAttachment"; +std::string KeyPair::GetTypeName() const { + return "SessionProtos.KeyPair"; } // =================================================================== -class DataMessage_Quote::_Internal { +class DataExtractionNotification::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_id(HasBits* has_bits) { - (*has_bits)[0] |= 4u; + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 2u; } - static void set_has_author(HasBits* has_bits) { + static void set_has_timestamp(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_text(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; + return ((has_bits[0] & 0x00000002) ^ 0x00000002) != 0; } }; -DataMessage_Quote::DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataExtractionNotification::DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataExtractionNotification) } -DataMessage_Quote::DataMessage_Quote(const DataMessage_Quote& from) +DataExtractionNotification::DataExtractionNotification(const DataExtractionNotification& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Quote* const _this = this; (void)_this; + DataExtractionNotification* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){from._impl_.attachments_} - , decltype(_impl_.author_){} - , decltype(_impl_.text_){} - , decltype(_impl_.id_){}}; + , decltype(_impl_.timestamp_){} + , decltype(_impl_.type_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.author_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_author()) { - _this->_impl_.author_.Set(from._internal_author(), - _this->GetArenaForAllocation()); - } - _impl_.text_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.text_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_text()) { - _this->_impl_.text_.Set(from._internal_text(), - _this->GetArenaForAllocation()); - } - _this->_impl_.id_ = from._impl_.id_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote) + ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, + static_cast(reinterpret_cast(&_impl_.type_) - + reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.type_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataExtractionNotification) } -inline void DataMessage_Quote::SharedCtor( +inline void DataExtractionNotification::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){arena} - , decltype(_impl_.author_){} - , decltype(_impl_.text_){} - , decltype(_impl_.id_){uint64_t{0u}} + , decltype(_impl_.timestamp_){uint64_t{0u}} + , decltype(_impl_.type_){1} }; - _impl_.author_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.text_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.text_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Quote::~DataMessage_Quote() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote) +DataExtractionNotification::~DataExtractionNotification() { + // @@protoc_insertion_point(destructor:SessionProtos.DataExtractionNotification) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -4646,85 +4804,58 @@ DataMessage_Quote::~DataMessage_Quote() { SharedDtor(); } -inline void DataMessage_Quote::SharedDtor() { +inline void DataExtractionNotification::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.attachments_.~RepeatedPtrField(); - _impl_.author_.Destroy(); - _impl_.text_.Destroy(); } -void DataMessage_Quote::SetCachedSize(int size) const { +void DataExtractionNotification::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Quote::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote) +void DataExtractionNotification::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataExtractionNotification) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.attachments_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _impl_.author_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.text_.ClearNonDefaultToEmpty(); - } + _impl_.timestamp_ = uint64_t{0u}; + _impl_.type_ = 1; } - _impl_.id_ = uint64_t{0u}; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint64 id = 1; + // required .SessionProtos.DataExtractionNotification.Type type = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_id(&has_bits); - _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataExtractionNotification_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::DataExtractionNotification_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // required string author = 2; + // optional uint64 timestamp = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_author(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string text = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_text(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_timestamp(&has_bits); + _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -4749,98 +4880,51 @@ const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseCont #undef CHK_ } -uint8_t* DataMessage_Quote::_InternalSerialize( +uint8_t* DataExtractionNotification::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataExtractionNotification) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint64 id = 1; - if (cached_has_bits & 0x00000004u) { + // required .SessionProtos.DataExtractionNotification.Type type = 1; + if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - // required string author = 2; + // optional uint64 timestamp = 2; if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_author(), target); - } - - // optional string text = 3; - if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_text(), target); - } - - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - for (unsigned i = 0, - n = static_cast(this->_internal_attachments_size()); i < n; i++) { - const auto& repfield = this->_internal_attachments(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_timestamp(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataExtractionNotification) return target; } -size_t DataMessage_Quote::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Quote) - size_t total_size = 0; - - if (_internal_has_author()) { - // required string author = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); - } - - if (_internal_has_id()) { - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - } - - return total_size; -} -size_t DataMessage_Quote::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote) +size_t DataExtractionNotification::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataExtractionNotification) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. - // required string author = 2; + // required .SessionProtos.DataExtractionNotification.Type type = 1; + if (_internal_has_type()) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); - - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - total_size += 1UL * this->_internal_attachments_size(); - for (const auto& msg : this->_impl_.attachments_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // optional string text = 3; + // optional uint64 timestamp = 2; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_text()); + if (cached_has_bits & 0x00000001u) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -4851,159 +4935,127 @@ size_t DataMessage_Quote::ByteSizeLong() const { return total_size; } -void DataMessage_Quote::CheckTypeAndMergeFrom( +void DataExtractionNotification::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_Quote::MergeFrom(const DataMessage_Quote& from) { - DataMessage_Quote* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote) +void DataExtractionNotification::MergeFrom(const DataExtractionNotification& from) { + DataExtractionNotification* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataExtractionNotification) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_author(from._internal_author()); + _this->_impl_.timestamp_ = from._impl_.timestamp_; } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_text(from._internal_text()); - } - if (cached_has_bits & 0x00000004u) { - _this->_impl_.id_ = from._impl_.id_; + _this->_impl_.type_ = from._impl_.type_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_Quote::CopyFrom(const DataMessage_Quote& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote) +void DataExtractionNotification::CopyFrom(const DataExtractionNotification& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataExtractionNotification) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Quote::IsInitialized() const { +bool DataExtractionNotification::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) - return false; return true; } -void DataMessage_Quote::InternalSwap(DataMessage_Quote* other) { +void DataExtractionNotification::InternalSwap(DataExtractionNotification* other) { using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.author_, lhs_arena, - &other->_impl_.author_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.text_, lhs_arena, - &other->_impl_.text_, rhs_arena - ); - swap(_impl_.id_, other->_impl_.id_); + swap(_impl_.timestamp_, other->_impl_.timestamp_); + swap(_impl_.type_, other->_impl_.type_); } -std::string DataMessage_Quote::GetTypeName() const { - return "SessionProtos.DataMessage.Quote"; +std::string DataExtractionNotification::GetTypeName() const { + return "SessionProtos.DataExtractionNotification"; } // =================================================================== -class DataMessage_Preview::_Internal { +class LokiProfile::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_url(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_displayname(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_title(HasBits* has_bits) { + static void set_has_profilepicture(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::AttachmentPointer& image(const DataMessage_Preview* msg); - static void set_has_image(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } }; -const ::SessionProtos::AttachmentPointer& -DataMessage_Preview::_Internal::image(const DataMessage_Preview* msg) { - return *msg->_impl_.image_; -} -DataMessage_Preview::DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, +LokiProfile::LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Preview) + // @@protoc_insertion_point(arena_constructor:SessionProtos.LokiProfile) } -DataMessage_Preview::DataMessage_Preview(const DataMessage_Preview& from) +LokiProfile::LokiProfile(const LokiProfile& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Preview* const _this = this; (void)_this; + LokiProfile* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.url_){} - , decltype(_impl_.title_){} - , decltype(_impl_.image_){nullptr}}; + , decltype(_impl_.displayname_){} + , decltype(_impl_.profilepicture_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.url_.InitDefault(); + _impl_.displayname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.displayname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_url()) { - _this->_impl_.url_.Set(from._internal_url(), + if (from._internal_has_displayname()) { + _this->_impl_.displayname_.Set(from._internal_displayname(), _this->GetArenaForAllocation()); } - _impl_.title_.InitDefault(); + _impl_.profilepicture_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.title_.Set("", GetArenaForAllocation()); + _impl_.profilepicture_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_title()) { - _this->_impl_.title_.Set(from._internal_title(), + if (from._internal_has_profilepicture()) { + _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), _this->GetArenaForAllocation()); } - if (from._internal_has_image()) { - _this->_impl_.image_ = new ::SessionProtos::AttachmentPointer(*from._impl_.image_); - } - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Preview) + // @@protoc_insertion_point(copy_constructor:SessionProtos.LokiProfile) } -inline void DataMessage_Preview::SharedCtor( +inline void LokiProfile::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.url_){} - , decltype(_impl_.title_){} - , decltype(_impl_.image_){nullptr} + , decltype(_impl_.displayname_){} + , decltype(_impl_.profilepicture_){} }; - _impl_.url_.InitDefault(); + _impl_.displayname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.displayname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.title_.InitDefault(); + _impl_.profilepicture_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.title_.Set("", GetArenaForAllocation()); + _impl_.profilepicture_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Preview::~DataMessage_Preview() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Preview) +LokiProfile::~LokiProfile() { + // @@protoc_insertion_point(destructor:SessionProtos.LokiProfile) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -5011,73 +5063,60 @@ DataMessage_Preview::~DataMessage_Preview() { SharedDtor(); } -inline void DataMessage_Preview::SharedDtor() { +inline void LokiProfile::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.url_.Destroy(); - _impl_.title_.Destroy(); - if (this != internal_default_instance()) delete _impl_.image_; + _impl_.displayname_.Destroy(); + _impl_.profilepicture_.Destroy(); } -void DataMessage_Preview::SetCachedSize(int size) const { +void LokiProfile::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Preview::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Preview) +void LokiProfile::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.LokiProfile) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.url_.ClearNonDefaultToEmpty(); + _impl_.displayname_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.title_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.image_ != nullptr); - _impl_.image_->Clear(); + _impl_.profilepicture_.ClearNonDefaultToEmpty(); } } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required string url = 1; + // optional string displayName = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_url(); + auto str = _internal_mutable_displayname(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional string title = 2; + // optional string profilePicture = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_title(); + auto str = _internal_mutable_profilepicture(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.AttachmentPointer image = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_image(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -5102,68 +5141,55 @@ const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseCo #undef CHK_ } -uint8_t* DataMessage_Preview::_InternalSerialize( +uint8_t* LokiProfile::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Preview) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.LokiProfile) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required string url = 1; + // optional string displayName = 1; if (cached_has_bits & 0x00000001u) { target = stream->WriteStringMaybeAliased( - 1, this->_internal_url(), target); + 1, this->_internal_displayname(), target); } - // optional string title = 2; + // optional string profilePicture = 2; if (cached_has_bits & 0x00000002u) { target = stream->WriteStringMaybeAliased( - 2, this->_internal_title(), target); - } - - // optional .SessionProtos.AttachmentPointer image = 3; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::image(this), - _Internal::image(this).GetCachedSize(), target, stream); + 2, this->_internal_profilepicture(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Preview) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.LokiProfile) return target; } -size_t DataMessage_Preview::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Preview) +size_t LokiProfile::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.LokiProfile) size_t total_size = 0; - // required string url = 1; - if (_internal_has_url()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000006u) { - // optional string title = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000003u) { + // optional string displayName = 1; + if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_title()); + this->_internal_displayname()); } - // optional .SessionProtos.AttachmentPointer image = 3; - if (cached_has_bits & 0x00000004u) { + // optional string profilePicture = 2; + if (cached_has_bits & 0x00000002u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.image_); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_profilepicture()); } } @@ -5175,158 +5201,152 @@ size_t DataMessage_Preview::ByteSizeLong() const { return total_size; } -void DataMessage_Preview::CheckTypeAndMergeFrom( +void LokiProfile::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_Preview::MergeFrom(const DataMessage_Preview& from) { - DataMessage_Preview* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Preview) +void LokiProfile::MergeFrom(const LokiProfile& from) { + LokiProfile* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.LokiProfile) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_url(from._internal_url()); + _this->_internal_set_displayname(from._internal_displayname()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_title(from._internal_title()); - } - if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_image()->::SessionProtos::AttachmentPointer::MergeFrom( - from._internal_image()); + _this->_internal_set_profilepicture(from._internal_profilepicture()); } } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_Preview::CopyFrom(const DataMessage_Preview& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Preview) +void LokiProfile::CopyFrom(const LokiProfile& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.LokiProfile) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Preview::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (_internal_has_image()) { - if (!_impl_.image_->IsInitialized()) return false; - } +bool LokiProfile::IsInitialized() const { return true; } -void DataMessage_Preview::InternalSwap(DataMessage_Preview* other) { +void LokiProfile::InternalSwap(LokiProfile* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.url_, lhs_arena, - &other->_impl_.url_, rhs_arena + &_impl_.displayname_, lhs_arena, + &other->_impl_.displayname_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.title_, lhs_arena, - &other->_impl_.title_, rhs_arena + &_impl_.profilepicture_, lhs_arena, + &other->_impl_.profilepicture_, rhs_arena ); - swap(_impl_.image_, other->_impl_.image_); } -std::string DataMessage_Preview::GetTypeName() const { - return "SessionProtos.DataMessage.Preview"; +std::string LokiProfile::GetTypeName() const { + return "SessionProtos.LokiProfile"; } // =================================================================== -class DataMessage_Reaction::_Internal { +class DataMessage_Quote_QuotedAttachment::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_id(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_author(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_contenttype(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_emoji(HasBits* has_bits) { + static void set_has_filename(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_action(HasBits* has_bits) { - (*has_bits)[0] |= 8u; + static const ::SessionProtos::AttachmentPointer& thumbnail(const DataMessage_Quote_QuotedAttachment* msg); + static void set_has_thumbnail(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x0000000d) ^ 0x0000000d) != 0; + static void set_has_flags(HasBits* has_bits) { + (*has_bits)[0] |= 8u; } }; -DataMessage_Reaction::DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::AttachmentPointer& +DataMessage_Quote_QuotedAttachment::_Internal::thumbnail(const DataMessage_Quote_QuotedAttachment* msg) { + return *msg->_impl_.thumbnail_; +} +DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) } -DataMessage_Reaction::DataMessage_Reaction(const DataMessage_Reaction& from) +DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Reaction* const _this = this; (void)_this; + DataMessage_Quote_QuotedAttachment* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.author_){} - , decltype(_impl_.emoji_){} - , decltype(_impl_.id_){} - , decltype(_impl_.action_){}}; + , decltype(_impl_.contenttype_){} + , decltype(_impl_.filename_){} + , decltype(_impl_.thumbnail_){nullptr} + , decltype(_impl_.flags_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.author_.InitDefault(); + _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); + _impl_.contenttype_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_author()) { - _this->_impl_.author_.Set(from._internal_author(), + if (from._internal_has_contenttype()) { + _this->_impl_.contenttype_.Set(from._internal_contenttype(), _this->GetArenaForAllocation()); } - _impl_.emoji_.InitDefault(); + _impl_.filename_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.emoji_.Set("", GetArenaForAllocation()); + _impl_.filename_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_emoji()) { - _this->_impl_.emoji_.Set(from._internal_emoji(), + if (from._internal_has_filename()) { + _this->_impl_.filename_.Set(from._internal_filename(), _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.id_, &from._impl_.id_, - static_cast(reinterpret_cast(&_impl_.action_) - - reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Reaction) + if (from._internal_has_thumbnail()) { + _this->_impl_.thumbnail_ = new ::SessionProtos::AttachmentPointer(*from._impl_.thumbnail_); + } + _this->_impl_.flags_ = from._impl_.flags_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) } -inline void DataMessage_Reaction::SharedCtor( +inline void DataMessage_Quote_QuotedAttachment::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.author_){} - , decltype(_impl_.emoji_){} - , decltype(_impl_.id_){uint64_t{0u}} - , decltype(_impl_.action_){0} + , decltype(_impl_.contenttype_){} + , decltype(_impl_.filename_){} + , decltype(_impl_.thumbnail_){nullptr} + , decltype(_impl_.flags_){0u} }; - _impl_.author_.InitDefault(); + _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); + _impl_.contenttype_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.emoji_.InitDefault(); + _impl_.filename_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.emoji_.Set("", GetArenaForAllocation()); + _impl_.filename_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Reaction::~DataMessage_Reaction() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Reaction) +DataMessage_Quote_QuotedAttachment::~DataMessage_Quote_QuotedAttachment() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote.QuotedAttachment) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -5334,84 +5354,80 @@ DataMessage_Reaction::~DataMessage_Reaction() { SharedDtor(); } -inline void DataMessage_Reaction::SharedDtor() { +inline void DataMessage_Quote_QuotedAttachment::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.author_.Destroy(); - _impl_.emoji_.Destroy(); + _impl_.contenttype_.Destroy(); + _impl_.filename_.Destroy(); + if (this != internal_default_instance()) delete _impl_.thumbnail_; } -void DataMessage_Reaction::SetCachedSize(int size) const { +void DataMessage_Quote_QuotedAttachment::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Reaction::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Reaction) +void DataMessage_Quote_QuotedAttachment::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote.QuotedAttachment) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _impl_.author_.ClearNonDefaultToEmpty(); + _impl_.contenttype_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.emoji_.ClearNonDefaultToEmpty(); + _impl_.filename_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + GOOGLE_DCHECK(_impl_.thumbnail_ != nullptr); + _impl_.thumbnail_->Clear(); } } - if (cached_has_bits & 0x0000000cu) { - ::memset(&_impl_.id_, 0, static_cast( - reinterpret_cast(&_impl_.action_) - - reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); - } + _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint64 id = 1; + // optional string contentType = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_id(&has_bits); - _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_contenttype(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required string author = 2; + // optional string fileName = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_author(); + auto str = _internal_mutable_filename(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional string emoji = 3; + // optional .SessionProtos.AttachmentPointer thumbnail = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_emoji(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_thumbnail(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // required .SessionProtos.DataMessage.Reaction.Action action = 4; + // optional uint32 flags = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_Reaction_Action_IsValid(val))) { - _internal_set_action(static_cast<::SessionProtos::DataMessage_Reaction_Action>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields()); - } + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); } else goto handle_unusual; continue; @@ -5439,102 +5455,83 @@ const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseC #undef CHK_ } -uint8_t* DataMessage_Reaction::_InternalSerialize( +uint8_t* DataMessage_Quote_QuotedAttachment::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote.QuotedAttachment) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint64 id = 1; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); - } - - // required string author = 2; + // optional string contentType = 1; if (cached_has_bits & 0x00000001u) { target = stream->WriteStringMaybeAliased( - 2, this->_internal_author(), target); + 1, this->_internal_contenttype(), target); } - // optional string emoji = 3; + // optional string fileName = 2; if (cached_has_bits & 0x00000002u) { target = stream->WriteStringMaybeAliased( - 3, this->_internal_emoji(), target); + 2, this->_internal_filename(), target); } - // required .SessionProtos.DataMessage.Reaction.Action action = 4; + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::thumbnail(this), + _Internal::thumbnail(this).GetCachedSize(), target, stream); + } + + // optional uint32 flags = 4; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 4, this->_internal_action(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote.QuotedAttachment) return target; } -size_t DataMessage_Reaction::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Reaction) - size_t total_size = 0; - - if (_internal_has_author()) { - // required string author = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); - } - - if (_internal_has_id()) { - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - } - - if (_internal_has_action()) { - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); - } - - return total_size; -} -size_t DataMessage_Reaction::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Reaction) +size_t DataMessage_Quote_QuotedAttachment::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote.QuotedAttachment) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x0000000d) ^ 0x0000000d) == 0) { // All required fields are present. - // required string author = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); - - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // optional string emoji = 3; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_emoji()); - } + if (cached_has_bits & 0x0000000fu) { + // optional string contentType = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_contenttype()); + } + + // optional string fileName = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_filename()); + } + + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.thumbnail_); + } + + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -5543,15 +5540,15 @@ size_t DataMessage_Reaction::ByteSizeLong() const { return total_size; } -void DataMessage_Reaction::CheckTypeAndMergeFrom( +void DataMessage_Quote_QuotedAttachment::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_Reaction::MergeFrom(const DataMessage_Reaction& from) { - DataMessage_Reaction* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Reaction) +void DataMessage_Quote_QuotedAttachment::MergeFrom(const DataMessage_Quote_QuotedAttachment& from) { + DataMessage_Quote_QuotedAttachment* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -5559,134 +5556,145 @@ void DataMessage_Reaction::MergeFrom(const DataMessage_Reaction& from) { cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_author(from._internal_author()); + _this->_internal_set_contenttype(from._internal_contenttype()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_emoji(from._internal_emoji()); + _this->_internal_set_filename(from._internal_filename()); } if (cached_has_bits & 0x00000004u) { - _this->_impl_.id_ = from._impl_.id_; + _this->_internal_mutable_thumbnail()->::SessionProtos::AttachmentPointer::MergeFrom( + from._internal_thumbnail()); } if (cached_has_bits & 0x00000008u) { - _this->_impl_.action_ = from._impl_.action_; + _this->_impl_.flags_ = from._impl_.flags_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_Reaction::CopyFrom(const DataMessage_Reaction& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Reaction) +void DataMessage_Quote_QuotedAttachment::CopyFrom(const DataMessage_Quote_QuotedAttachment& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Reaction::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool DataMessage_Quote_QuotedAttachment::IsInitialized() const { + if (_internal_has_thumbnail()) { + if (!_impl_.thumbnail_->IsInitialized()) return false; + } return true; } -void DataMessage_Reaction::InternalSwap(DataMessage_Reaction* other) { +void DataMessage_Quote_QuotedAttachment::InternalSwap(DataMessage_Quote_QuotedAttachment* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.author_, lhs_arena, - &other->_impl_.author_, rhs_arena + &_impl_.contenttype_, lhs_arena, + &other->_impl_.contenttype_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.emoji_, lhs_arena, - &other->_impl_.emoji_, rhs_arena + &_impl_.filename_, lhs_arena, + &other->_impl_.filename_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.action_) - + sizeof(DataMessage_Reaction::_impl_.action_) - - PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.id_)>( - reinterpret_cast(&_impl_.id_), - reinterpret_cast(&other->_impl_.id_)); + PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.flags_) + + sizeof(DataMessage_Quote_QuotedAttachment::_impl_.flags_) + - PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.thumbnail_)>( + reinterpret_cast(&_impl_.thumbnail_), + reinterpret_cast(&other->_impl_.thumbnail_)); } -std::string DataMessage_Reaction::GetTypeName() const { - return "SessionProtos.DataMessage.Reaction"; +std::string DataMessage_Quote_QuotedAttachment::GetTypeName() const { + return "SessionProtos.DataMessage.Quote.QuotedAttachment"; } // =================================================================== -class DataMessage_OpenGroupInvitation::_Internal { +class DataMessage_Quote::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_url(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_author(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_name(HasBits* has_bits) { + static void set_has_text(HasBits* has_bits) { (*has_bits)[0] |= 2u; } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; } }; -DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_Quote::DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.OpenGroupInvitation) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote) } -DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from) +DataMessage_Quote::DataMessage_Quote(const DataMessage_Quote& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_OpenGroupInvitation* const _this = this; (void)_this; + DataMessage_Quote* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.url_){} - , decltype(_impl_.name_){}}; + , decltype(_impl_.attachments_){from._impl_.attachments_} + , decltype(_impl_.author_){} + , decltype(_impl_.text_){} + , decltype(_impl_.id_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.url_.InitDefault(); + _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.author_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_url()) { - _this->_impl_.url_.Set(from._internal_url(), + if (from._internal_has_author()) { + _this->_impl_.author_.Set(from._internal_author(), _this->GetArenaForAllocation()); } - _impl_.name_.InitDefault(); + _impl_.text_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_.text_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_name()) { - _this->_impl_.name_.Set(from._internal_name(), + if (from._internal_has_text()) { + _this->_impl_.text_.Set(from._internal_text(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.OpenGroupInvitation) + _this->_impl_.id_ = from._impl_.id_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote) } -inline void DataMessage_OpenGroupInvitation::SharedCtor( +inline void DataMessage_Quote::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.url_){} - , decltype(_impl_.name_){} + , decltype(_impl_.attachments_){arena} + , decltype(_impl_.author_){} + , decltype(_impl_.text_){} + , decltype(_impl_.id_){uint64_t{0u}} }; - _impl_.url_.InitDefault(); + _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.author_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.InitDefault(); + _impl_.text_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_.text_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_OpenGroupInvitation::~DataMessage_OpenGroupInvitation() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.OpenGroupInvitation) +DataMessage_Quote::~DataMessage_Quote() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -5694,60 +5702,85 @@ DataMessage_OpenGroupInvitation::~DataMessage_OpenGroupInvitation() { SharedDtor(); } -inline void DataMessage_OpenGroupInvitation::SharedDtor() { +inline void DataMessage_Quote::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.url_.Destroy(); - _impl_.name_.Destroy(); + _impl_.attachments_.~RepeatedPtrField(); + _impl_.author_.Destroy(); + _impl_.text_.Destroy(); } -void DataMessage_OpenGroupInvitation::SetCachedSize(int size) const { +void DataMessage_Quote::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_OpenGroupInvitation::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.OpenGroupInvitation) +void DataMessage_Quote::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.attachments_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.url_.ClearNonDefaultToEmpty(); + _impl_.author_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.name_.ClearNonDefaultToEmpty(); + _impl_.text_.ClearNonDefaultToEmpty(); } } + _impl_.id_ = uint64_t{0u}; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required string url = 1; + // required uint64 id = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_url(); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _Internal::set_has_id(&has_bits); + _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required string author = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required string name = 3; + // optional string text = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_name(); + auto str = _internal_mutable_text(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -5772,67 +5805,77 @@ const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_ #undef CHK_ } -uint8_t* DataMessage_OpenGroupInvitation::_InternalSerialize( +uint8_t* DataMessage_Quote::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.OpenGroupInvitation) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required string url = 1; + // required uint64 id = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); + } + + // required string author = 2; if (cached_has_bits & 0x00000001u) { target = stream->WriteStringMaybeAliased( - 1, this->_internal_url(), target); + 2, this->_internal_author(), target); } - // required string name = 3; + // optional string text = 3; if (cached_has_bits & 0x00000002u) { target = stream->WriteStringMaybeAliased( - 3, this->_internal_name(), target); + 3, this->_internal_text(), target); + } + + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + for (unsigned i = 0, + n = static_cast(this->_internal_attachments_size()); i < n; i++) { + const auto& repfield = this->_internal_attachments(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.OpenGroupInvitation) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote) return target; } -size_t DataMessage_OpenGroupInvitation::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.OpenGroupInvitation) +size_t DataMessage_Quote::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Quote) size_t total_size = 0; - if (_internal_has_url()) { - // required string url = 1; + if (_internal_has_author()) { + // required string author = 2; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); + this->_internal_author()); } - if (_internal_has_name()) { - // required string name = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + if (_internal_has_id()) { + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); } return total_size; } -size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.OpenGroupInvitation) +size_t DataMessage_Quote::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string url = 1; + if (((_impl_._has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. + // required string author = 2; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); + this->_internal_author()); - // required string name = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -5841,6 +5884,21 @@ size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + total_size += 1UL * this->_internal_attachments_size(); + for (const auto& msg : this->_impl_.attachments_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // optional string text = 3; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_text()); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -5849,137 +5907,159 @@ size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { return total_size; } -void DataMessage_OpenGroupInvitation::CheckTypeAndMergeFrom( +void DataMessage_Quote::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_OpenGroupInvitation::MergeFrom(const DataMessage_OpenGroupInvitation& from) { - DataMessage_OpenGroupInvitation* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.OpenGroupInvitation) +void DataMessage_Quote::MergeFrom(const DataMessage_Quote& from) { + DataMessage_Quote* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; + _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_url(from._internal_url()); + _this->_internal_set_author(from._internal_author()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_name(from._internal_name()); + _this->_internal_set_text(from._internal_text()); + } + if (cached_has_bits & 0x00000004u) { + _this->_impl_.id_ = from._impl_.id_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_OpenGroupInvitation::CopyFrom(const DataMessage_OpenGroupInvitation& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.OpenGroupInvitation) +void DataMessage_Quote::CopyFrom(const DataMessage_Quote& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_OpenGroupInvitation::IsInitialized() const { +bool DataMessage_Quote::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) + return false; return true; } -void DataMessage_OpenGroupInvitation::InternalSwap(DataMessage_OpenGroupInvitation* other) { +void DataMessage_Quote::InternalSwap(DataMessage_Quote* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.url_, lhs_arena, - &other->_impl_.url_, rhs_arena + &_impl_.author_, lhs_arena, + &other->_impl_.author_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.name_, lhs_arena, - &other->_impl_.name_, rhs_arena + &_impl_.text_, lhs_arena, + &other->_impl_.text_, rhs_arena ); + swap(_impl_.id_, other->_impl_.id_); } -std::string DataMessage_OpenGroupInvitation::GetTypeName() const { - return "SessionProtos.DataMessage.OpenGroupInvitation"; +std::string DataMessage_Quote::GetTypeName() const { + return "SessionProtos.DataMessage.Quote"; } // =================================================================== -class DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_Internal { +class DataMessage_Preview::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_url(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_encryptedkeypair(HasBits* has_bits) { + static void set_has_title(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static const ::SessionProtos::AttachmentPointer& image(const DataMessage_Preview* msg); + static void set_has_image(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; } }; -DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::AttachmentPointer& +DataMessage_Preview::_Internal::image(const DataMessage_Preview* msg) { + return *msg->_impl_.image_; +} +DataMessage_Preview::DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Preview) } -DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) +DataMessage_Preview::DataMessage_Preview(const DataMessage_Preview& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_ClosedGroupControlMessage_KeyPairWrapper* const _this = this; (void)_this; + DataMessage_Preview* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.encryptedkeypair_){}}; + , decltype(_impl_.url_){} + , decltype(_impl_.title_){} + , decltype(_impl_.image_){nullptr}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), _this->GetArenaForAllocation()); } - _impl_.encryptedkeypair_.InitDefault(); + _impl_.title_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); + _impl_.title_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_encryptedkeypair()) { - _this->_impl_.encryptedkeypair_.Set(from._internal_encryptedkeypair(), + if (from._internal_has_title()) { + _this->_impl_.title_.Set(from._internal_title(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + if (from._internal_has_image()) { + _this->_impl_.image_ = new ::SessionProtos::AttachmentPointer(*from._impl_.image_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Preview) } -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SharedCtor( +inline void DataMessage_Preview::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.encryptedkeypair_){} + , decltype(_impl_.url_){} + , decltype(_impl_.title_){} + , decltype(_impl_.image_){nullptr} }; - _impl_.publickey_.InitDefault(); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.encryptedkeypair_.InitDefault(); + _impl_.title_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); + _impl_.title_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_ClosedGroupControlMessage_KeyPairWrapper::~DataMessage_ClosedGroupControlMessage_KeyPairWrapper() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +DataMessage_Preview::~DataMessage_Preview() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Preview) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -5987,60 +6067,73 @@ DataMessage_ClosedGroupControlMessage_KeyPairWrapper::~DataMessage_ClosedGroupCo SharedDtor(); } -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SharedDtor() { +inline void DataMessage_Preview::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.publickey_.Destroy(); - _impl_.encryptedkeypair_.Destroy(); + _impl_.url_.Destroy(); + _impl_.title_.Destroy(); + if (this != internal_default_instance()) delete _impl_.image_; } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SetCachedSize(int size) const { +void DataMessage_Preview::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +void DataMessage_Preview::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Preview) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + _impl_.url_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.encryptedkeypair_.ClearNonDefaultToEmpty(); + _impl_.title_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + GOOGLE_DCHECK(_impl_.image_ != nullptr); + _impl_.image_->Clear(); } } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes publicKey = 1; + // required string url = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); + auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes encryptedKeyPair = 2; + // optional string title = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_encryptedkeypair(); + auto str = _internal_mutable_title(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; + // optional .SessionProtos.AttachmentPointer image = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_image(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -6065,75 +6158,71 @@ const char* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalParse #undef CHK_ } -uint8_t* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalSerialize( +uint8_t* DataMessage_Preview::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Preview) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes publicKey = 1; + // required string url = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_url(), target); } - // required bytes encryptedKeyPair = 2; + // optional string title = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 2, this->_internal_encryptedkeypair(), target); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_title(), target); + } + + // optional .SessionProtos.AttachmentPointer image = 3; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::image(this), + _Internal::image(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Preview) return target; } -size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) - size_t total_size = 0; - - if (_internal_has_publickey()) { - // required bytes publicKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - } - - if (_internal_has_encryptedkeypair()) { - // required bytes encryptedKeyPair = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_encryptedkeypair()); - } - - return total_size; -} -size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +size_t DataMessage_Preview::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Preview) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes publicKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - - // required bytes encryptedKeyPair = 2; + // required string url = 1; + if (_internal_has_url()) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_encryptedkeypair()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000006u) { + // optional string title = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_title()); + } + + // optional .SessionProtos.AttachmentPointer image = 3; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.image_); + } + + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -6142,169 +6231,158 @@ size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::ByteSizeLong() cons return total_size; } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::CheckTypeAndMergeFrom( +void DataMessage_Preview::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::MergeFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { - DataMessage_ClosedGroupControlMessage_KeyPairWrapper* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +void DataMessage_Preview::MergeFrom(const DataMessage_Preview& from) { + DataMessage_Preview* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Preview) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_url(from._internal_url()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_encryptedkeypair(from._internal_encryptedkeypair()); + _this->_internal_set_title(from._internal_title()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_mutable_image()->::SessionProtos::AttachmentPointer::MergeFrom( + from._internal_image()); } } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::CopyFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +void DataMessage_Preview::CopyFrom(const DataMessage_Preview& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Preview) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::IsInitialized() const { +bool DataMessage_Preview::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (_internal_has_image()) { + if (!_impl_.image_->IsInitialized()) return false; + } return true; } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::InternalSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { +void DataMessage_Preview::InternalSwap(DataMessage_Preview* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.encryptedkeypair_, lhs_arena, - &other->_impl_.encryptedkeypair_, rhs_arena + &_impl_.title_, lhs_arena, + &other->_impl_.title_, rhs_arena ); + swap(_impl_.image_, other->_impl_.image_); } -std::string DataMessage_ClosedGroupControlMessage_KeyPairWrapper::GetTypeName() const { - return "SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper"; +std::string DataMessage_Preview::GetTypeName() const { + return "SessionProtos.DataMessage.Preview"; } // =================================================================== -class DataMessage_ClosedGroupControlMessage::_Internal { +class DataMessage_Reaction::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 16u; + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static void set_has_publickey(HasBits* has_bits) { + static void set_has_author(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_name(HasBits* has_bits) { + static void set_has_emoji(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::KeyPair& encryptionkeypair(const DataMessage_ClosedGroupControlMessage* msg); - static void set_has_encryptionkeypair(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_expirationtimer(HasBits* has_bits) { + static void set_has_action(HasBits* has_bits) { (*has_bits)[0] |= 8u; } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000010) ^ 0x00000010) != 0; + return ((has_bits[0] & 0x0000000d) ^ 0x0000000d) != 0; } }; -const ::SessionProtos::KeyPair& -DataMessage_ClosedGroupControlMessage::_Internal::encryptionkeypair(const DataMessage_ClosedGroupControlMessage* msg) { - return *msg->_impl_.encryptionkeypair_; -} -DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_Reaction::DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Reaction) } -DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage(const DataMessage_ClosedGroupControlMessage& from) +DataMessage_Reaction::DataMessage_Reaction(const DataMessage_Reaction& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_ClosedGroupControlMessage* const _this = this; (void)_this; + DataMessage_Reaction* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.members_){from._impl_.members_} - , decltype(_impl_.admins_){from._impl_.admins_} - , decltype(_impl_.wrappers_){from._impl_.wrappers_} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){} - , decltype(_impl_.type_){}}; + , decltype(_impl_.author_){} + , decltype(_impl_.emoji_){} + , decltype(_impl_.id_){} + , decltype(_impl_.action_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); + _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.author_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), + if (from._internal_has_author()) { + _this->_impl_.author_.Set(from._internal_author(), _this->GetArenaForAllocation()); } - _impl_.name_.InitDefault(); + _impl_.emoji_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_.emoji_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_name()) { - _this->_impl_.name_.Set(from._internal_name(), + if (from._internal_has_emoji()) { + _this->_impl_.emoji_.Set(from._internal_emoji(), _this->GetArenaForAllocation()); } - if (from._internal_has_encryptionkeypair()) { - _this->_impl_.encryptionkeypair_ = new ::SessionProtos::KeyPair(*from._impl_.encryptionkeypair_); - } - ::memcpy(&_impl_.expirationtimer_, &from._impl_.expirationtimer_, - static_cast(reinterpret_cast(&_impl_.type_) - - reinterpret_cast(&_impl_.expirationtimer_)) + sizeof(_impl_.type_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage) + ::memcpy(&_impl_.id_, &from._impl_.id_, + static_cast(reinterpret_cast(&_impl_.action_) - + reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Reaction) } -inline void DataMessage_ClosedGroupControlMessage::SharedCtor( +inline void DataMessage_Reaction::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.members_){arena} - , decltype(_impl_.admins_){arena} - , decltype(_impl_.wrappers_){arena} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){0u} - , decltype(_impl_.type_){1} + , decltype(_impl_.author_){} + , decltype(_impl_.emoji_){} + , decltype(_impl_.id_){uint64_t{0u}} + , decltype(_impl_.action_){0} }; - _impl_.publickey_.InitDefault(); + _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.author_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.InitDefault(); + _impl_.emoji_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_.emoji_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_ClosedGroupControlMessage::~DataMessage_ClosedGroupControlMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.ClosedGroupControlMessage) +DataMessage_Reaction::~DataMessage_Reaction() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Reaction) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -6312,143 +6390,84 @@ DataMessage_ClosedGroupControlMessage::~DataMessage_ClosedGroupControlMessage() SharedDtor(); } -inline void DataMessage_ClosedGroupControlMessage::SharedDtor() { +inline void DataMessage_Reaction::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.members_.~RepeatedPtrField(); - _impl_.admins_.~RepeatedPtrField(); - _impl_.wrappers_.~RepeatedPtrField(); - _impl_.publickey_.Destroy(); - _impl_.name_.Destroy(); - if (this != internal_default_instance()) delete _impl_.encryptionkeypair_; + _impl_.author_.Destroy(); + _impl_.emoji_.Destroy(); } -void DataMessage_ClosedGroupControlMessage::SetCachedSize(int size) const { +void DataMessage_Reaction::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_ClosedGroupControlMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +void DataMessage_Reaction::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Reaction) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.members_.Clear(); - _impl_.admins_.Clear(); - _impl_.wrappers_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + _impl_.author_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.encryptionkeypair_ != nullptr); - _impl_.encryptionkeypair_->Clear(); + _impl_.emoji_.ClearNonDefaultToEmpty(); } } - if (cached_has_bits & 0x00000018u) { - _impl_.expirationtimer_ = 0u; - _impl_.type_ = 1; + if (cached_has_bits & 0x0000000cu) { + ::memset(&_impl_.id_, 0, static_cast( + reinterpret_cast(&_impl_.action_) - + reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage_ClosedGroupControlMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; + // required uint64 id = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _Internal::set_has_id(&has_bits); + _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::DataMessage_ClosedGroupControlMessage_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } } else goto handle_unusual; continue; - // optional bytes publicKey = 2; + // required string author = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_publickey(); + auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional string name = 3; + // optional string emoji = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_name(); + auto str = _internal_mutable_emoji(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; + // required .SessionProtos.DataMessage.Reaction.Action action = 4; case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr = ctx->ParseMessage(_internal_mutable_encryptionkeypair(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated bytes members = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_members(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); - } else - goto handle_unusual; - continue; - // repeated bytes admins = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_admins(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); - } else - goto handle_unusual; - continue; - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_wrappers(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr)); - } else - goto handle_unusual; - continue; - // optional uint32 expirationTimer = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 64)) { - _Internal::set_has_expirationtimer(&has_bits); - _impl_.expirationtimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_Reaction_Action_IsValid(val))) { + _internal_set_action(static_cast<::SessionProtos::DataMessage_Reaction_Action>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; @@ -6476,138 +6495,102 @@ const char* DataMessage_ClosedGroupControlMessage::_InternalParse(const char* pt #undef CHK_ } -uint8_t* DataMessage_ClosedGroupControlMessage::_InternalSerialize( +uint8_t* DataMessage_Reaction::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Reaction) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; - if (cached_has_bits & 0x00000010u) { + // required uint64 id = 1; + if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); } - // optional bytes publicKey = 2; + // required string author = 2; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 2, this->_internal_publickey(), target); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_author(), target); } - // optional string name = 3; + // optional string emoji = 3; if (cached_has_bits & 0x00000002u) { target = stream->WriteStringMaybeAliased( - 3, this->_internal_name(), target); - } - - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, _Internal::encryptionkeypair(this), - _Internal::encryptionkeypair(this).GetCachedSize(), target, stream); - } - - // repeated bytes members = 5; - for (int i = 0, n = this->_internal_members_size(); i < n; i++) { - const auto& s = this->_internal_members(i); - target = stream->WriteBytes(5, s, target); - } - - // repeated bytes admins = 6; - for (int i = 0, n = this->_internal_admins_size(); i < n; i++) { - const auto& s = this->_internal_admins(i); - target = stream->WriteBytes(6, s, target); - } - - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - for (unsigned i = 0, - n = static_cast(this->_internal_wrappers_size()); i < n; i++) { - const auto& repfield = this->_internal_wrappers(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, repfield, repfield.GetCachedSize(), target, stream); + 3, this->_internal_emoji(), target); } - // optional uint32 expirationTimer = 8; + // required .SessionProtos.DataMessage.Reaction.Action action = 4; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_expirationtimer(), target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 4, this->_internal_action(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Reaction) return target; } -size_t DataMessage_ClosedGroupControlMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +size_t DataMessage_Reaction::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Reaction) size_t total_size = 0; - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; - if (_internal_has_type()) { + if (_internal_has_author()) { + // required string author = 2; total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_author()); } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - // repeated bytes members = 5; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.members_.size()); - for (int i = 0, n = _impl_.members_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - _impl_.members_.Get(i)); + if (_internal_has_id()) { + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); } - // repeated bytes admins = 6; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.admins_.size()); - for (int i = 0, n = _impl_.admins_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - _impl_.admins_.Get(i)); + if (_internal_has_action()) { + // required .SessionProtos.DataMessage.Reaction.Action action = 4; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); } - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - total_size += 1UL * this->_internal_wrappers_size(); - for (const auto& msg : this->_impl_.wrappers_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } + return total_size; +} +size_t DataMessage_Reaction::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Reaction) + size_t total_size = 0; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional bytes publicKey = 2; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - } + if (((_impl_._has_bits_[0] & 0x0000000d) ^ 0x0000000d) == 0) { // All required fields are present. + // required string author = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_author()); - // optional string name = 3; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - } + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.encryptionkeypair_); - } + // required .SessionProtos.DataMessage.Reaction.Action action = 4; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); - // optional uint32 expirationTimer = 8; - if (cached_has_bits & 0x00000008u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); - } + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + // optional string emoji = 3; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_emoji()); } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -6616,272 +6599,150 @@ size_t DataMessage_ClosedGroupControlMessage::ByteSizeLong() const { return total_size; } -void DataMessage_ClosedGroupControlMessage::CheckTypeAndMergeFrom( +void DataMessage_Reaction::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage_ClosedGroupControlMessage::MergeFrom(const DataMessage_ClosedGroupControlMessage& from) { - DataMessage_ClosedGroupControlMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +void DataMessage_Reaction::MergeFrom(const DataMessage_Reaction& from) { + DataMessage_Reaction* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Reaction) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.members_.MergeFrom(from._impl_.members_); - _this->_impl_.admins_.MergeFrom(from._impl_.admins_); - _this->_impl_.wrappers_.MergeFrom(from._impl_.wrappers_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_author(from._internal_author()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_name(from._internal_name()); + _this->_internal_set_emoji(from._internal_emoji()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_encryptionkeypair()->::SessionProtos::KeyPair::MergeFrom( - from._internal_encryptionkeypair()); + _this->_impl_.id_ = from._impl_.id_; } if (cached_has_bits & 0x00000008u) { - _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; - } - if (cached_has_bits & 0x00000010u) { - _this->_impl_.type_ = from._impl_.type_; + _this->_impl_.action_ = from._impl_.action_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage_ClosedGroupControlMessage::CopyFrom(const DataMessage_ClosedGroupControlMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +void DataMessage_Reaction::CopyFrom(const DataMessage_Reaction& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Reaction) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_ClosedGroupControlMessage::IsInitialized() const { +bool DataMessage_Reaction::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.wrappers_)) - return false; - if (_internal_has_encryptionkeypair()) { - if (!_impl_.encryptionkeypair_->IsInitialized()) return false; - } return true; } -void DataMessage_ClosedGroupControlMessage::InternalSwap(DataMessage_ClosedGroupControlMessage* other) { +void DataMessage_Reaction::InternalSwap(DataMessage_Reaction* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.members_.InternalSwap(&other->_impl_.members_); - _impl_.admins_.InternalSwap(&other->_impl_.admins_); - _impl_.wrappers_.InternalSwap(&other->_impl_.wrappers_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena + &_impl_.author_, lhs_arena, + &other->_impl_.author_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.name_, lhs_arena, - &other->_impl_.name_, rhs_arena + &_impl_.emoji_, lhs_arena, + &other->_impl_.emoji_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage_ClosedGroupControlMessage, _impl_.expirationtimer_) - + sizeof(DataMessage_ClosedGroupControlMessage::_impl_.expirationtimer_) - - PROTOBUF_FIELD_OFFSET(DataMessage_ClosedGroupControlMessage, _impl_.encryptionkeypair_)>( - reinterpret_cast(&_impl_.encryptionkeypair_), - reinterpret_cast(&other->_impl_.encryptionkeypair_)); - swap(_impl_.type_, other->_impl_.type_); + PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.action_) + + sizeof(DataMessage_Reaction::_impl_.action_) + - PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.id_)>( + reinterpret_cast(&_impl_.id_), + reinterpret_cast(&other->_impl_.id_)); } -std::string DataMessage_ClosedGroupControlMessage::GetTypeName() const { - return "SessionProtos.DataMessage.ClosedGroupControlMessage"; +std::string DataMessage_Reaction::GetTypeName() const { + return "SessionProtos.DataMessage.Reaction"; } // =================================================================== -class DataMessage::_Internal { +class DataMessage_OpenGroupInvitation::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_body(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_url(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_flags(HasBits* has_bits) { - (*has_bits)[0] |= 256u; - } - static void set_has_expiretimer(HasBits* has_bits) { - (*has_bits)[0] |= 512u; - } - static void set_has_profilekey(HasBits* has_bits) { + static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_timestamp(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; - } - static const ::SessionProtos::DataMessage_Quote& quote(const DataMessage* msg); - static void set_has_quote(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static const ::SessionProtos::DataMessage_Reaction& reaction(const DataMessage* msg); - static void set_has_reaction(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static const ::SessionProtos::LokiProfile& profile(const DataMessage* msg); - static void set_has_profile(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation(const DataMessage* msg); - static void set_has_opengroupinvitation(HasBits* has_bits) { - (*has_bits)[0] |= 64u; - } - static const ::SessionProtos::DataMessage_ClosedGroupControlMessage& closedgroupcontrolmessage(const DataMessage* msg); - static void set_has_closedgroupcontrolmessage(HasBits* has_bits) { - (*has_bits)[0] |= 128u; - } - static void set_has_synctarget(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_blockscommunitymessagerequests(HasBits* has_bits) { - (*has_bits)[0] |= 2048u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -const ::SessionProtos::DataMessage_Quote& -DataMessage::_Internal::quote(const DataMessage* msg) { - return *msg->_impl_.quote_; -} -const ::SessionProtos::DataMessage_Reaction& -DataMessage::_Internal::reaction(const DataMessage* msg) { - return *msg->_impl_.reaction_; -} -const ::SessionProtos::LokiProfile& -DataMessage::_Internal::profile(const DataMessage* msg) { - return *msg->_impl_.profile_; -} -const ::SessionProtos::DataMessage_OpenGroupInvitation& -DataMessage::_Internal::opengroupinvitation(const DataMessage* msg) { - return *msg->_impl_.opengroupinvitation_; -} -const ::SessionProtos::DataMessage_ClosedGroupControlMessage& -DataMessage::_Internal::closedgroupcontrolmessage(const DataMessage* msg) { - return *msg->_impl_.closedgroupcontrolmessage_; -} -DataMessage::DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.OpenGroupInvitation) } -DataMessage::DataMessage(const DataMessage& from) +DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage* const _this = this; (void)_this; + DataMessage_OpenGroupInvitation* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){from._impl_.attachments_} - , decltype(_impl_.preview_){from._impl_.preview_} - , decltype(_impl_.body_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.synctarget_){} - , decltype(_impl_.quote_){nullptr} - , decltype(_impl_.reaction_){nullptr} - , decltype(_impl_.profile_){nullptr} - , decltype(_impl_.opengroupinvitation_){nullptr} - , decltype(_impl_.closedgroupcontrolmessage_){nullptr} - , decltype(_impl_.flags_){} - , decltype(_impl_.expiretimer_){} - , decltype(_impl_.timestamp_){} - , decltype(_impl_.blockscommunitymessagerequests_){}}; + , decltype(_impl_.url_){} + , decltype(_impl_.name_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.body_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.body_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_body()) { - _this->_impl_.body_.Set(from._internal_body(), - _this->GetArenaForAllocation()); - } - _impl_.profilekey_.InitDefault(); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilekey()) { - _this->_impl_.profilekey_.Set(from._internal_profilekey(), + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), _this->GetArenaForAllocation()); } - _impl_.synctarget_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.synctarget_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_synctarget()) { - _this->_impl_.synctarget_.Set(from._internal_synctarget(), + if (from._internal_has_name()) { + _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation()); } - if (from._internal_has_quote()) { - _this->_impl_.quote_ = new ::SessionProtos::DataMessage_Quote(*from._impl_.quote_); - } - if (from._internal_has_reaction()) { - _this->_impl_.reaction_ = new ::SessionProtos::DataMessage_Reaction(*from._impl_.reaction_); - } - if (from._internal_has_profile()) { - _this->_impl_.profile_ = new ::SessionProtos::LokiProfile(*from._impl_.profile_); - } - if (from._internal_has_opengroupinvitation()) { - _this->_impl_.opengroupinvitation_ = new ::SessionProtos::DataMessage_OpenGroupInvitation(*from._impl_.opengroupinvitation_); - } - if (from._internal_has_closedgroupcontrolmessage()) { - _this->_impl_.closedgroupcontrolmessage_ = new ::SessionProtos::DataMessage_ClosedGroupControlMessage(*from._impl_.closedgroupcontrolmessage_); - } - ::memcpy(&_impl_.flags_, &from._impl_.flags_, - static_cast(reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - - reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.blockscommunitymessagerequests_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage) + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.OpenGroupInvitation) } -inline void DataMessage::SharedCtor( +inline void DataMessage_OpenGroupInvitation::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){arena} - , decltype(_impl_.preview_){arena} - , decltype(_impl_.body_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.synctarget_){} - , decltype(_impl_.quote_){nullptr} - , decltype(_impl_.reaction_){nullptr} - , decltype(_impl_.profile_){nullptr} - , decltype(_impl_.opengroupinvitation_){nullptr} - , decltype(_impl_.closedgroupcontrolmessage_){nullptr} - , decltype(_impl_.flags_){0u} - , decltype(_impl_.expiretimer_){0u} - , decltype(_impl_.timestamp_){uint64_t{0u}} - , decltype(_impl_.blockscommunitymessagerequests_){false} + , decltype(_impl_.url_){} + , decltype(_impl_.name_){} }; - _impl_.body_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.body_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.InitDefault(); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.synctarget_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.synctarget_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage::~DataMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage) +DataMessage_OpenGroupInvitation::~DataMessage_OpenGroupInvitation() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.OpenGroupInvitation) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -6889,209 +6750,60 @@ DataMessage::~DataMessage() { SharedDtor(); } -inline void DataMessage::SharedDtor() { +inline void DataMessage_OpenGroupInvitation::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.attachments_.~RepeatedPtrField(); - _impl_.preview_.~RepeatedPtrField(); - _impl_.body_.Destroy(); - _impl_.profilekey_.Destroy(); - _impl_.synctarget_.Destroy(); - if (this != internal_default_instance()) delete _impl_.quote_; - if (this != internal_default_instance()) delete _impl_.reaction_; - if (this != internal_default_instance()) delete _impl_.profile_; - if (this != internal_default_instance()) delete _impl_.opengroupinvitation_; - if (this != internal_default_instance()) delete _impl_.closedgroupcontrolmessage_; + _impl_.url_.Destroy(); + _impl_.name_.Destroy(); } -void DataMessage::SetCachedSize(int size) const { +void DataMessage_OpenGroupInvitation::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage) +void DataMessage_OpenGroupInvitation::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.OpenGroupInvitation) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.attachments_.Clear(); - _impl_.preview_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.body_.ClearNonDefaultToEmpty(); + _impl_.url_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.profilekey_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - _impl_.synctarget_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(_impl_.quote_ != nullptr); - _impl_.quote_->Clear(); - } - if (cached_has_bits & 0x00000010u) { - GOOGLE_DCHECK(_impl_.reaction_ != nullptr); - _impl_.reaction_->Clear(); + _impl_.name_.ClearNonDefaultToEmpty(); } - if (cached_has_bits & 0x00000020u) { - GOOGLE_DCHECK(_impl_.profile_ != nullptr); - _impl_.profile_->Clear(); - } - if (cached_has_bits & 0x00000040u) { - GOOGLE_DCHECK(_impl_.opengroupinvitation_ != nullptr); - _impl_.opengroupinvitation_->Clear(); - } - if (cached_has_bits & 0x00000080u) { - GOOGLE_DCHECK(_impl_.closedgroupcontrolmessage_ != nullptr); - _impl_.closedgroupcontrolmessage_->Clear(); - } - } - if (cached_has_bits & 0x00000f00u) { - ::memset(&_impl_.flags_, 0, static_cast( - reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - - reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.blockscommunitymessagerequests_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional string body = 1; + // required string url = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_body(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated .SessionProtos.AttachmentPointer attachments = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else - goto handle_unusual; - continue; - // optional uint32 flags = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 expireTimer = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { - _Internal::set_has_expiretimer(&has_bits); - _impl_.expiretimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bytes profileKey = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - auto str = _internal_mutable_profilekey(); + auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional uint64 timestamp = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { - _Internal::set_has_timestamp(&has_bits); - _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.Quote quote = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { - ptr = ctx->ParseMessage(_internal_mutable_quote(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated .SessionProtos.DataMessage.Preview preview = 10; - case 10: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_preview(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr)); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { - ptr = ctx->ParseMessage(_internal_mutable_reaction(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.LokiProfile profile = 101; - case 101: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr = ctx->ParseMessage(_internal_mutable_profile(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - case 102: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr = ctx->ParseMessage(_internal_mutable_opengroupinvitation(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - case 104: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { - ptr = ctx->ParseMessage(_internal_mutable_closedgroupcontrolmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string syncTarget = 105; - case 105: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { - auto str = _internal_mutable_synctarget(); + // required string name = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional bool blocksCommunityMessageRequests = 106; - case 106: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 80)) { - _Internal::set_has_blockscommunitymessagerequests(&has_bits); - _impl_.blockscommunitymessagerequests_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -7116,217 +6828,368 @@ const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c #undef CHK_ } -uint8_t* DataMessage::_InternalSerialize( +uint8_t* DataMessage_OpenGroupInvitation::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.OpenGroupInvitation) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional string body = 1; + // required string url = 1; if (cached_has_bits & 0x00000001u) { target = stream->WriteStringMaybeAliased( - 1, this->_internal_body(), target); + 1, this->_internal_url(), target); } - // repeated .SessionProtos.AttachmentPointer attachments = 2; - for (unsigned i = 0, - n = static_cast(this->_internal_attachments_size()); i < n; i++) { - const auto& repfield = this->_internal_attachments(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); + // required string name = 3; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteStringMaybeAliased( + 3, this->_internal_name(), target); } - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000100u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.OpenGroupInvitation) + return target; +} - // optional uint32 expireTimer = 5; - if (cached_has_bits & 0x00000200u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(5, this->_internal_expiretimer(), target); - } +size_t DataMessage_OpenGroupInvitation::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.OpenGroupInvitation) + size_t total_size = 0; - // optional bytes profileKey = 6; - if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 6, this->_internal_profilekey(), target); + if (_internal_has_url()) { + // required string url = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); } - // optional uint64 timestamp = 7; - if (cached_has_bits & 0x00000400u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(7, this->_internal_timestamp(), target); + if (_internal_has_name()) { + // required string name = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } - // optional .SessionProtos.DataMessage.Quote quote = 8; - if (cached_has_bits & 0x00000008u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(8, _Internal::quote(this), - _Internal::quote(this).GetCachedSize(), target, stream); - } + return total_size; +} +size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.OpenGroupInvitation) + size_t total_size = 0; - // repeated .SessionProtos.DataMessage.Preview preview = 10; - for (unsigned i = 0, - n = static_cast(this->_internal_preview_size()); i < n; i++) { - const auto& repfield = this->_internal_preview(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(10, repfield, repfield.GetCachedSize(), target, stream); - } + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string url = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - if (cached_has_bits & 0x00000010u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(11, _Internal::reaction(this), - _Internal::reaction(this).GetCachedSize(), target, stream); - } + // required string name = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); - // optional .SessionProtos.LokiProfile profile = 101; - if (cached_has_bits & 0x00000020u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(101, _Internal::profile(this), - _Internal::profile(this).GetCachedSize(), target, stream); + } else { + total_size += RequiredFieldsByteSizeFallback(); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - if (cached_has_bits & 0x00000040u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(102, _Internal::opengroupinvitation(this), - _Internal::opengroupinvitation(this).GetCachedSize(), target, stream); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - if (cached_has_bits & 0x00000080u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(104, _Internal::closedgroupcontrolmessage(this), - _Internal::closedgroupcontrolmessage(this).GetCachedSize(), target, stream); - } +void DataMessage_OpenGroupInvitation::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} - // optional string syncTarget = 105; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteStringMaybeAliased( - 105, this->_internal_synctarget(), target); +void DataMessage_OpenGroupInvitation::MergeFrom(const DataMessage_OpenGroupInvitation& from) { + DataMessage_OpenGroupInvitation* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.OpenGroupInvitation) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_url(from._internal_url()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_name(from._internal_name()); + } } + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} - // optional bool blocksCommunityMessageRequests = 106; - if (cached_has_bits & 0x00000800u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(106, this->_internal_blockscommunitymessagerequests(), target); +void DataMessage_OpenGroupInvitation::CopyFrom(const DataMessage_OpenGroupInvitation& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.OpenGroupInvitation) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool DataMessage_OpenGroupInvitation::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + return true; +} + +void DataMessage_OpenGroupInvitation::InternalSwap(DataMessage_OpenGroupInvitation* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena + ); +} + +std::string DataMessage_OpenGroupInvitation::GetTypeName() const { + return "SessionProtos.DataMessage.OpenGroupInvitation"; +} + + +// =================================================================== + +class DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_publickey(HasBits* has_bits) { + (*has_bits)[0] |= 1u; } + static void set_has_encryptedkeypair(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); +DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +} +DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + DataMessage_ClosedGroupControlMessage_KeyPairWrapper* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.publickey_){} + , decltype(_impl_.encryptedkeypair_){}}; + + _internal_metadata_.MergeFrom(from._internal_metadata_); + _impl_.publickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.publickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_publickey()) { + _this->_impl_.publickey_.Set(from._internal_publickey(), + _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage) - return target; + _impl_.encryptedkeypair_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_encryptedkeypair()) { + _this->_impl_.encryptedkeypair_.Set(from._internal_encryptedkeypair(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) } -size_t DataMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage) - size_t total_size = 0; +inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.publickey_){} + , decltype(_impl_.encryptedkeypair_){} + }; + _impl_.publickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.publickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.encryptedkeypair_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +DataMessage_ClosedGroupControlMessage_KeyPairWrapper::~DataMessage_ClosedGroupControlMessage_KeyPairWrapper() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.publickey_.Destroy(); + _impl_.encryptedkeypair_.Destroy(); +} +void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated .SessionProtos.AttachmentPointer attachments = 2; - total_size += 1UL * this->_internal_attachments_size(); - for (const auto& msg : this->_impl_.attachments_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .SessionProtos.DataMessage.Preview preview = 10; - total_size += 1UL * this->_internal_preview_size(); - for (const auto& msg : this->_impl_.preview_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - // optional string body = 1; + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_body()); + _impl_.publickey_.ClearNonDefaultToEmpty(); } - - // optional bytes profileKey = 6; if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_profilekey()); + _impl_.encryptedkeypair_.ClearNonDefaultToEmpty(); } + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear(); +} - // optional string syncTarget = 105; - if (cached_has_bits & 0x00000004u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_synctarget()); +const char* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required bytes publicKey = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_publickey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bytes encryptedKeyPair = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_encryptedkeypair(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} - // optional .SessionProtos.DataMessage.Quote quote = 8; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.quote_); - } +uint8_t* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.reaction_); - } + cached_has_bits = _impl_._has_bits_[0]; + // required bytes publicKey = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteBytesMaybeAliased( + 1, this->_internal_publickey(), target); + } - // optional .SessionProtos.LokiProfile profile = 101; - if (cached_has_bits & 0x00000020u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.profile_); - } + // required bytes encryptedKeyPair = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_encryptedkeypair(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + return target; +} - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - if (cached_has_bits & 0x00000040u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.opengroupinvitation_); - } +size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + size_t total_size = 0; - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - if (cached_has_bits & 0x00000080u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.closedgroupcontrolmessage_); - } + if (_internal_has_publickey()) { + // required bytes publicKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); + } + if (_internal_has_encryptedkeypair()) { + // required bytes encryptedKeyPair = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_encryptedkeypair()); } - if (cached_has_bits & 0x00000f00u) { - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000100u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - } - // optional uint32 expireTimer = 5; - if (cached_has_bits & 0x00000200u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expiretimer()); - } + return total_size; +} +size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + size_t total_size = 0; - // optional uint64 timestamp = 7; - if (cached_has_bits & 0x00000400u) { - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); - } + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required bytes publicKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); - // optional bool blocksCommunityMessageRequests = 106; - if (cached_has_bits & 0x00000800u) { - total_size += 2 + 1; - } + // required bytes encryptedKeyPair = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_encryptedkeypair()); + } else { + total_size += RequiredFieldsByteSizeFallback(); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -7335,173 +7198,114 @@ size_t DataMessage::ByteSizeLong() const { return total_size; } -void DataMessage::CheckTypeAndMergeFrom( +void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void DataMessage::MergeFrom(const DataMessage& from) { - DataMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage) +void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::MergeFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { + DataMessage_ClosedGroupControlMessage_KeyPairWrapper* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); - _this->_impl_.preview_.MergeFrom(from._impl_.preview_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_body(from._internal_body()); + _this->_internal_set_publickey(from._internal_publickey()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_profilekey(from._internal_profilekey()); - } - if (cached_has_bits & 0x00000004u) { - _this->_internal_set_synctarget(from._internal_synctarget()); - } - if (cached_has_bits & 0x00000008u) { - _this->_internal_mutable_quote()->::SessionProtos::DataMessage_Quote::MergeFrom( - from._internal_quote()); - } - if (cached_has_bits & 0x00000010u) { - _this->_internal_mutable_reaction()->::SessionProtos::DataMessage_Reaction::MergeFrom( - from._internal_reaction()); - } - if (cached_has_bits & 0x00000020u) { - _this->_internal_mutable_profile()->::SessionProtos::LokiProfile::MergeFrom( - from._internal_profile()); - } - if (cached_has_bits & 0x00000040u) { - _this->_internal_mutable_opengroupinvitation()->::SessionProtos::DataMessage_OpenGroupInvitation::MergeFrom( - from._internal_opengroupinvitation()); - } - if (cached_has_bits & 0x00000080u) { - _this->_internal_mutable_closedgroupcontrolmessage()->::SessionProtos::DataMessage_ClosedGroupControlMessage::MergeFrom( - from._internal_closedgroupcontrolmessage()); - } - } - if (cached_has_bits & 0x00000f00u) { - if (cached_has_bits & 0x00000100u) { - _this->_impl_.flags_ = from._impl_.flags_; - } - if (cached_has_bits & 0x00000200u) { - _this->_impl_.expiretimer_ = from._impl_.expiretimer_; - } - if (cached_has_bits & 0x00000400u) { - _this->_impl_.timestamp_ = from._impl_.timestamp_; - } - if (cached_has_bits & 0x00000800u) { - _this->_impl_.blockscommunitymessagerequests_ = from._impl_.blockscommunitymessagerequests_; + _this->_internal_set_encryptedkeypair(from._internal_encryptedkeypair()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void DataMessage::CopyFrom(const DataMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage) +void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::CopyFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) - return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.preview_)) - return false; - if (_internal_has_quote()) { - if (!_impl_.quote_->IsInitialized()) return false; - } - if (_internal_has_reaction()) { - if (!_impl_.reaction_->IsInitialized()) return false; - } - if (_internal_has_opengroupinvitation()) { - if (!_impl_.opengroupinvitation_->IsInitialized()) return false; - } - if (_internal_has_closedgroupcontrolmessage()) { - if (!_impl_.closedgroupcontrolmessage_->IsInitialized()) return false; - } +bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage::InternalSwap(DataMessage* other) { +void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::InternalSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); - _impl_.preview_.InternalSwap(&other->_impl_.preview_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.body_, lhs_arena, - &other->_impl_.body_, rhs_arena - ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilekey_, lhs_arena, - &other->_impl_.profilekey_, rhs_arena + &_impl_.publickey_, lhs_arena, + &other->_impl_.publickey_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.synctarget_, lhs_arena, - &other->_impl_.synctarget_, rhs_arena + &_impl_.encryptedkeypair_, lhs_arena, + &other->_impl_.encryptedkeypair_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.blockscommunitymessagerequests_) - + sizeof(DataMessage::_impl_.blockscommunitymessagerequests_) - - PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.quote_)>( - reinterpret_cast(&_impl_.quote_), - reinterpret_cast(&other->_impl_.quote_)); } -std::string DataMessage::GetTypeName() const { - return "SessionProtos.DataMessage"; +std::string DataMessage_ClosedGroupControlMessage_KeyPairWrapper::GetTypeName() const { + return "SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper"; } // =================================================================== -class ConfigurationMessage_ClosedGroup::_Internal { +class DataMessage_ClosedGroupControlMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } static void set_has_publickey(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::KeyPair& encryptionkeypair(const ConfigurationMessage_ClosedGroup* msg); + static const ::SessionProtos::KeyPair& encryptionkeypair(const DataMessage_ClosedGroupControlMessage* msg); static void set_has_encryptionkeypair(HasBits* has_bits) { (*has_bits)[0] |= 4u; } static void set_has_expirationtimer(HasBits* has_bits) { (*has_bits)[0] |= 8u; } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000010) ^ 0x00000010) != 0; + } }; const ::SessionProtos::KeyPair& -ConfigurationMessage_ClosedGroup::_Internal::encryptionkeypair(const ConfigurationMessage_ClosedGroup* msg) { +DataMessage_ClosedGroupControlMessage::_Internal::encryptionkeypair(const DataMessage_ClosedGroupControlMessage* msg) { return *msg->_impl_.encryptionkeypair_; } -ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage) } -ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(const ConfigurationMessage_ClosedGroup& from) +DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage(const DataMessage_ClosedGroupControlMessage& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage_ClosedGroup* const _this = this; (void)_this; + DataMessage_ClosedGroupControlMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.members_){from._impl_.members_} , decltype(_impl_.admins_){from._impl_.admins_} + , decltype(_impl_.wrappers_){from._impl_.wrappers_} , decltype(_impl_.publickey_){} , decltype(_impl_.name_){} , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){}}; + , decltype(_impl_.expirationtimer_){} + , decltype(_impl_.type_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.publickey_.InitDefault(); @@ -7523,11 +7327,13 @@ ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(const Configu if (from._internal_has_encryptionkeypair()) { _this->_impl_.encryptionkeypair_ = new ::SessionProtos::KeyPair(*from._impl_.encryptionkeypair_); } - _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.ClosedGroup) + ::memcpy(&_impl_.expirationtimer_, &from._impl_.expirationtimer_, + static_cast(reinterpret_cast(&_impl_.type_) - + reinterpret_cast(&_impl_.expirationtimer_)) + sizeof(_impl_.type_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage) } -inline void ConfigurationMessage_ClosedGroup::SharedCtor( +inline void DataMessage_ClosedGroupControlMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; @@ -7536,10 +7342,12 @@ inline void ConfigurationMessage_ClosedGroup::SharedCtor( , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.members_){arena} , decltype(_impl_.admins_){arena} + , decltype(_impl_.wrappers_){arena} , decltype(_impl_.publickey_){} , decltype(_impl_.name_){} , decltype(_impl_.encryptionkeypair_){nullptr} , decltype(_impl_.expirationtimer_){0u} + , decltype(_impl_.type_){1} }; _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -7551,8 +7359,8 @@ inline void ConfigurationMessage_ClosedGroup::SharedCtor( #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage_ClosedGroup::~ConfigurationMessage_ClosedGroup() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.ClosedGroup) +DataMessage_ClosedGroupControlMessage::~DataMessage_ClosedGroupControlMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.ClosedGroupControlMessage) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -7560,27 +7368,29 @@ ConfigurationMessage_ClosedGroup::~ConfigurationMessage_ClosedGroup() { SharedDtor(); } -inline void ConfigurationMessage_ClosedGroup::SharedDtor() { +inline void DataMessage_ClosedGroupControlMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); _impl_.members_.~RepeatedPtrField(); _impl_.admins_.~RepeatedPtrField(); + _impl_.wrappers_.~RepeatedPtrField(); _impl_.publickey_.Destroy(); _impl_.name_.Destroy(); if (this != internal_default_instance()) delete _impl_.encryptionkeypair_; } -void ConfigurationMessage_ClosedGroup::SetCachedSize(int size) const { +void DataMessage_ClosedGroupControlMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage_ClosedGroup::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.ClosedGroup) +void DataMessage_ClosedGroupControlMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.ClosedGroupControlMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; _impl_.members_.Clear(); _impl_.admins_.Clear(); + _impl_.wrappers_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { @@ -7594,47 +7404,63 @@ void ConfigurationMessage_ClosedGroup::Clear() { _impl_.encryptionkeypair_->Clear(); } } - _impl_.expirationtimer_ = 0u; + if (cached_has_bits & 0x00000018u) { + _impl_.expirationtimer_ = 0u; + _impl_.type_ = 1; + } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_ClosedGroupControlMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional bytes publicKey = 1; + // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::DataMessage_ClosedGroupControlMessage_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // optional string name = 2; + // optional bytes publicKey = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_name(); + auto str = _internal_mutable_publickey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; + // optional string name = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_encryptionkeypair(), ptr); + auto str = _internal_mutable_name(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // repeated bytes members = 4; + // optional .SessionProtos.KeyPair encryptionKeyPair = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + ptr = ctx->ParseMessage(_internal_mutable_encryptionkeypair(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // repeated bytes members = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { ptr -= 1; do { ptr += 1; @@ -7642,13 +7468,13 @@ const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, :: ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); } else goto handle_unusual; continue; - // repeated bytes admins = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + // repeated bytes admins = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { ptr -= 1; do { ptr += 1; @@ -7656,13 +7482,26 @@ const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, :: ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; - // optional uint32 expirationTimer = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { + // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_wrappers(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr)); + } else + goto handle_unusual; + continue; + // optional uint32 expirationTimer = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 64)) { _Internal::set_has_expirationtimer(&has_bits); _impl_.expirationtimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); @@ -7693,67 +7532,87 @@ const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, :: #undef CHK_ } -uint8_t* ConfigurationMessage_ClosedGroup::_InternalSerialize( +uint8_t* DataMessage_ClosedGroupControlMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.ClosedGroupControlMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional bytes publicKey = 1; + // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); + } + + // optional bytes publicKey = 2; if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + 2, this->_internal_publickey(), target); } - // optional string name = 2; + // optional string name = 3; if (cached_has_bits & 0x00000002u) { target = stream->WriteStringMaybeAliased( - 2, this->_internal_name(), target); + 3, this->_internal_name(), target); } - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; + // optional .SessionProtos.KeyPair encryptionKeyPair = 4; if (cached_has_bits & 0x00000004u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::encryptionkeypair(this), + InternalWriteMessage(4, _Internal::encryptionkeypair(this), _Internal::encryptionkeypair(this).GetCachedSize(), target, stream); } - // repeated bytes members = 4; + // repeated bytes members = 5; for (int i = 0, n = this->_internal_members_size(); i < n; i++) { const auto& s = this->_internal_members(i); - target = stream->WriteBytes(4, s, target); + target = stream->WriteBytes(5, s, target); } - // repeated bytes admins = 5; + // repeated bytes admins = 6; for (int i = 0, n = this->_internal_admins_size(); i < n; i++) { const auto& s = this->_internal_admins(i); - target = stream->WriteBytes(5, s, target); + target = stream->WriteBytes(6, s, target); } - // optional uint32 expirationTimer = 6; + // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; + for (unsigned i = 0, + n = static_cast(this->_internal_wrappers_size()); i < n; i++) { + const auto& repfield = this->_internal_wrappers(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(7, repfield, repfield.GetCachedSize(), target, stream); + } + + // optional uint32 expirationTimer = 8; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(6, this->_internal_expirationtimer(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_expirationtimer(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.ClosedGroupControlMessage) return target; } -size_t ConfigurationMessage_ClosedGroup::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.ClosedGroup) +size_t DataMessage_ClosedGroupControlMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.ClosedGroupControlMessage) size_t total_size = 0; + // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; + if (_internal_has_type()) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated bytes members = 4; + // repeated bytes members = 5; total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.members_.size()); for (int i = 0, n = _impl_.members_.size(); i < n; i++) { @@ -7761,7 +7620,7 @@ size_t ConfigurationMessage_ClosedGroup::ByteSizeLong() const { _impl_.members_.Get(i)); } - // repeated bytes admins = 5; + // repeated bytes admins = 6; total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.admins_.size()); for (int i = 0, n = _impl_.admins_.size(); i < n; i++) { @@ -7769,30 +7628,37 @@ size_t ConfigurationMessage_ClosedGroup::ByteSizeLong() const { _impl_.admins_.Get(i)); } + // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; + total_size += 1UL * this->_internal_wrappers_size(); + for (const auto& msg : this->_impl_.wrappers_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { - // optional bytes publicKey = 1; + // optional bytes publicKey = 2; if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( this->_internal_publickey()); } - // optional string name = 2; + // optional string name = 3; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); } - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; + // optional .SessionProtos.KeyPair encryptionKeyPair = 4; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.encryptionkeypair_); } - // optional uint32 expirationTimer = 6; + // optional uint32 expirationTimer = 8; if (cached_has_bits & 0x00000008u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); } @@ -7806,23 +7672,24 @@ size_t ConfigurationMessage_ClosedGroup::ByteSizeLong() const { return total_size; } -void ConfigurationMessage_ClosedGroup::CheckTypeAndMergeFrom( +void DataMessage_ClosedGroupControlMessage::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void ConfigurationMessage_ClosedGroup::MergeFrom(const ConfigurationMessage_ClosedGroup& from) { - ConfigurationMessage_ClosedGroup* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.ClosedGroup) +void DataMessage_ClosedGroupControlMessage::MergeFrom(const DataMessage_ClosedGroupControlMessage& from) { + DataMessage_ClosedGroupControlMessage* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; _this->_impl_.members_.MergeFrom(from._impl_.members_); _this->_impl_.admins_.MergeFrom(from._impl_.admins_); + _this->_impl_.wrappers_.MergeFrom(from._impl_.wrappers_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { _this->_internal_set_publickey(from._internal_publickey()); } @@ -7836,26 +7703,32 @@ void ConfigurationMessage_ClosedGroup::MergeFrom(const ConfigurationMessage_Clos if (cached_has_bits & 0x00000008u) { _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; } + if (cached_has_bits & 0x00000010u) { + _this->_impl_.type_ = from._impl_.type_; + } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void ConfigurationMessage_ClosedGroup::CopyFrom(const ConfigurationMessage_ClosedGroup& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.ClosedGroup) +void DataMessage_ClosedGroupControlMessage::CopyFrom(const DataMessage_ClosedGroupControlMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage_ClosedGroup::IsInitialized() const { +bool DataMessage_ClosedGroupControlMessage::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.wrappers_)) + return false; if (_internal_has_encryptionkeypair()) { if (!_impl_.encryptionkeypair_->IsInitialized()) return false; } return true; } -void ConfigurationMessage_ClosedGroup::InternalSwap(ConfigurationMessage_ClosedGroup* other) { +void DataMessage_ClosedGroupControlMessage::InternalSwap(DataMessage_ClosedGroupControlMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); @@ -7863,6 +7736,7 @@ void ConfigurationMessage_ClosedGroup::InternalSwap(ConfigurationMessage_ClosedG swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); _impl_.members_.InternalSwap(&other->_impl_.members_); _impl_.admins_.InternalSwap(&other->_impl_.admins_); + _impl_.wrappers_.InternalSwap(&other->_impl_.wrappers_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &_impl_.publickey_, lhs_arena, &other->_impl_.publickey_, rhs_arena @@ -7872,92 +7746,121 @@ void ConfigurationMessage_ClosedGroup::InternalSwap(ConfigurationMessage_ClosedG &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ClosedGroup, _impl_.expirationtimer_) - + sizeof(ConfigurationMessage_ClosedGroup::_impl_.expirationtimer_) - - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ClosedGroup, _impl_.encryptionkeypair_)>( + PROTOBUF_FIELD_OFFSET(DataMessage_ClosedGroupControlMessage, _impl_.expirationtimer_) + + sizeof(DataMessage_ClosedGroupControlMessage::_impl_.expirationtimer_) + - PROTOBUF_FIELD_OFFSET(DataMessage_ClosedGroupControlMessage, _impl_.encryptionkeypair_)>( reinterpret_cast(&_impl_.encryptionkeypair_), reinterpret_cast(&other->_impl_.encryptionkeypair_)); + swap(_impl_.type_, other->_impl_.type_); } -std::string ConfigurationMessage_ClosedGroup::GetTypeName() const { - return "SessionProtos.ConfigurationMessage.ClosedGroup"; +std::string DataMessage_ClosedGroupControlMessage::GetTypeName() const { + return "SessionProtos.DataMessage.ClosedGroupControlMessage"; } // =================================================================== -class ConfigurationMessage_Contact::_Internal { +class DataMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_body(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_name(HasBits* has_bits) { - (*has_bits)[0] |= 2u; + static void set_has_flags(HasBits* has_bits) { + (*has_bits)[0] |= 256u; } - static void set_has_profilepicture(HasBits* has_bits) { - (*has_bits)[0] |= 4u; + static void set_has_expiretimer(HasBits* has_bits) { + (*has_bits)[0] |= 512u; } static void set_has_profilekey(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_timestamp(HasBits* has_bits) { + (*has_bits)[0] |= 1024u; + } + static const ::SessionProtos::DataMessage_Quote& quote(const DataMessage* msg); + static void set_has_quote(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static void set_has_isapproved(HasBits* has_bits) { + static const ::SessionProtos::DataMessage_Reaction& reaction(const DataMessage* msg); + static void set_has_reaction(HasBits* has_bits) { (*has_bits)[0] |= 16u; } - static void set_has_isblocked(HasBits* has_bits) { + static const ::SessionProtos::LokiProfile& profile(const DataMessage* msg); + static void set_has_profile(HasBits* has_bits) { (*has_bits)[0] |= 32u; } - static void set_has_didapproveme(HasBits* has_bits) { + static const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation(const DataMessage* msg); + static void set_has_opengroupinvitation(HasBits* has_bits) { (*has_bits)[0] |= 64u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + static const ::SessionProtos::DataMessage_ClosedGroupControlMessage& closedgroupcontrolmessage(const DataMessage* msg); + static void set_has_closedgroupcontrolmessage(HasBits* has_bits) { + (*has_bits)[0] |= 128u; + } + static void set_has_synctarget(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_blockscommunitymessagerequests(HasBits* has_bits) { + (*has_bits)[0] |= 2048u; } }; -ConfigurationMessage_Contact::ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::DataMessage_Quote& +DataMessage::_Internal::quote(const DataMessage* msg) { + return *msg->_impl_.quote_; +} +const ::SessionProtos::DataMessage_Reaction& +DataMessage::_Internal::reaction(const DataMessage* msg) { + return *msg->_impl_.reaction_; +} +const ::SessionProtos::LokiProfile& +DataMessage::_Internal::profile(const DataMessage* msg) { + return *msg->_impl_.profile_; +} +const ::SessionProtos::DataMessage_OpenGroupInvitation& +DataMessage::_Internal::opengroupinvitation(const DataMessage* msg) { + return *msg->_impl_.opengroupinvitation_; +} +const ::SessionProtos::DataMessage_ClosedGroupControlMessage& +DataMessage::_Internal::closedgroupcontrolmessage(const DataMessage* msg) { + return *msg->_impl_.closedgroupcontrolmessage_; +} +DataMessage::DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage) } -ConfigurationMessage_Contact::ConfigurationMessage_Contact(const ConfigurationMessage_Contact& from) +DataMessage::DataMessage(const DataMessage& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage_Contact* const _this = this; (void)_this; + DataMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.profilepicture_){} + , decltype(_impl_.attachments_){from._impl_.attachments_} + , decltype(_impl_.preview_){from._impl_.preview_} + , decltype(_impl_.body_){} , decltype(_impl_.profilekey_){} - , decltype(_impl_.isapproved_){} - , decltype(_impl_.isblocked_){} - , decltype(_impl_.didapproveme_){}}; + , decltype(_impl_.synctarget_){} + , decltype(_impl_.quote_){nullptr} + , decltype(_impl_.reaction_){nullptr} + , decltype(_impl_.profile_){nullptr} + , decltype(_impl_.opengroupinvitation_){nullptr} + , decltype(_impl_.closedgroupcontrolmessage_){nullptr} + , decltype(_impl_.flags_){} + , decltype(_impl_.expiretimer_){} + , decltype(_impl_.timestamp_){} + , decltype(_impl_.blockscommunitymessagerequests_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), - _this->GetArenaForAllocation()); - } - _impl_.name_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_name()) { - _this->_impl_.name_.Set(from._internal_name(), - _this->GetArenaForAllocation()); - } - _impl_.profilepicture_.InitDefault(); + _impl_.body_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.body_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilepicture()) { - _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + if (from._internal_has_body()) { + _this->_impl_.body_.Set(from._internal_body(), _this->GetArenaForAllocation()); } _impl_.profilekey_.InitDefault(); @@ -7968,47 +7871,73 @@ ConfigurationMessage_Contact::ConfigurationMessage_Contact(const ConfigurationMe _this->_impl_.profilekey_.Set(from._internal_profilekey(), _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.isapproved_, &from._impl_.isapproved_, - static_cast(reinterpret_cast(&_impl_.didapproveme_) - - reinterpret_cast(&_impl_.isapproved_)) + sizeof(_impl_.didapproveme_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.Contact) + _impl_.synctarget_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.synctarget_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_synctarget()) { + _this->_impl_.synctarget_.Set(from._internal_synctarget(), + _this->GetArenaForAllocation()); + } + if (from._internal_has_quote()) { + _this->_impl_.quote_ = new ::SessionProtos::DataMessage_Quote(*from._impl_.quote_); + } + if (from._internal_has_reaction()) { + _this->_impl_.reaction_ = new ::SessionProtos::DataMessage_Reaction(*from._impl_.reaction_); + } + if (from._internal_has_profile()) { + _this->_impl_.profile_ = new ::SessionProtos::LokiProfile(*from._impl_.profile_); + } + if (from._internal_has_opengroupinvitation()) { + _this->_impl_.opengroupinvitation_ = new ::SessionProtos::DataMessage_OpenGroupInvitation(*from._impl_.opengroupinvitation_); + } + if (from._internal_has_closedgroupcontrolmessage()) { + _this->_impl_.closedgroupcontrolmessage_ = new ::SessionProtos::DataMessage_ClosedGroupControlMessage(*from._impl_.closedgroupcontrolmessage_); + } + ::memcpy(&_impl_.flags_, &from._impl_.flags_, + static_cast(reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - + reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.blockscommunitymessagerequests_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage) } -inline void ConfigurationMessage_Contact::SharedCtor( +inline void DataMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.profilepicture_){} + , decltype(_impl_.attachments_){arena} + , decltype(_impl_.preview_){arena} + , decltype(_impl_.body_){} , decltype(_impl_.profilekey_){} - , decltype(_impl_.isapproved_){false} - , decltype(_impl_.isblocked_){false} - , decltype(_impl_.didapproveme_){false} + , decltype(_impl_.synctarget_){} + , decltype(_impl_.quote_){nullptr} + , decltype(_impl_.reaction_){nullptr} + , decltype(_impl_.profile_){nullptr} + , decltype(_impl_.opengroupinvitation_){nullptr} + , decltype(_impl_.closedgroupcontrolmessage_){nullptr} + , decltype(_impl_.flags_){0u} + , decltype(_impl_.expiretimer_){0u} + , decltype(_impl_.timestamp_){uint64_t{0u}} + , decltype(_impl_.blockscommunitymessagerequests_){false} }; - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.InitDefault(); + _impl_.body_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.body_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.profilekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.profilekey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.synctarget_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.synctarget_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage_Contact::~ConfigurationMessage_Contact() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.Contact) +DataMessage::~DataMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -8016,112 +7945,205 @@ ConfigurationMessage_Contact::~ConfigurationMessage_Contact() { SharedDtor(); } -inline void ConfigurationMessage_Contact::SharedDtor() { +inline void DataMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.publickey_.Destroy(); - _impl_.name_.Destroy(); - _impl_.profilepicture_.Destroy(); + _impl_.attachments_.~RepeatedPtrField(); + _impl_.preview_.~RepeatedPtrField(); + _impl_.body_.Destroy(); _impl_.profilekey_.Destroy(); + _impl_.synctarget_.Destroy(); + if (this != internal_default_instance()) delete _impl_.quote_; + if (this != internal_default_instance()) delete _impl_.reaction_; + if (this != internal_default_instance()) delete _impl_.profile_; + if (this != internal_default_instance()) delete _impl_.opengroupinvitation_; + if (this != internal_default_instance()) delete _impl_.closedgroupcontrolmessage_; } -void ConfigurationMessage_Contact::SetCachedSize(int size) const { +void DataMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage_Contact::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.Contact) +void DataMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.attachments_.Clear(); + _impl_.preview_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + _impl_.body_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.name_.ClearNonDefaultToEmpty(); + _impl_.profilekey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - _impl_.profilepicture_.ClearNonDefaultToEmpty(); + _impl_.synctarget_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - _impl_.profilekey_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.quote_ != nullptr); + _impl_.quote_->Clear(); + } + if (cached_has_bits & 0x00000010u) { + GOOGLE_DCHECK(_impl_.reaction_ != nullptr); + _impl_.reaction_->Clear(); + } + if (cached_has_bits & 0x00000020u) { + GOOGLE_DCHECK(_impl_.profile_ != nullptr); + _impl_.profile_->Clear(); + } + if (cached_has_bits & 0x00000040u) { + GOOGLE_DCHECK(_impl_.opengroupinvitation_ != nullptr); + _impl_.opengroupinvitation_->Clear(); + } + if (cached_has_bits & 0x00000080u) { + GOOGLE_DCHECK(_impl_.closedgroupcontrolmessage_ != nullptr); + _impl_.closedgroupcontrolmessage_->Clear(); } } - ::memset(&_impl_.isapproved_, 0, static_cast( - reinterpret_cast(&_impl_.didapproveme_) - - reinterpret_cast(&_impl_.isapproved_)) + sizeof(_impl_.didapproveme_)); + if (cached_has_bits & 0x00000f00u) { + ::memset(&_impl_.flags_, 0, static_cast( + reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - + reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.blockscommunitymessagerequests_)); + } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* ConfigurationMessage_Contact::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes publicKey = 1; + // optional string body = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); + auto str = _internal_mutable_body(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required string name = 2; + // repeated .SessionProtos.AttachmentPointer attachments = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_name(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else + goto handle_unusual; + continue; + // optional uint32 flags = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional string profilePicture = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_profilepicture(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + // optional uint32 expireTimer = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { + _Internal::set_has_expiretimer(&has_bits); + _impl_.expiretimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional bytes profileKey = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + // optional bytes profileKey = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { auto str = _internal_mutable_profilekey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional bool isApproved = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { - _Internal::set_has_isapproved(&has_bits); - _impl_.isapproved_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // optional uint64 timestamp = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { + _Internal::set_has_timestamp(&has_bits); + _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional bool isBlocked = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { - _Internal::set_has_isblocked(&has_bits); - _impl_.isblocked_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // optional .SessionProtos.DataMessage.Quote quote = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { + ptr = ctx->ParseMessage(_internal_mutable_quote(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional bool didApproveMe = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { - _Internal::set_has_didapproveme(&has_bits); - _impl_.didapproveme_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // repeated .SessionProtos.DataMessage.Preview preview = 10; + case 10: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_preview(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr)); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataMessage.Reaction reaction = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { + ptr = ctx->ParseMessage(_internal_mutable_reaction(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.LokiProfile profile = 101; + case 101: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + ptr = ctx->ParseMessage(_internal_mutable_profile(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; + case 102: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + ptr = ctx->ParseMessage(_internal_mutable_opengroupinvitation(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; + case 104: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { + ptr = ctx->ParseMessage(_internal_mutable_closedgroupcontrolmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string syncTarget = 105; + case 105: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { + auto str = _internal_mutable_synctarget(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bool blocksCommunityMessageRequests = 106; + case 106: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 80)) { + _Internal::set_has_blockscommunitymessagerequests(&has_bits); + _impl_.blockscommunitymessagerequests_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8150,134 +8172,214 @@ const char* ConfigurationMessage_Contact::_InternalParse(const char* ptr, ::_pbi #undef CHK_ } -uint8_t* ConfigurationMessage_Contact::_InternalSerialize( +uint8_t* DataMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes publicKey = 1; + // optional string body = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_body(), target); } - // required string name = 2; + // repeated .SessionProtos.AttachmentPointer attachments = 2; + for (unsigned i = 0, + n = static_cast(this->_internal_attachments_size()); i < n; i++) { + const auto& repfield = this->_internal_attachments(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); + } + + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000100u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); + } + + // optional uint32 expireTimer = 5; + if (cached_has_bits & 0x00000200u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(5, this->_internal_expiretimer(), target); + } + + // optional bytes profileKey = 6; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_name(), target); + target = stream->WriteBytesMaybeAliased( + 6, this->_internal_profilekey(), target); } - // optional string profilePicture = 3; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_profilepicture(), target); + // optional uint64 timestamp = 7; + if (cached_has_bits & 0x00000400u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(7, this->_internal_timestamp(), target); } - // optional bytes profileKey = 4; + // optional .SessionProtos.DataMessage.Quote quote = 8; if (cached_has_bits & 0x00000008u) { - target = stream->WriteBytesMaybeAliased( - 4, this->_internal_profilekey(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(8, _Internal::quote(this), + _Internal::quote(this).GetCachedSize(), target, stream); } - // optional bool isApproved = 5; + // repeated .SessionProtos.DataMessage.Preview preview = 10; + for (unsigned i = 0, + n = static_cast(this->_internal_preview_size()); i < n; i++) { + const auto& repfield = this->_internal_preview(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(10, repfield, repfield.GetCachedSize(), target, stream); + } + + // optional .SessionProtos.DataMessage.Reaction reaction = 11; if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_isapproved(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(11, _Internal::reaction(this), + _Internal::reaction(this).GetCachedSize(), target, stream); } - // optional bool isBlocked = 6; + // optional .SessionProtos.LokiProfile profile = 101; if (cached_has_bits & 0x00000020u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(6, this->_internal_isblocked(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(101, _Internal::profile(this), + _Internal::profile(this).GetCachedSize(), target, stream); } - // optional bool didApproveMe = 7; + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; if (cached_has_bits & 0x00000040u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(102, _Internal::opengroupinvitation(this), + _Internal::opengroupinvitation(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; + if (cached_has_bits & 0x00000080u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(104, _Internal::closedgroupcontrolmessage(this), + _Internal::closedgroupcontrolmessage(this).GetCachedSize(), target, stream); + } + + // optional string syncTarget = 105; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteStringMaybeAliased( + 105, this->_internal_synctarget(), target); + } + + // optional bool blocksCommunityMessageRequests = 106; + if (cached_has_bits & 0x00000800u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(7, this->_internal_didapproveme(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(106, this->_internal_blockscommunitymessagerequests(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage) return target; } -size_t ConfigurationMessage_Contact::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.Contact) +size_t DataMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage) size_t total_size = 0; - if (_internal_has_publickey()) { - // required bytes publicKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - if (_internal_has_name()) { - // required string name = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + // repeated .SessionProtos.AttachmentPointer attachments = 2; + total_size += 1UL * this->_internal_attachments_size(); + for (const auto& msg : this->_impl_.attachments_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return total_size; -} -size_t ConfigurationMessage_Contact::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.Contact) - size_t total_size = 0; - - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes publicKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - - // required string name = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); + // repeated .SessionProtos.DataMessage.Preview preview = 10; + total_size += 1UL * this->_internal_preview_size(); + for (const auto& msg : this->_impl_.preview_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007cu) { - // optional string profilePicture = 3; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x000000ffu) { + // optional string body = 1; + if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_profilepicture()); + this->_internal_body()); } - // optional bytes profileKey = 4; - if (cached_has_bits & 0x00000008u) { + // optional bytes profileKey = 6; + if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( this->_internal_profilekey()); } - // optional bool isApproved = 5; + // optional string syncTarget = 105; + if (cached_has_bits & 0x00000004u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_synctarget()); + } + + // optional .SessionProtos.DataMessage.Quote quote = 8; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.quote_); + } + + // optional .SessionProtos.DataMessage.Reaction reaction = 11; if (cached_has_bits & 0x00000010u) { - total_size += 1 + 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.reaction_); } - // optional bool isBlocked = 6; + // optional .SessionProtos.LokiProfile profile = 101; if (cached_has_bits & 0x00000020u) { - total_size += 1 + 1; + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.profile_); } - // optional bool didApproveMe = 7; + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; if (cached_has_bits & 0x00000040u) { - total_size += 1 + 1; + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.opengroupinvitation_); + } + + // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; + if (cached_has_bits & 0x00000080u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.closedgroupcontrolmessage_); + } + + } + if (cached_has_bits & 0x00000f00u) { + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000100u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + + // optional uint32 expireTimer = 5; + if (cached_has_bits & 0x00000200u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expiretimer()); + } + + // optional uint64 timestamp = 7; + if (cached_has_bits & 0x00000400u) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); + } + + // optional bool blocksCommunityMessageRequests = 106; + if (cached_has_bits & 0x00000800u) { + total_size += 2 + 1; } } @@ -8289,197 +8391,224 @@ size_t ConfigurationMessage_Contact::ByteSizeLong() const { return total_size; } -void ConfigurationMessage_Contact::CheckTypeAndMergeFrom( +void DataMessage::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void ConfigurationMessage_Contact::MergeFrom(const ConfigurationMessage_Contact& from) { - ConfigurationMessage_Contact* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.Contact) +void DataMessage::MergeFrom(const DataMessage& from) { + DataMessage* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; + _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); + _this->_impl_.preview_.MergeFrom(from._impl_.preview_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_body(from._internal_body()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_name(from._internal_name()); + _this->_internal_set_profilekey(from._internal_profilekey()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_synctarget(from._internal_synctarget()); + } + if (cached_has_bits & 0x00000008u) { + _this->_internal_mutable_quote()->::SessionProtos::DataMessage_Quote::MergeFrom( + from._internal_quote()); + } + if (cached_has_bits & 0x00000010u) { + _this->_internal_mutable_reaction()->::SessionProtos::DataMessage_Reaction::MergeFrom( + from._internal_reaction()); + } + if (cached_has_bits & 0x00000020u) { + _this->_internal_mutable_profile()->::SessionProtos::LokiProfile::MergeFrom( + from._internal_profile()); + } + if (cached_has_bits & 0x00000040u) { + _this->_internal_mutable_opengroupinvitation()->::SessionProtos::DataMessage_OpenGroupInvitation::MergeFrom( + from._internal_opengroupinvitation()); } - if (cached_has_bits & 0x00000004u) { - _this->_internal_set_profilepicture(from._internal_profilepicture()); + if (cached_has_bits & 0x00000080u) { + _this->_internal_mutable_closedgroupcontrolmessage()->::SessionProtos::DataMessage_ClosedGroupControlMessage::MergeFrom( + from._internal_closedgroupcontrolmessage()); } - if (cached_has_bits & 0x00000008u) { - _this->_internal_set_profilekey(from._internal_profilekey()); + } + if (cached_has_bits & 0x00000f00u) { + if (cached_has_bits & 0x00000100u) { + _this->_impl_.flags_ = from._impl_.flags_; } - if (cached_has_bits & 0x00000010u) { - _this->_impl_.isapproved_ = from._impl_.isapproved_; + if (cached_has_bits & 0x00000200u) { + _this->_impl_.expiretimer_ = from._impl_.expiretimer_; } - if (cached_has_bits & 0x00000020u) { - _this->_impl_.isblocked_ = from._impl_.isblocked_; + if (cached_has_bits & 0x00000400u) { + _this->_impl_.timestamp_ = from._impl_.timestamp_; } - if (cached_has_bits & 0x00000040u) { - _this->_impl_.didapproveme_ = from._impl_.didapproveme_; + if (cached_has_bits & 0x00000800u) { + _this->_impl_.blockscommunitymessagerequests_ = from._impl_.blockscommunitymessagerequests_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void ConfigurationMessage_Contact::CopyFrom(const ConfigurationMessage_Contact& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.Contact) +void DataMessage::CopyFrom(const DataMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage_Contact::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool DataMessage::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) + return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.preview_)) + return false; + if (_internal_has_quote()) { + if (!_impl_.quote_->IsInitialized()) return false; + } + if (_internal_has_reaction()) { + if (!_impl_.reaction_->IsInitialized()) return false; + } + if (_internal_has_opengroupinvitation()) { + if (!_impl_.opengroupinvitation_->IsInitialized()) return false; + } + if (_internal_has_closedgroupcontrolmessage()) { + if (!_impl_.closedgroupcontrolmessage_->IsInitialized()) return false; + } return true; } -void ConfigurationMessage_Contact::InternalSwap(ConfigurationMessage_Contact* other) { +void DataMessage::InternalSwap(DataMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); + _impl_.preview_.InternalSwap(&other->_impl_.preview_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.name_, lhs_arena, - &other->_impl_.name_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilepicture_, lhs_arena, - &other->_impl_.profilepicture_, rhs_arena + &_impl_.body_, lhs_arena, + &other->_impl_.body_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &_impl_.profilekey_, lhs_arena, &other->_impl_.profilekey_, rhs_arena ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.synctarget_, lhs_arena, + &other->_impl_.synctarget_, rhs_arena + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_Contact, _impl_.didapproveme_) - + sizeof(ConfigurationMessage_Contact::_impl_.didapproveme_) - - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_Contact, _impl_.isapproved_)>( - reinterpret_cast(&_impl_.isapproved_), - reinterpret_cast(&other->_impl_.isapproved_)); + PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.blockscommunitymessagerequests_) + + sizeof(DataMessage::_impl_.blockscommunitymessagerequests_) + - PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.quote_)>( + reinterpret_cast(&_impl_.quote_), + reinterpret_cast(&other->_impl_.quote_)); } -std::string ConfigurationMessage_Contact::GetTypeName() const { - return "SessionProtos.ConfigurationMessage.Contact"; +std::string DataMessage::GetTypeName() const { + return "SessionProtos.DataMessage"; } // =================================================================== -class ConfigurationMessage_ProProof::_Internal { +class ConfigurationMessage_ClosedGroup::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_version(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static void set_has_genindexhash(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_publickey(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_rotatingpublickey(HasBits* has_bits) { + static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_expiryunixts(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static void set_has_sig(HasBits* has_bits) { + static const ::SessionProtos::KeyPair& encryptionkeypair(const ConfigurationMessage_ClosedGroup* msg); + static void set_has_encryptionkeypair(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x0000001f) ^ 0x0000001f) != 0; + static void set_has_expirationtimer(HasBits* has_bits) { + (*has_bits)[0] |= 8u; } }; -ConfigurationMessage_ProProof::ConfigurationMessage_ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::KeyPair& +ConfigurationMessage_ClosedGroup::_Internal::encryptionkeypair(const ConfigurationMessage_ClosedGroup* msg) { + return *msg->_impl_.encryptionkeypair_; +} +ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.ProProof) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.ClosedGroup) } -ConfigurationMessage_ProProof::ConfigurationMessage_ProProof(const ConfigurationMessage_ProProof& from) +ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(const ConfigurationMessage_ClosedGroup& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage_ProProof* const _this = this; (void)_this; + ConfigurationMessage_ClosedGroup* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.genindexhash_){} - , decltype(_impl_.rotatingpublickey_){} - , decltype(_impl_.sig_){} - , decltype(_impl_.expiryunixts_){} - , decltype(_impl_.version_){}}; + , decltype(_impl_.members_){from._impl_.members_} + , decltype(_impl_.admins_){from._impl_.admins_} + , decltype(_impl_.publickey_){} + , decltype(_impl_.name_){} + , decltype(_impl_.encryptionkeypair_){nullptr} + , decltype(_impl_.expirationtimer_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.genindexhash_.InitDefault(); + _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.genindexhash_.Set("", GetArenaForAllocation()); + _impl_.publickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_genindexhash()) { - _this->_impl_.genindexhash_.Set(from._internal_genindexhash(), + if (from._internal_has_publickey()) { + _this->_impl_.publickey_.Set(from._internal_publickey(), _this->GetArenaForAllocation()); } - _impl_.rotatingpublickey_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_rotatingpublickey()) { - _this->_impl_.rotatingpublickey_.Set(from._internal_rotatingpublickey(), + if (from._internal_has_name()) { + _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation()); } - _impl_.sig_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.sig_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_sig()) { - _this->_impl_.sig_.Set(from._internal_sig(), - _this->GetArenaForAllocation()); + if (from._internal_has_encryptionkeypair()) { + _this->_impl_.encryptionkeypair_ = new ::SessionProtos::KeyPair(*from._impl_.encryptionkeypair_); } - ::memcpy(&_impl_.expiryunixts_, &from._impl_.expiryunixts_, - static_cast(reinterpret_cast(&_impl_.version_) - - reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.ProProof) + _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.ClosedGroup) } -inline void ConfigurationMessage_ProProof::SharedCtor( +inline void ConfigurationMessage_ClosedGroup::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.genindexhash_){} - , decltype(_impl_.rotatingpublickey_){} - , decltype(_impl_.sig_){} - , decltype(_impl_.expiryunixts_){uint64_t{0u}} - , decltype(_impl_.version_){0u} + , decltype(_impl_.members_){arena} + , decltype(_impl_.admins_){arena} + , decltype(_impl_.publickey_){} + , decltype(_impl_.name_){} + , decltype(_impl_.encryptionkeypair_){nullptr} + , decltype(_impl_.expirationtimer_){0u} }; - _impl_.genindexhash_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.genindexhash_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingpublickey_.InitDefault(); + _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + _impl_.publickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.sig_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.sig_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage_ProProof::~ConfigurationMessage_ProProof() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.ProProof) +ConfigurationMessage_ClosedGroup::~ConfigurationMessage_ClosedGroup() { + // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.ClosedGroup) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -8487,92 +8616,111 @@ ConfigurationMessage_ProProof::~ConfigurationMessage_ProProof() { SharedDtor(); } -inline void ConfigurationMessage_ProProof::SharedDtor() { +inline void ConfigurationMessage_ClosedGroup::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.genindexhash_.Destroy(); - _impl_.rotatingpublickey_.Destroy(); - _impl_.sig_.Destroy(); + _impl_.members_.~RepeatedPtrField(); + _impl_.admins_.~RepeatedPtrField(); + _impl_.publickey_.Destroy(); + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.encryptionkeypair_; } -void ConfigurationMessage_ProProof::SetCachedSize(int size) const { +void ConfigurationMessage_ClosedGroup::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage_ProProof::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.ProProof) +void ConfigurationMessage_ClosedGroup::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.ClosedGroup) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.members_.Clear(); + _impl_.admins_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _impl_.genindexhash_.ClearNonDefaultToEmpty(); + _impl_.publickey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.rotatingpublickey_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - _impl_.sig_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.encryptionkeypair_ != nullptr); + _impl_.encryptionkeypair_->Clear(); } } - if (cached_has_bits & 0x00000018u) { - ::memset(&_impl_.expiryunixts_, 0, static_cast( - reinterpret_cast(&_impl_.version_) - - reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); - } + _impl_.expirationtimer_ = 0u; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* ConfigurationMessage_ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint32 version = 1; + // optional bytes publicKey = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_version(&has_bits); - _impl_.version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_publickey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes genIndexHash = 2; + // optional string name = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_genindexhash(); + auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes rotatingPublicKey = 3; + // optional .SessionProtos.KeyPair encryptionKeyPair = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_rotatingpublickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_encryptionkeypair(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // required uint64 expiryUnixTs = 4; + // repeated bytes members = 4; case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_expiryunixts(&has_bits); - _impl_.expiryunixts_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_members(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; - // required bytes sig = 5; + // repeated bytes admins = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_sig(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_admins(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + } else + goto handle_unusual; + continue; + // optional uint32 expirationTimer = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { + _Internal::set_has_expirationtimer(&has_bits); + _impl_.expirationtimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8601,121 +8749,111 @@ const char* ConfigurationMessage_ProProof::_InternalParse(const char* ptr, ::_pb #undef CHK_ } -uint8_t* ConfigurationMessage_ProProof::_InternalSerialize( +uint8_t* ConfigurationMessage_ClosedGroup::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.ProProof) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.ClosedGroup) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint32 version = 1; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_version(), target); - } - - // required bytes genIndexHash = 2; + // optional bytes publicKey = 1; if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 2, this->_internal_genindexhash(), target); + 1, this->_internal_publickey(), target); } - // required bytes rotatingPublicKey = 3; + // optional string name = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 3, this->_internal_rotatingpublickey(), target); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_name(), target); } - // required uint64 expiryUnixTs = 4; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_expiryunixts(), target); + // optional .SessionProtos.KeyPair encryptionKeyPair = 3; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::encryptionkeypair(this), + _Internal::encryptionkeypair(this).GetCachedSize(), target, stream); } - // required bytes sig = 5; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteBytesMaybeAliased( - 5, this->_internal_sig(), target); + // repeated bytes members = 4; + for (int i = 0, n = this->_internal_members_size(); i < n; i++) { + const auto& s = this->_internal_members(i); + target = stream->WriteBytes(4, s, target); + } + + // repeated bytes admins = 5; + for (int i = 0, n = this->_internal_admins_size(); i < n; i++) { + const auto& s = this->_internal_admins(i); + target = stream->WriteBytes(5, s, target); + } + + // optional uint32 expirationTimer = 6; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(6, this->_internal_expirationtimer(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.ProProof) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.ClosedGroup) return target; } -size_t ConfigurationMessage_ProProof::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.ProProof) +size_t ConfigurationMessage_ClosedGroup::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.ClosedGroup) size_t total_size = 0; - if (_internal_has_genindexhash()) { - // required bytes genIndexHash = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_genindexhash()); - } - - if (_internal_has_rotatingpublickey()) { - // required bytes rotatingPublicKey = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingpublickey()); - } - - if (_internal_has_sig()) { - // required bytes sig = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_sig()); - } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - if (_internal_has_expiryunixts()) { - // required uint64 expiryUnixTs = 4; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + // repeated bytes members = 4; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.members_.size()); + for (int i = 0, n = _impl_.members_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + _impl_.members_.Get(i)); } - if (_internal_has_version()) { - // required uint32 version = 1; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + // repeated bytes admins = 5; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.admins_.size()); + for (int i = 0, n = _impl_.admins_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + _impl_.admins_.Get(i)); } - return total_size; -} -size_t ConfigurationMessage_ProProof::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.ProProof) - size_t total_size = 0; - - if (((_impl_._has_bits_[0] & 0x0000001f) ^ 0x0000001f) == 0) { // All required fields are present. - // required bytes genIndexHash = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_genindexhash()); - - // required bytes rotatingPublicKey = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingpublickey()); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + // optional bytes publicKey = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); + } - // required bytes sig = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_sig()); + // optional string name = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } - // required uint64 expiryUnixTs = 4; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + // optional .SessionProtos.KeyPair encryptionKeyPair = 3; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.encryptionkeypair_); + } - // required uint32 version = 1; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + // optional uint32 expirationTimer = 6; + if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); + } - } else { - total_size += RequiredFieldsByteSizeFallback(); } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -8724,157 +8862,209 @@ size_t ConfigurationMessage_ProProof::ByteSizeLong() const { return total_size; } -void ConfigurationMessage_ProProof::CheckTypeAndMergeFrom( +void ConfigurationMessage_ClosedGroup::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void ConfigurationMessage_ProProof::MergeFrom(const ConfigurationMessage_ProProof& from) { - ConfigurationMessage_ProProof* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.ProProof) +void ConfigurationMessage_ClosedGroup::MergeFrom(const ConfigurationMessage_ClosedGroup& from) { + ConfigurationMessage_ClosedGroup* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.ClosedGroup) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; + _this->_impl_.members_.MergeFrom(from._impl_.members_); + _this->_impl_.admins_.MergeFrom(from._impl_.admins_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_genindexhash(from._internal_genindexhash()); + _this->_internal_set_publickey(from._internal_publickey()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_rotatingpublickey(from._internal_rotatingpublickey()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_set_sig(from._internal_sig()); + _this->_internal_mutable_encryptionkeypair()->::SessionProtos::KeyPair::MergeFrom( + from._internal_encryptionkeypair()); } if (cached_has_bits & 0x00000008u) { - _this->_impl_.expiryunixts_ = from._impl_.expiryunixts_; - } - if (cached_has_bits & 0x00000010u) { - _this->_impl_.version_ = from._impl_.version_; + _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void ConfigurationMessage_ProProof::CopyFrom(const ConfigurationMessage_ProProof& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.ProProof) +void ConfigurationMessage_ClosedGroup::CopyFrom(const ConfigurationMessage_ClosedGroup& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.ClosedGroup) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage_ProProof::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool ConfigurationMessage_ClosedGroup::IsInitialized() const { + if (_internal_has_encryptionkeypair()) { + if (!_impl_.encryptionkeypair_->IsInitialized()) return false; + } return true; } -void ConfigurationMessage_ProProof::InternalSwap(ConfigurationMessage_ProProof* other) { +void ConfigurationMessage_ClosedGroup::InternalSwap(ConfigurationMessage_ClosedGroup* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.members_.InternalSwap(&other->_impl_.members_); + _impl_.admins_.InternalSwap(&other->_impl_.admins_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.genindexhash_, lhs_arena, - &other->_impl_.genindexhash_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.rotatingpublickey_, lhs_arena, - &other->_impl_.rotatingpublickey_, rhs_arena + &_impl_.publickey_, lhs_arena, + &other->_impl_.publickey_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.sig_, lhs_arena, - &other->_impl_.sig_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ProProof, _impl_.version_) - + sizeof(ConfigurationMessage_ProProof::_impl_.version_) - - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ProProof, _impl_.expiryunixts_)>( - reinterpret_cast(&_impl_.expiryunixts_), - reinterpret_cast(&other->_impl_.expiryunixts_)); + PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ClosedGroup, _impl_.expirationtimer_) + + sizeof(ConfigurationMessage_ClosedGroup::_impl_.expirationtimer_) + - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ClosedGroup, _impl_.encryptionkeypair_)>( + reinterpret_cast(&_impl_.encryptionkeypair_), + reinterpret_cast(&other->_impl_.encryptionkeypair_)); } -std::string ConfigurationMessage_ProProof::GetTypeName() const { - return "SessionProtos.ConfigurationMessage.ProProof"; +std::string ConfigurationMessage_ClosedGroup::GetTypeName() const { + return "SessionProtos.ConfigurationMessage.ClosedGroup"; } // =================================================================== -class ConfigurationMessage_Pro::_Internal { +class ConfigurationMessage_Contact::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_rotatingprivkey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_publickey(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_proof(HasBits* has_bits) { + static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static void set_has_profilepicture(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_profilekey(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_isapproved(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_isblocked(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static void set_has_didapproveme(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } static bool MissingRequiredFields(const HasBits& has_bits) { return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -ConfigurationMessage_Pro::ConfigurationMessage_Pro(::PROTOBUF_NAMESPACE_ID::Arena* arena, +ConfigurationMessage_Contact::ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.Pro) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.Contact) } -ConfigurationMessage_Pro::ConfigurationMessage_Pro(const ConfigurationMessage_Pro& from) +ConfigurationMessage_Contact::ConfigurationMessage_Contact(const ConfigurationMessage_Contact& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage_Pro* const _this = this; (void)_this; + ConfigurationMessage_Contact* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.rotatingprivkey_){} - , decltype(_impl_.proof_){}}; + , decltype(_impl_.publickey_){} + , decltype(_impl_.name_){} + , decltype(_impl_.profilepicture_){} + , decltype(_impl_.profilekey_){} + , decltype(_impl_.isapproved_){} + , decltype(_impl_.isblocked_){} + , decltype(_impl_.didapproveme_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.rotatingprivkey_.InitDefault(); + _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + _impl_.publickey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_rotatingprivkey()) { - _this->_impl_.rotatingprivkey_.Set(from._internal_rotatingprivkey(), + if (from._internal_has_publickey()) { + _this->_impl_.publickey_.Set(from._internal_publickey(), _this->GetArenaForAllocation()); } - _impl_.proof_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.proof_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_proof()) { - _this->_impl_.proof_.Set(from._internal_proof(), + if (from._internal_has_name()) { + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); + } + _impl_.profilepicture_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_profilepicture()) { + _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + _this->GetArenaForAllocation()); + } + _impl_.profilekey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilekey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_profilekey()) { + _this->_impl_.profilekey_.Set(from._internal_profilekey(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.Pro) + ::memcpy(&_impl_.isapproved_, &from._impl_.isapproved_, + static_cast(reinterpret_cast(&_impl_.didapproveme_) - + reinterpret_cast(&_impl_.isapproved_)) + sizeof(_impl_.didapproveme_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.Contact) } -inline void ConfigurationMessage_Pro::SharedCtor( +inline void ConfigurationMessage_Contact::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.rotatingprivkey_){} - , decltype(_impl_.proof_){} + , decltype(_impl_.publickey_){} + , decltype(_impl_.name_){} + , decltype(_impl_.profilepicture_){} + , decltype(_impl_.profilekey_){} + , decltype(_impl_.isapproved_){false} + , decltype(_impl_.isblocked_){false} + , decltype(_impl_.didapproveme_){false} }; - _impl_.rotatingprivkey_.InitDefault(); + _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + _impl_.publickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.proof_.InitDefault(); + _impl_.profilekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.proof_.Set("", GetArenaForAllocation()); + _impl_.profilekey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage_Pro::~ConfigurationMessage_Pro() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.Pro) +ConfigurationMessage_Contact::~ConfigurationMessage_Contact() { + // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.Contact) if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; @@ -8882,60 +9072,116 @@ ConfigurationMessage_Pro::~ConfigurationMessage_Pro() { SharedDtor(); } -inline void ConfigurationMessage_Pro::SharedDtor() { +inline void ConfigurationMessage_Contact::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.rotatingprivkey_.Destroy(); - _impl_.proof_.Destroy(); + _impl_.publickey_.Destroy(); + _impl_.name_.Destroy(); + _impl_.profilepicture_.Destroy(); + _impl_.profilekey_.Destroy(); } -void ConfigurationMessage_Pro::SetCachedSize(int size) const { +void ConfigurationMessage_Contact::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage_Pro::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.Pro) +void ConfigurationMessage_Contact::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.Contact) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _impl_.rotatingprivkey_.ClearNonDefaultToEmpty(); + _impl_.publickey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.proof_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + _impl_.profilepicture_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000008u) { + _impl_.profilekey_.ClearNonDefaultToEmpty(); } } + ::memset(&_impl_.isapproved_, 0, static_cast( + reinterpret_cast(&_impl_.didapproveme_) - + reinterpret_cast(&_impl_.isapproved_)) + sizeof(_impl_.didapproveme_)); _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } -const char* ConfigurationMessage_Pro::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ConfigurationMessage_Contact::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes rotatingPrivKey = 1; + // required bytes publicKey = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_rotatingprivkey(); + auto str = _internal_mutable_publickey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes proof = 2; + // required string name = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_proof(); + auto str = _internal_mutable_name(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string profilePicture = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_profilepicture(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes profileKey = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_profilekey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; + // optional bool isApproved = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { + _Internal::set_has_isapproved(&has_bits); + _impl_.isapproved_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bool isBlocked = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { + _Internal::set_has_isblocked(&has_bits); + _impl_.isblocked_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bool didApproveMe = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { + _Internal::set_has_didapproveme(&has_bits); + _impl_.didapproveme_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -8960,67 +9206,97 @@ const char* ConfigurationMessage_Pro::_InternalParse(const char* ptr, ::_pbi::Pa #undef CHK_ } -uint8_t* ConfigurationMessage_Pro::_InternalSerialize( +uint8_t* ConfigurationMessage_Contact::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.Pro) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.Contact) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes rotatingPrivKey = 1; + // required bytes publicKey = 1; if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 1, this->_internal_rotatingprivkey(), target); + 1, this->_internal_publickey(), target); } - // required bytes proof = 2; + // required string name = 2; if (cached_has_bits & 0x00000002u) { + target = stream->WriteStringMaybeAliased( + 2, this->_internal_name(), target); + } + + // optional string profilePicture = 3; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteStringMaybeAliased( + 3, this->_internal_profilepicture(), target); + } + + // optional bytes profileKey = 4; + if (cached_has_bits & 0x00000008u) { target = stream->WriteBytesMaybeAliased( - 2, this->_internal_proof(), target); + 4, this->_internal_profilekey(), target); + } + + // optional bool isApproved = 5; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_isapproved(), target); + } + + // optional bool isBlocked = 6; + if (cached_has_bits & 0x00000020u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(6, this->_internal_isblocked(), target); + } + + // optional bool didApproveMe = 7; + if (cached_has_bits & 0x00000040u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(7, this->_internal_didapproveme(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.Pro) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.Contact) return target; } -size_t ConfigurationMessage_Pro::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.Pro) +size_t ConfigurationMessage_Contact::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.Contact) size_t total_size = 0; - if (_internal_has_rotatingprivkey()) { - // required bytes rotatingPrivKey = 1; + if (_internal_has_publickey()) { + // required bytes publicKey = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingprivkey()); + this->_internal_publickey()); } - if (_internal_has_proof()) { - // required bytes proof = 2; + if (_internal_has_name()) { + // required string name = 2; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_proof()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } return total_size; } -size_t ConfigurationMessage_Pro::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.Pro) +size_t ConfigurationMessage_Contact::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.Contact) size_t total_size = 0; if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes rotatingPrivKey = 1; + // required bytes publicKey = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingprivkey()); + this->_internal_publickey()); - // required bytes proof = 2; + // required string name = 2; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_proof()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -9029,6 +9305,38 @@ size_t ConfigurationMessage_Pro::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000007cu) { + // optional string profilePicture = 3; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_profilepicture()); + } + + // optional bytes profileKey = 4; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_profilekey()); + } + + // optional bool isApproved = 5; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + 1; + } + + // optional bool isBlocked = 6; + if (cached_has_bits & 0x00000020u) { + total_size += 1 + 1; + } + + // optional bool didApproveMe = 7; + if (cached_has_bits & 0x00000040u) { + total_size += 1 + 1; + } + + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -9037,61 +9345,91 @@ size_t ConfigurationMessage_Pro::ByteSizeLong() const { return total_size; } -void ConfigurationMessage_Pro::CheckTypeAndMergeFrom( +void ConfigurationMessage_Contact::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( + MergeFrom(*::_pbi::DownCast( &from)); } -void ConfigurationMessage_Pro::MergeFrom(const ConfigurationMessage_Pro& from) { - ConfigurationMessage_Pro* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.Pro) +void ConfigurationMessage_Contact::MergeFrom(const ConfigurationMessage_Contact& from) { + ConfigurationMessage_Contact* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.Contact) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x0000007fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_rotatingprivkey(from._internal_rotatingprivkey()); + _this->_internal_set_publickey(from._internal_publickey()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_proof(from._internal_proof()); + _this->_internal_set_name(from._internal_name()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_profilepicture(from._internal_profilepicture()); + } + if (cached_has_bits & 0x00000008u) { + _this->_internal_set_profilekey(from._internal_profilekey()); + } + if (cached_has_bits & 0x00000010u) { + _this->_impl_.isapproved_ = from._impl_.isapproved_; + } + if (cached_has_bits & 0x00000020u) { + _this->_impl_.isblocked_ = from._impl_.isblocked_; + } + if (cached_has_bits & 0x00000040u) { + _this->_impl_.didapproveme_ = from._impl_.didapproveme_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } -void ConfigurationMessage_Pro::CopyFrom(const ConfigurationMessage_Pro& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.Pro) +void ConfigurationMessage_Contact::CopyFrom(const ConfigurationMessage_Contact& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.Contact) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage_Pro::IsInitialized() const { +bool ConfigurationMessage_Contact::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void ConfigurationMessage_Pro::InternalSwap(ConfigurationMessage_Pro* other) { +void ConfigurationMessage_Contact::InternalSwap(ConfigurationMessage_Contact* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.rotatingprivkey_, lhs_arena, - &other->_impl_.rotatingprivkey_, rhs_arena + &_impl_.publickey_, lhs_arena, + &other->_impl_.publickey_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.profilepicture_, lhs_arena, + &other->_impl_.profilepicture_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.proof_, lhs_arena, - &other->_impl_.proof_, rhs_arena + &_impl_.profilekey_, lhs_arena, + &other->_impl_.profilekey_, rhs_arena ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ConfigurationMessage_Contact, _impl_.didapproveme_) + + sizeof(ConfigurationMessage_Contact::_impl_.didapproveme_) + - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_Contact, _impl_.isapproved_)>( + reinterpret_cast(&_impl_.isapproved_), + reinterpret_cast(&other->_impl_.isapproved_)); } -std::string ConfigurationMessage_Pro::GetTypeName() const { - return "SessionProtos.ConfigurationMessage.Pro"; +std::string ConfigurationMessage_Contact::GetTypeName() const { + return "SessionProtos.ConfigurationMessage.Contact"; } @@ -9109,15 +9447,15 @@ class ConfigurationMessage::_Internal { static void set_has_profilekey(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static const ::SessionProtos::ConfigurationMessage_Pro& pro(const ConfigurationMessage* msg); - static void set_has_pro(HasBits* has_bits) { + static const ::SessionProtos::ProConfig& proconfig(const ConfigurationMessage* msg); + static void set_has_proconfig(HasBits* has_bits) { (*has_bits)[0] |= 8u; } }; -const ::SessionProtos::ConfigurationMessage_Pro& -ConfigurationMessage::_Internal::pro(const ConfigurationMessage* msg) { - return *msg->_impl_.pro_; +const ::SessionProtos::ProConfig& +ConfigurationMessage::_Internal::proconfig(const ConfigurationMessage* msg) { + return *msg->_impl_.proconfig_; } ConfigurationMessage::ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) @@ -9137,7 +9475,7 @@ ConfigurationMessage::ConfigurationMessage(const ConfigurationMessage& from) , decltype(_impl_.displayname_){} , decltype(_impl_.profilepicture_){} , decltype(_impl_.profilekey_){} - , decltype(_impl_.pro_){nullptr}}; + , decltype(_impl_.proconfig_){nullptr}}; _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.displayname_.InitDefault(); @@ -9164,8 +9502,8 @@ ConfigurationMessage::ConfigurationMessage(const ConfigurationMessage& from) _this->_impl_.profilekey_.Set(from._internal_profilekey(), _this->GetArenaForAllocation()); } - if (from._internal_has_pro()) { - _this->_impl_.pro_ = new ::SessionProtos::ConfigurationMessage_Pro(*from._impl_.pro_); + if (from._internal_has_proconfig()) { + _this->_impl_.proconfig_ = new ::SessionProtos::ProConfig(*from._impl_.proconfig_); } // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage) } @@ -9183,7 +9521,7 @@ inline void ConfigurationMessage::SharedCtor( , decltype(_impl_.displayname_){} , decltype(_impl_.profilepicture_){} , decltype(_impl_.profilekey_){} - , decltype(_impl_.pro_){nullptr} + , decltype(_impl_.proconfig_){nullptr} }; _impl_.displayname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -9216,7 +9554,7 @@ inline void ConfigurationMessage::SharedDtor() { _impl_.displayname_.Destroy(); _impl_.profilepicture_.Destroy(); _impl_.profilekey_.Destroy(); - if (this != internal_default_instance()) delete _impl_.pro_; + if (this != internal_default_instance()) delete _impl_.proconfig_; } void ConfigurationMessage::SetCachedSize(int size) const { @@ -9244,8 +9582,8 @@ void ConfigurationMessage::Clear() { _impl_.profilekey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(_impl_.pro_ != nullptr); - _impl_.pro_->Clear(); + GOOGLE_DCHECK(_impl_.proconfig_ != nullptr); + _impl_.proconfig_->Clear(); } } _impl_._has_bits_.Clear(); @@ -9326,10 +9664,10 @@ const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseC } else goto handle_unusual; continue; - // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + // optional .SessionProtos.ProConfig proConfig = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - ptr = ctx->ParseMessage(_internal_mutable_pro(), ptr); + ptr = ctx->ParseMessage(_internal_mutable_proconfig(), ptr); CHK_(ptr); } else goto handle_unusual; @@ -9405,11 +9743,11 @@ uint8_t* ConfigurationMessage::_InternalSerialize( InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); } - // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + // optional .SessionProtos.ProConfig proConfig = 7; if (cached_has_bits & 0x00000008u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, _Internal::pro(this), - _Internal::pro(this).GetCachedSize(), target, stream); + InternalWriteMessage(7, _Internal::proconfig(this), + _Internal::proconfig(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -9473,11 +9811,11 @@ size_t ConfigurationMessage::ByteSizeLong() const { this->_internal_profilekey()); } - // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; + // optional .SessionProtos.ProConfig proConfig = 7; if (cached_has_bits & 0x00000008u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.pro_); + *_impl_.proconfig_); } } @@ -9517,8 +9855,8 @@ void ConfigurationMessage::MergeFrom(const ConfigurationMessage& from) { _this->_internal_set_profilekey(from._internal_profilekey()); } if (cached_has_bits & 0x00000008u) { - _this->_internal_mutable_pro()->::SessionProtos::ConfigurationMessage_Pro::MergeFrom( - from._internal_pro()); + _this->_internal_mutable_proconfig()->::SessionProtos::ProConfig::MergeFrom( + from._internal_proconfig()); } } _this->_internal_metadata_.MergeFrom(from._internal_metadata_); @@ -9536,8 +9874,8 @@ bool ConfigurationMessage::IsInitialized() const { return false; if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.contacts_)) return false; - if (_internal_has_pro()) { - if (!_impl_.pro_->IsInitialized()) return false; + if (_internal_has_proconfig()) { + if (!_impl_.proconfig_->IsInitialized()) return false; } return true; } @@ -9563,7 +9901,7 @@ void ConfigurationMessage::InternalSwap(ConfigurationMessage* other) { &_impl_.profilekey_, lhs_arena, &other->_impl_.profilekey_, rhs_arena ); - swap(_impl_.pro_, other->_impl_.pro_); + swap(_impl_.proconfig_, other->_impl_.proconfig_); } std::string ConfigurationMessage::GetTypeName() const { @@ -10829,6 +11167,18 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::MessageRequestResponse* Arena::CreateMaybeMessage< ::SessionProtos::MessageRequestResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::MessageRequestResponse >(arena); } +template<> PROTOBUF_NOINLINE ::SessionProtos::ProProof* +Arena::CreateMaybeMessage< ::SessionProtos::ProProof >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ProProof >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::ProConfig* +Arena::CreateMaybeMessage< ::SessionProtos::ProConfig >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ProConfig >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::ProMessageConfig* +Arena::CreateMaybeMessage< ::SessionProtos::ProMessageConfig >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ProMessageConfig >(arena); +} template<> PROTOBUF_NOINLINE ::SessionProtos::Content* Arena::CreateMaybeMessage< ::SessionProtos::Content >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::Content >(arena); @@ -10889,14 +11239,6 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_Contact* Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_Contact >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_Contact >(arena); } -template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_ProProof* -Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_ProProof >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_ProProof >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_Pro* -Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_Pro >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_Pro >(arena); -} template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage* Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage >(arena); diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index e05be469..ee1c8b5e 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -58,12 +58,6 @@ extern ConfigurationMessage_ClosedGroupDefaultTypeInternal _ConfigurationMessage class ConfigurationMessage_Contact; struct ConfigurationMessage_ContactDefaultTypeInternal; extern ConfigurationMessage_ContactDefaultTypeInternal _ConfigurationMessage_Contact_default_instance_; -class ConfigurationMessage_Pro; -struct ConfigurationMessage_ProDefaultTypeInternal; -extern ConfigurationMessage_ProDefaultTypeInternal _ConfigurationMessage_Pro_default_instance_; -class ConfigurationMessage_ProProof; -struct ConfigurationMessage_ProProofDefaultTypeInternal; -extern ConfigurationMessage_ProProofDefaultTypeInternal _ConfigurationMessage_ProProof_default_instance_; class Content; struct ContentDefaultTypeInternal; extern ContentDefaultTypeInternal _Content_default_instance_; @@ -106,6 +100,15 @@ extern LokiProfileDefaultTypeInternal _LokiProfile_default_instance_; class MessageRequestResponse; struct MessageRequestResponseDefaultTypeInternal; extern MessageRequestResponseDefaultTypeInternal _MessageRequestResponse_default_instance_; +class ProConfig; +struct ProConfigDefaultTypeInternal; +extern ProConfigDefaultTypeInternal _ProConfig_default_instance_; +class ProMessageConfig; +struct ProMessageConfigDefaultTypeInternal; +extern ProMessageConfigDefaultTypeInternal _ProMessageConfig_default_instance_; +class ProProof; +struct ProProofDefaultTypeInternal; +extern ProProofDefaultTypeInternal _ProProof_default_instance_; class ReceiptMessage; struct ReceiptMessageDefaultTypeInternal; extern ReceiptMessageDefaultTypeInternal _ReceiptMessage_default_instance_; @@ -125,8 +128,6 @@ template<> ::SessionProtos::CallMessage* Arena::CreateMaybeMessage<::SessionProt template<> ::SessionProtos::ConfigurationMessage* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage>(Arena*); template<> ::SessionProtos::ConfigurationMessage_ClosedGroup* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_ClosedGroup>(Arena*); template<> ::SessionProtos::ConfigurationMessage_Contact* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Contact>(Arena*); -template<> ::SessionProtos::ConfigurationMessage_Pro* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Pro>(Arena*); -template<> ::SessionProtos::ConfigurationMessage_ProProof* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_ProProof>(Arena*); template<> ::SessionProtos::Content* Arena::CreateMaybeMessage<::SessionProtos::Content>(Arena*); template<> ::SessionProtos::DataExtractionNotification* Arena::CreateMaybeMessage<::SessionProtos::DataExtractionNotification>(Arena*); template<> ::SessionProtos::DataMessage* Arena::CreateMaybeMessage<::SessionProtos::DataMessage>(Arena*); @@ -141,6 +142,9 @@ template<> ::SessionProtos::Envelope* Arena::CreateMaybeMessage<::SessionProtos: template<> ::SessionProtos::KeyPair* Arena::CreateMaybeMessage<::SessionProtos::KeyPair>(Arena*); template<> ::SessionProtos::LokiProfile* Arena::CreateMaybeMessage<::SessionProtos::LokiProfile>(Arena*); template<> ::SessionProtos::MessageRequestResponse* Arena::CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(Arena*); +template<> ::SessionProtos::ProConfig* Arena::CreateMaybeMessage<::SessionProtos::ProConfig>(Arena*); +template<> ::SessionProtos::ProMessageConfig* Arena::CreateMaybeMessage<::SessionProtos::ProMessageConfig>(Arena*); +template<> ::SessionProtos::ProProof* Arena::CreateMaybeMessage<::SessionProtos::ProProof>(Arena*); template<> ::SessionProtos::ReceiptMessage* Arena::CreateMaybeMessage<::SessionProtos::ReceiptMessage>(Arena*); template<> ::SessionProtos::SharedConfigMessage* Arena::CreateMaybeMessage<::SessionProtos::SharedConfigMessage>(Arena*); template<> ::SessionProtos::TypingMessage* Arena::CreateMaybeMessage<::SessionProtos::TypingMessage>(Arena*); @@ -1156,24 +1160,24 @@ class MessageRequestResponse final : }; // ------------------------------------------------------------------- -class Content final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.Content) */ { +class ProProof final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProProof) */ { public: - inline Content() : Content(nullptr) {} - ~Content() override; - explicit PROTOBUF_CONSTEXPR Content(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ProProof() : ProProof(nullptr) {} + ~ProProof() override; + explicit PROTOBUF_CONSTEXPR ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - Content(const Content& from); - Content(Content&& from) noexcept - : Content() { + ProProof(const ProProof& from); + ProProof(ProProof&& from) noexcept + : ProProof() { *this = ::std::move(from); } - inline Content& operator=(const Content& from) { + inline ProProof& operator=(const ProProof& from) { CopyFrom(from); return *this; } - inline Content& operator=(Content&& from) noexcept { + inline ProProof& operator=(ProProof&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1194,20 +1198,20 @@ class Content final : return _internal_metadata_.mutable_unknown_fields(); } - static const Content& default_instance() { + static const ProProof& default_instance() { return *internal_default_instance(); } - static inline const Content* internal_default_instance() { - return reinterpret_cast( - &_Content_default_instance_); + static inline const ProProof* internal_default_instance() { + return reinterpret_cast( + &_ProProof_default_instance_); } static constexpr int kIndexInFileMessages = 4; - friend void swap(Content& a, Content& b) { + friend void swap(ProProof& a, ProProof& b) { a.Swap(&b); } - inline void Swap(Content* other) { + inline void Swap(ProProof* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1220,7 +1224,7 @@ class Content final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(Content* other) { + void UnsafeArenaSwap(ProProof* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1228,12 +1232,12 @@ class Content final : // implements Message ---------------------------------------------- - Content* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const Content& from); - void MergeFrom(const Content& from); + void CopyFrom(const ProProof& from); + void MergeFrom(const ProProof& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1247,15 +1251,15 @@ class Content final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(Content* other); + void InternalSwap(ProProof* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.Content"; + return "SessionProtos.ProProof"; } protected: - explicit Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -1266,221 +1270,134 @@ class Content final : // accessors ------------------------------------------------------- enum : int { - kDataMessageFieldNumber = 1, - kCallMessageFieldNumber = 3, - kReceiptMessageFieldNumber = 5, - kTypingMessageFieldNumber = 6, - kConfigurationMessageFieldNumber = 7, - kDataExtractionNotificationFieldNumber = 8, - kUnsendRequestFieldNumber = 9, - kMessageRequestResponseFieldNumber = 10, - kSharedConfigMessageFieldNumber = 11, + kGenIndexHashFieldNumber = 2, + kRotatingPublicKeyFieldNumber = 3, + kSigFieldNumber = 5, + kExpiryUnixTsFieldNumber = 4, + kVersionFieldNumber = 1, }; - // optional .SessionProtos.DataMessage dataMessage = 1; - bool has_datamessage() const; - private: - bool _internal_has_datamessage() const; - public: - void clear_datamessage(); - const ::SessionProtos::DataMessage& datamessage() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage* release_datamessage(); - ::SessionProtos::DataMessage* mutable_datamessage(); - void set_allocated_datamessage(::SessionProtos::DataMessage* datamessage); - private: - const ::SessionProtos::DataMessage& _internal_datamessage() const; - ::SessionProtos::DataMessage* _internal_mutable_datamessage(); - public: - void unsafe_arena_set_allocated_datamessage( - ::SessionProtos::DataMessage* datamessage); - ::SessionProtos::DataMessage* unsafe_arena_release_datamessage(); - - // optional .SessionProtos.CallMessage callMessage = 3; - bool has_callmessage() const; - private: - bool _internal_has_callmessage() const; - public: - void clear_callmessage(); - const ::SessionProtos::CallMessage& callmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::CallMessage* release_callmessage(); - ::SessionProtos::CallMessage* mutable_callmessage(); - void set_allocated_callmessage(::SessionProtos::CallMessage* callmessage); - private: - const ::SessionProtos::CallMessage& _internal_callmessage() const; - ::SessionProtos::CallMessage* _internal_mutable_callmessage(); - public: - void unsafe_arena_set_allocated_callmessage( - ::SessionProtos::CallMessage* callmessage); - ::SessionProtos::CallMessage* unsafe_arena_release_callmessage(); - - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - bool has_receiptmessage() const; - private: - bool _internal_has_receiptmessage() const; - public: - void clear_receiptmessage(); - const ::SessionProtos::ReceiptMessage& receiptmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::ReceiptMessage* release_receiptmessage(); - ::SessionProtos::ReceiptMessage* mutable_receiptmessage(); - void set_allocated_receiptmessage(::SessionProtos::ReceiptMessage* receiptmessage); - private: - const ::SessionProtos::ReceiptMessage& _internal_receiptmessage() const; - ::SessionProtos::ReceiptMessage* _internal_mutable_receiptmessage(); - public: - void unsafe_arena_set_allocated_receiptmessage( - ::SessionProtos::ReceiptMessage* receiptmessage); - ::SessionProtos::ReceiptMessage* unsafe_arena_release_receiptmessage(); - - // optional .SessionProtos.TypingMessage typingMessage = 6; - bool has_typingmessage() const; - private: - bool _internal_has_typingmessage() const; - public: - void clear_typingmessage(); - const ::SessionProtos::TypingMessage& typingmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::TypingMessage* release_typingmessage(); - ::SessionProtos::TypingMessage* mutable_typingmessage(); - void set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage); - private: - const ::SessionProtos::TypingMessage& _internal_typingmessage() const; - ::SessionProtos::TypingMessage* _internal_mutable_typingmessage(); - public: - void unsafe_arena_set_allocated_typingmessage( - ::SessionProtos::TypingMessage* typingmessage); - ::SessionProtos::TypingMessage* unsafe_arena_release_typingmessage(); - - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - bool has_configurationmessage() const; + // required bytes genIndexHash = 2; + bool has_genindexhash() const; private: - bool _internal_has_configurationmessage() const; + bool _internal_has_genindexhash() const; public: - void clear_configurationmessage(); - const ::SessionProtos::ConfigurationMessage& configurationmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::ConfigurationMessage* release_configurationmessage(); - ::SessionProtos::ConfigurationMessage* mutable_configurationmessage(); - void set_allocated_configurationmessage(::SessionProtos::ConfigurationMessage* configurationmessage); + void clear_genindexhash(); + const std::string& genindexhash() const; + template + void set_genindexhash(ArgT0&& arg0, ArgT... args); + std::string* mutable_genindexhash(); + PROTOBUF_NODISCARD std::string* release_genindexhash(); + void set_allocated_genindexhash(std::string* genindexhash); private: - const ::SessionProtos::ConfigurationMessage& _internal_configurationmessage() const; - ::SessionProtos::ConfigurationMessage* _internal_mutable_configurationmessage(); + const std::string& _internal_genindexhash() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); + std::string* _internal_mutable_genindexhash(); public: - void unsafe_arena_set_allocated_configurationmessage( - ::SessionProtos::ConfigurationMessage* configurationmessage); - ::SessionProtos::ConfigurationMessage* unsafe_arena_release_configurationmessage(); - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - bool has_dataextractionnotification() const; + // required bytes rotatingPublicKey = 3; + bool has_rotatingpublickey() const; private: - bool _internal_has_dataextractionnotification() const; + bool _internal_has_rotatingpublickey() const; public: - void clear_dataextractionnotification(); - const ::SessionProtos::DataExtractionNotification& dataextractionnotification() const; - PROTOBUF_NODISCARD ::SessionProtos::DataExtractionNotification* release_dataextractionnotification(); - ::SessionProtos::DataExtractionNotification* mutable_dataextractionnotification(); - void set_allocated_dataextractionnotification(::SessionProtos::DataExtractionNotification* dataextractionnotification); + void clear_rotatingpublickey(); + const std::string& rotatingpublickey() const; + template + void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingpublickey(); + PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); + void set_allocated_rotatingpublickey(std::string* rotatingpublickey); private: - const ::SessionProtos::DataExtractionNotification& _internal_dataextractionnotification() const; - ::SessionProtos::DataExtractionNotification* _internal_mutable_dataextractionnotification(); + const std::string& _internal_rotatingpublickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); + std::string* _internal_mutable_rotatingpublickey(); public: - void unsafe_arena_set_allocated_dataextractionnotification( - ::SessionProtos::DataExtractionNotification* dataextractionnotification); - ::SessionProtos::DataExtractionNotification* unsafe_arena_release_dataextractionnotification(); - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - bool has_unsendrequest() const; + // required bytes sig = 5; + bool has_sig() const; private: - bool _internal_has_unsendrequest() const; + bool _internal_has_sig() const; public: - void clear_unsendrequest(); - const ::SessionProtos::UnsendRequest& unsendrequest() const; - PROTOBUF_NODISCARD ::SessionProtos::UnsendRequest* release_unsendrequest(); - ::SessionProtos::UnsendRequest* mutable_unsendrequest(); - void set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest); + void clear_sig(); + const std::string& sig() const; + template + void set_sig(ArgT0&& arg0, ArgT... args); + std::string* mutable_sig(); + PROTOBUF_NODISCARD std::string* release_sig(); + void set_allocated_sig(std::string* sig); private: - const ::SessionProtos::UnsendRequest& _internal_unsendrequest() const; - ::SessionProtos::UnsendRequest* _internal_mutable_unsendrequest(); + const std::string& _internal_sig() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); + std::string* _internal_mutable_sig(); public: - void unsafe_arena_set_allocated_unsendrequest( - ::SessionProtos::UnsendRequest* unsendrequest); - ::SessionProtos::UnsendRequest* unsafe_arena_release_unsendrequest(); - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - bool has_messagerequestresponse() const; + // required uint64 expiryUnixTs = 4; + bool has_expiryunixts() const; private: - bool _internal_has_messagerequestresponse() const; + bool _internal_has_expiryunixts() const; public: - void clear_messagerequestresponse(); - const ::SessionProtos::MessageRequestResponse& messagerequestresponse() const; - PROTOBUF_NODISCARD ::SessionProtos::MessageRequestResponse* release_messagerequestresponse(); - ::SessionProtos::MessageRequestResponse* mutable_messagerequestresponse(); - void set_allocated_messagerequestresponse(::SessionProtos::MessageRequestResponse* messagerequestresponse); + void clear_expiryunixts(); + uint64_t expiryunixts() const; + void set_expiryunixts(uint64_t value); private: - const ::SessionProtos::MessageRequestResponse& _internal_messagerequestresponse() const; - ::SessionProtos::MessageRequestResponse* _internal_mutable_messagerequestresponse(); + uint64_t _internal_expiryunixts() const; + void _internal_set_expiryunixts(uint64_t value); public: - void unsafe_arena_set_allocated_messagerequestresponse( - ::SessionProtos::MessageRequestResponse* messagerequestresponse); - ::SessionProtos::MessageRequestResponse* unsafe_arena_release_messagerequestresponse(); - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - bool has_sharedconfigmessage() const; + // required uint32 version = 1; + bool has_version() const; private: - bool _internal_has_sharedconfigmessage() const; + bool _internal_has_version() const; public: - void clear_sharedconfigmessage(); - const ::SessionProtos::SharedConfigMessage& sharedconfigmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::SharedConfigMessage* release_sharedconfigmessage(); - ::SessionProtos::SharedConfigMessage* mutable_sharedconfigmessage(); - void set_allocated_sharedconfigmessage(::SessionProtos::SharedConfigMessage* sharedconfigmessage); + void clear_version(); + uint32_t version() const; + void set_version(uint32_t value); private: - const ::SessionProtos::SharedConfigMessage& _internal_sharedconfigmessage() const; - ::SessionProtos::SharedConfigMessage* _internal_mutable_sharedconfigmessage(); + uint32_t _internal_version() const; + void _internal_set_version(uint32_t value); public: - void unsafe_arena_set_allocated_sharedconfigmessage( - ::SessionProtos::SharedConfigMessage* sharedconfigmessage); - ::SessionProtos::SharedConfigMessage* unsafe_arena_release_sharedconfigmessage(); - // @@protoc_insertion_point(class_scope:SessionProtos.Content) + // @@protoc_insertion_point(class_scope:SessionProtos.ProProof) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::SessionProtos::DataMessage* datamessage_; - ::SessionProtos::CallMessage* callmessage_; - ::SessionProtos::ReceiptMessage* receiptmessage_; - ::SessionProtos::TypingMessage* typingmessage_; - ::SessionProtos::ConfigurationMessage* configurationmessage_; - ::SessionProtos::DataExtractionNotification* dataextractionnotification_; - ::SessionProtos::UnsendRequest* unsendrequest_; - ::SessionProtos::MessageRequestResponse* messagerequestresponse_; - ::SessionProtos::SharedConfigMessage* sharedconfigmessage_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; + uint64_t expiryunixts_; + uint32_t version_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class CallMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.CallMessage) */ { +class ProConfig final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProConfig) */ { public: - inline CallMessage() : CallMessage(nullptr) {} - ~CallMessage() override; - explicit PROTOBUF_CONSTEXPR CallMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ProConfig() : ProConfig(nullptr) {} + ~ProConfig() override; + explicit PROTOBUF_CONSTEXPR ProConfig(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - CallMessage(const CallMessage& from); - CallMessage(CallMessage&& from) noexcept - : CallMessage() { + ProConfig(const ProConfig& from); + ProConfig(ProConfig&& from) noexcept + : ProConfig() { *this = ::std::move(from); } - inline CallMessage& operator=(const CallMessage& from) { + inline ProConfig& operator=(const ProConfig& from) { CopyFrom(from); return *this; } - inline CallMessage& operator=(CallMessage&& from) noexcept { + inline ProConfig& operator=(ProConfig&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1501,20 +1418,20 @@ class CallMessage final : return _internal_metadata_.mutable_unknown_fields(); } - static const CallMessage& default_instance() { + static const ProConfig& default_instance() { return *internal_default_instance(); } - static inline const CallMessage* internal_default_instance() { - return reinterpret_cast( - &_CallMessage_default_instance_); + static inline const ProConfig* internal_default_instance() { + return reinterpret_cast( + &_ProConfig_default_instance_); } static constexpr int kIndexInFileMessages = 5; - friend void swap(CallMessage& a, CallMessage& b) { + friend void swap(ProConfig& a, ProConfig& b) { a.Swap(&b); } - inline void Swap(CallMessage* other) { + inline void Swap(ProConfig* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1527,7 +1444,7 @@ class CallMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(CallMessage* other) { + void UnsafeArenaSwap(ProConfig* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1535,12 +1452,12 @@ class CallMessage final : // implements Message ---------------------------------------------- - CallMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ProConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const CallMessage& from); - void MergeFrom(const CallMessage& from); + void CopyFrom(const ProConfig& from); + void MergeFrom(const ProConfig& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1554,15 +1471,15 @@ class CallMessage final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(CallMessage* other); + void InternalSwap(ProConfig* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.CallMessage"; + return "SessionProtos.ProConfig"; } protected: - explicit CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -1570,151 +1487,49 @@ class CallMessage final : // nested types ---------------------------------------------------- - typedef CallMessage_Type Type; - static constexpr Type PRE_OFFER = - CallMessage_Type_PRE_OFFER; - static constexpr Type OFFER = - CallMessage_Type_OFFER; - static constexpr Type ANSWER = - CallMessage_Type_ANSWER; - static constexpr Type PROVISIONAL_ANSWER = - CallMessage_Type_PROVISIONAL_ANSWER; - static constexpr Type ICE_CANDIDATES = - CallMessage_Type_ICE_CANDIDATES; - static constexpr Type END_CALL = - CallMessage_Type_END_CALL; - static inline bool Type_IsValid(int value) { - return CallMessage_Type_IsValid(value); - } - static constexpr Type Type_MIN = - CallMessage_Type_Type_MIN; - static constexpr Type Type_MAX = - CallMessage_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - CallMessage_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return CallMessage_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return CallMessage_Type_Parse(name, value); - } - // accessors ------------------------------------------------------- enum : int { - kSdpsFieldNumber = 2, - kSdpMLineIndexesFieldNumber = 3, - kSdpMidsFieldNumber = 4, - kUuidFieldNumber = 5, - kTypeFieldNumber = 1, + kRotatingPrivKeyFieldNumber = 1, + kProofFieldNumber = 2, }; - // repeated string sdps = 2; - int sdps_size() const; - private: - int _internal_sdps_size() const; - public: - void clear_sdps(); - const std::string& sdps(int index) const; - std::string* mutable_sdps(int index); - void set_sdps(int index, const std::string& value); - void set_sdps(int index, std::string&& value); - void set_sdps(int index, const char* value); - void set_sdps(int index, const char* value, size_t size); - std::string* add_sdps(); - void add_sdps(const std::string& value); - void add_sdps(std::string&& value); - void add_sdps(const char* value); - void add_sdps(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdps() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdps(); - private: - const std::string& _internal_sdps(int index) const; - std::string* _internal_add_sdps(); - public: - - // repeated uint32 sdpMLineIndexes = 3; - int sdpmlineindexes_size() const; - private: - int _internal_sdpmlineindexes_size() const; - public: - void clear_sdpmlineindexes(); - private: - uint32_t _internal_sdpmlineindexes(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& - _internal_sdpmlineindexes() const; - void _internal_add_sdpmlineindexes(uint32_t value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* - _internal_mutable_sdpmlineindexes(); - public: - uint32_t sdpmlineindexes(int index) const; - void set_sdpmlineindexes(int index, uint32_t value); - void add_sdpmlineindexes(uint32_t value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& - sdpmlineindexes() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* - mutable_sdpmlineindexes(); - - // repeated string sdpMids = 4; - int sdpmids_size() const; - private: - int _internal_sdpmids_size() const; - public: - void clear_sdpmids(); - const std::string& sdpmids(int index) const; - std::string* mutable_sdpmids(int index); - void set_sdpmids(int index, const std::string& value); - void set_sdpmids(int index, std::string&& value); - void set_sdpmids(int index, const char* value); - void set_sdpmids(int index, const char* value, size_t size); - std::string* add_sdpmids(); - void add_sdpmids(const std::string& value); - void add_sdpmids(std::string&& value); - void add_sdpmids(const char* value); - void add_sdpmids(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdpmids() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdpmids(); - private: - const std::string& _internal_sdpmids(int index) const; - std::string* _internal_add_sdpmids(); - public: - - // required string uuid = 5; - bool has_uuid() const; + // required bytes rotatingPrivKey = 1; + bool has_rotatingprivkey() const; private: - bool _internal_has_uuid() const; + bool _internal_has_rotatingprivkey() const; public: - void clear_uuid(); - const std::string& uuid() const; + void clear_rotatingprivkey(); + const std::string& rotatingprivkey() const; template - void set_uuid(ArgT0&& arg0, ArgT... args); - std::string* mutable_uuid(); - PROTOBUF_NODISCARD std::string* release_uuid(); - void set_allocated_uuid(std::string* uuid); + void set_rotatingprivkey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingprivkey(); + PROTOBUF_NODISCARD std::string* release_rotatingprivkey(); + void set_allocated_rotatingprivkey(std::string* rotatingprivkey); private: - const std::string& _internal_uuid() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_uuid(const std::string& value); - std::string* _internal_mutable_uuid(); + const std::string& _internal_rotatingprivkey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingprivkey(const std::string& value); + std::string* _internal_mutable_rotatingprivkey(); public: - // required .SessionProtos.CallMessage.Type type = 1; - bool has_type() const; + // required .SessionProtos.ProProof proof = 2; + bool has_proof() const; private: - bool _internal_has_type() const; + bool _internal_has_proof() const; public: - void clear_type(); - ::SessionProtos::CallMessage_Type type() const; - void set_type(::SessionProtos::CallMessage_Type value); + void clear_proof(); + const ::SessionProtos::ProProof& proof() const; + PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); + ::SessionProtos::ProProof* mutable_proof(); + void set_allocated_proof(::SessionProtos::ProProof* proof); private: - ::SessionProtos::CallMessage_Type _internal_type() const; - void _internal_set_type(::SessionProtos::CallMessage_Type value); + const ::SessionProtos::ProProof& _internal_proof() const; + ::SessionProtos::ProProof* _internal_mutable_proof(); public: + void unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof); + ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // @@protoc_insertion_point(class_scope:SessionProtos.CallMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.ProConfig) private: class _Internal; @@ -1727,35 +1542,32 @@ class CallMessage final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdps_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t > sdpmlineindexes_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdpmids_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr uuid_; - int type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingprivkey_; + ::SessionProtos::ProProof* proof_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class KeyPair final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.KeyPair) */ { +class ProMessageConfig final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProMessageConfig) */ { public: - inline KeyPair() : KeyPair(nullptr) {} - ~KeyPair() override; - explicit PROTOBUF_CONSTEXPR KeyPair(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ProMessageConfig() : ProMessageConfig(nullptr) {} + ~ProMessageConfig() override; + explicit PROTOBUF_CONSTEXPR ProMessageConfig(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - KeyPair(const KeyPair& from); - KeyPair(KeyPair&& from) noexcept - : KeyPair() { + ProMessageConfig(const ProMessageConfig& from); + ProMessageConfig(ProMessageConfig&& from) noexcept + : ProMessageConfig() { *this = ::std::move(from); } - inline KeyPair& operator=(const KeyPair& from) { + inline ProMessageConfig& operator=(const ProMessageConfig& from) { CopyFrom(from); return *this; } - inline KeyPair& operator=(KeyPair&& from) noexcept { + inline ProMessageConfig& operator=(ProMessageConfig&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1776,20 +1588,20 @@ class KeyPair final : return _internal_metadata_.mutable_unknown_fields(); } - static const KeyPair& default_instance() { + static const ProMessageConfig& default_instance() { return *internal_default_instance(); } - static inline const KeyPair* internal_default_instance() { - return reinterpret_cast( - &_KeyPair_default_instance_); + static inline const ProMessageConfig* internal_default_instance() { + return reinterpret_cast( + &_ProMessageConfig_default_instance_); } static constexpr int kIndexInFileMessages = 6; - friend void swap(KeyPair& a, KeyPair& b) { + friend void swap(ProMessageConfig& a, ProMessageConfig& b) { a.Swap(&b); } - inline void Swap(KeyPair* other) { + inline void Swap(ProMessageConfig* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1802,7 +1614,7 @@ class KeyPair final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(KeyPair* other) { + void UnsafeArenaSwap(ProMessageConfig* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1810,12 +1622,12 @@ class KeyPair final : // implements Message ---------------------------------------------- - KeyPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ProMessageConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const KeyPair& from); - void MergeFrom(const KeyPair& from); + void CopyFrom(const ProMessageConfig& from); + void MergeFrom(const ProMessageConfig& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1829,15 +1641,15 @@ class KeyPair final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(KeyPair* other); + void InternalSwap(ProMessageConfig* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.KeyPair"; + return "SessionProtos.ProMessageConfig"; } protected: - explicit KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ProMessageConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -1848,46 +1660,41 @@ class KeyPair final : // accessors ------------------------------------------------------- enum : int { - kPublicKeyFieldNumber = 1, - kPrivateKeyFieldNumber = 2, + kProofFieldNumber = 1, + kFlagsFieldNumber = 2, }; - // required bytes publicKey = 1; - bool has_publickey() const; + // required .SessionProtos.ProProof proof = 1; + bool has_proof() const; private: - bool _internal_has_publickey() const; + bool _internal_has_proof() const; public: - void clear_publickey(); - const std::string& publickey() const; - template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); + void clear_proof(); + const ::SessionProtos::ProProof& proof() const; + PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); + ::SessionProtos::ProProof* mutable_proof(); + void set_allocated_proof(::SessionProtos::ProProof* proof); private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); + const ::SessionProtos::ProProof& _internal_proof() const; + ::SessionProtos::ProProof* _internal_mutable_proof(); public: + void unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof); + ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // required bytes privateKey = 2; - bool has_privatekey() const; + // required uint32 flags = 2; + bool has_flags() const; private: - bool _internal_has_privatekey() const; + bool _internal_has_flags() const; public: - void clear_privatekey(); - const std::string& privatekey() const; - template - void set_privatekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_privatekey(); - PROTOBUF_NODISCARD std::string* release_privatekey(); - void set_allocated_privatekey(std::string* privatekey); + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); private: - const std::string& _internal_privatekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_privatekey(const std::string& value); - std::string* _internal_mutable_privatekey(); + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.KeyPair) + // @@protoc_insertion_point(class_scope:SessionProtos.ProMessageConfig) private: class _Internal; @@ -1900,32 +1707,32 @@ class KeyPair final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr privatekey_; + ::SessionProtos::ProProof* proof_; + uint32_t flags_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataExtractionNotification final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataExtractionNotification) */ { +class Content final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.Content) */ { public: - inline DataExtractionNotification() : DataExtractionNotification(nullptr) {} - ~DataExtractionNotification() override; - explicit PROTOBUF_CONSTEXPR DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline Content() : Content(nullptr) {} + ~Content() override; + explicit PROTOBUF_CONSTEXPR Content(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataExtractionNotification(const DataExtractionNotification& from); - DataExtractionNotification(DataExtractionNotification&& from) noexcept - : DataExtractionNotification() { + Content(const Content& from); + Content(Content&& from) noexcept + : Content() { *this = ::std::move(from); } - inline DataExtractionNotification& operator=(const DataExtractionNotification& from) { + inline Content& operator=(const Content& from) { CopyFrom(from); return *this; } - inline DataExtractionNotification& operator=(DataExtractionNotification&& from) noexcept { + inline Content& operator=(Content&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1946,20 +1753,20 @@ class DataExtractionNotification final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataExtractionNotification& default_instance() { + static const Content& default_instance() { return *internal_default_instance(); } - static inline const DataExtractionNotification* internal_default_instance() { - return reinterpret_cast( - &_DataExtractionNotification_default_instance_); + static inline const Content* internal_default_instance() { + return reinterpret_cast( + &_Content_default_instance_); } static constexpr int kIndexInFileMessages = 7; - friend void swap(DataExtractionNotification& a, DataExtractionNotification& b) { + friend void swap(Content& a, Content& b) { a.Swap(&b); } - inline void Swap(DataExtractionNotification* other) { + inline void Swap(Content* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1972,7 +1779,7 @@ class DataExtractionNotification final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataExtractionNotification* other) { + void UnsafeArenaSwap(Content* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1980,12 +1787,12 @@ class DataExtractionNotification final : // implements Message ---------------------------------------------- - DataExtractionNotification* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + Content* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataExtractionNotification& from); - void MergeFrom(const DataExtractionNotification& from); + void CopyFrom(const Content& from); + void MergeFrom(const Content& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1999,15 +1806,15 @@ class DataExtractionNotification final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataExtractionNotification* other); + void InternalSwap(Content* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataExtractionNotification"; + return "SessionProtos.Content"; } protected: - explicit DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -2015,65 +1822,201 @@ class DataExtractionNotification final : // nested types ---------------------------------------------------- - typedef DataExtractionNotification_Type Type; - static constexpr Type SCREENSHOT = - DataExtractionNotification_Type_SCREENSHOT; - static constexpr Type MEDIA_SAVED = - DataExtractionNotification_Type_MEDIA_SAVED; - static inline bool Type_IsValid(int value) { - return DataExtractionNotification_Type_IsValid(value); - } - static constexpr Type Type_MIN = - DataExtractionNotification_Type_Type_MIN; - static constexpr Type Type_MAX = - DataExtractionNotification_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - DataExtractionNotification_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return DataExtractionNotification_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return DataExtractionNotification_Type_Parse(name, value); - } - // accessors ------------------------------------------------------- enum : int { - kTimestampFieldNumber = 2, - kTypeFieldNumber = 1, + kDataMessageFieldNumber = 1, + kCallMessageFieldNumber = 3, + kReceiptMessageFieldNumber = 5, + kTypingMessageFieldNumber = 6, + kConfigurationMessageFieldNumber = 7, + kDataExtractionNotificationFieldNumber = 8, + kUnsendRequestFieldNumber = 9, + kMessageRequestResponseFieldNumber = 10, + kSharedConfigMessageFieldNumber = 11, + kProMessageConfigFieldNumber = 12, }; - // optional uint64 timestamp = 2; - bool has_timestamp() const; + // optional .SessionProtos.DataMessage dataMessage = 1; + bool has_datamessage() const; private: - bool _internal_has_timestamp() const; + bool _internal_has_datamessage() const; public: - void clear_timestamp(); - uint64_t timestamp() const; - void set_timestamp(uint64_t value); + void clear_datamessage(); + const ::SessionProtos::DataMessage& datamessage() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage* release_datamessage(); + ::SessionProtos::DataMessage* mutable_datamessage(); + void set_allocated_datamessage(::SessionProtos::DataMessage* datamessage); private: - uint64_t _internal_timestamp() const; - void _internal_set_timestamp(uint64_t value); + const ::SessionProtos::DataMessage& _internal_datamessage() const; + ::SessionProtos::DataMessage* _internal_mutable_datamessage(); public: + void unsafe_arena_set_allocated_datamessage( + ::SessionProtos::DataMessage* datamessage); + ::SessionProtos::DataMessage* unsafe_arena_release_datamessage(); - // required .SessionProtos.DataExtractionNotification.Type type = 1; - bool has_type() const; + // optional .SessionProtos.CallMessage callMessage = 3; + bool has_callmessage() const; private: - bool _internal_has_type() const; + bool _internal_has_callmessage() const; public: - void clear_type(); - ::SessionProtos::DataExtractionNotification_Type type() const; - void set_type(::SessionProtos::DataExtractionNotification_Type value); + void clear_callmessage(); + const ::SessionProtos::CallMessage& callmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::CallMessage* release_callmessage(); + ::SessionProtos::CallMessage* mutable_callmessage(); + void set_allocated_callmessage(::SessionProtos::CallMessage* callmessage); private: - ::SessionProtos::DataExtractionNotification_Type _internal_type() const; - void _internal_set_type(::SessionProtos::DataExtractionNotification_Type value); + const ::SessionProtos::CallMessage& _internal_callmessage() const; + ::SessionProtos::CallMessage* _internal_mutable_callmessage(); public: + void unsafe_arena_set_allocated_callmessage( + ::SessionProtos::CallMessage* callmessage); + ::SessionProtos::CallMessage* unsafe_arena_release_callmessage(); - // @@protoc_insertion_point(class_scope:SessionProtos.DataExtractionNotification) + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + bool has_receiptmessage() const; + private: + bool _internal_has_receiptmessage() const; + public: + void clear_receiptmessage(); + const ::SessionProtos::ReceiptMessage& receiptmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::ReceiptMessage* release_receiptmessage(); + ::SessionProtos::ReceiptMessage* mutable_receiptmessage(); + void set_allocated_receiptmessage(::SessionProtos::ReceiptMessage* receiptmessage); + private: + const ::SessionProtos::ReceiptMessage& _internal_receiptmessage() const; + ::SessionProtos::ReceiptMessage* _internal_mutable_receiptmessage(); + public: + void unsafe_arena_set_allocated_receiptmessage( + ::SessionProtos::ReceiptMessage* receiptmessage); + ::SessionProtos::ReceiptMessage* unsafe_arena_release_receiptmessage(); + + // optional .SessionProtos.TypingMessage typingMessage = 6; + bool has_typingmessage() const; + private: + bool _internal_has_typingmessage() const; + public: + void clear_typingmessage(); + const ::SessionProtos::TypingMessage& typingmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::TypingMessage* release_typingmessage(); + ::SessionProtos::TypingMessage* mutable_typingmessage(); + void set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage); + private: + const ::SessionProtos::TypingMessage& _internal_typingmessage() const; + ::SessionProtos::TypingMessage* _internal_mutable_typingmessage(); + public: + void unsafe_arena_set_allocated_typingmessage( + ::SessionProtos::TypingMessage* typingmessage); + ::SessionProtos::TypingMessage* unsafe_arena_release_typingmessage(); + + // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; + bool has_configurationmessage() const; + private: + bool _internal_has_configurationmessage() const; + public: + void clear_configurationmessage(); + const ::SessionProtos::ConfigurationMessage& configurationmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::ConfigurationMessage* release_configurationmessage(); + ::SessionProtos::ConfigurationMessage* mutable_configurationmessage(); + void set_allocated_configurationmessage(::SessionProtos::ConfigurationMessage* configurationmessage); + private: + const ::SessionProtos::ConfigurationMessage& _internal_configurationmessage() const; + ::SessionProtos::ConfigurationMessage* _internal_mutable_configurationmessage(); + public: + void unsafe_arena_set_allocated_configurationmessage( + ::SessionProtos::ConfigurationMessage* configurationmessage); + ::SessionProtos::ConfigurationMessage* unsafe_arena_release_configurationmessage(); + + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + bool has_dataextractionnotification() const; + private: + bool _internal_has_dataextractionnotification() const; + public: + void clear_dataextractionnotification(); + const ::SessionProtos::DataExtractionNotification& dataextractionnotification() const; + PROTOBUF_NODISCARD ::SessionProtos::DataExtractionNotification* release_dataextractionnotification(); + ::SessionProtos::DataExtractionNotification* mutable_dataextractionnotification(); + void set_allocated_dataextractionnotification(::SessionProtos::DataExtractionNotification* dataextractionnotification); + private: + const ::SessionProtos::DataExtractionNotification& _internal_dataextractionnotification() const; + ::SessionProtos::DataExtractionNotification* _internal_mutable_dataextractionnotification(); + public: + void unsafe_arena_set_allocated_dataextractionnotification( + ::SessionProtos::DataExtractionNotification* dataextractionnotification); + ::SessionProtos::DataExtractionNotification* unsafe_arena_release_dataextractionnotification(); + + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + bool has_unsendrequest() const; + private: + bool _internal_has_unsendrequest() const; + public: + void clear_unsendrequest(); + const ::SessionProtos::UnsendRequest& unsendrequest() const; + PROTOBUF_NODISCARD ::SessionProtos::UnsendRequest* release_unsendrequest(); + ::SessionProtos::UnsendRequest* mutable_unsendrequest(); + void set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest); + private: + const ::SessionProtos::UnsendRequest& _internal_unsendrequest() const; + ::SessionProtos::UnsendRequest* _internal_mutable_unsendrequest(); + public: + void unsafe_arena_set_allocated_unsendrequest( + ::SessionProtos::UnsendRequest* unsendrequest); + ::SessionProtos::UnsendRequest* unsafe_arena_release_unsendrequest(); + + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + bool has_messagerequestresponse() const; + private: + bool _internal_has_messagerequestresponse() const; + public: + void clear_messagerequestresponse(); + const ::SessionProtos::MessageRequestResponse& messagerequestresponse() const; + PROTOBUF_NODISCARD ::SessionProtos::MessageRequestResponse* release_messagerequestresponse(); + ::SessionProtos::MessageRequestResponse* mutable_messagerequestresponse(); + void set_allocated_messagerequestresponse(::SessionProtos::MessageRequestResponse* messagerequestresponse); + private: + const ::SessionProtos::MessageRequestResponse& _internal_messagerequestresponse() const; + ::SessionProtos::MessageRequestResponse* _internal_mutable_messagerequestresponse(); + public: + void unsafe_arena_set_allocated_messagerequestresponse( + ::SessionProtos::MessageRequestResponse* messagerequestresponse); + ::SessionProtos::MessageRequestResponse* unsafe_arena_release_messagerequestresponse(); + + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + bool has_sharedconfigmessage() const; + private: + bool _internal_has_sharedconfigmessage() const; + public: + void clear_sharedconfigmessage(); + const ::SessionProtos::SharedConfigMessage& sharedconfigmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::SharedConfigMessage* release_sharedconfigmessage(); + ::SessionProtos::SharedConfigMessage* mutable_sharedconfigmessage(); + void set_allocated_sharedconfigmessage(::SessionProtos::SharedConfigMessage* sharedconfigmessage); + private: + const ::SessionProtos::SharedConfigMessage& _internal_sharedconfigmessage() const; + ::SessionProtos::SharedConfigMessage* _internal_mutable_sharedconfigmessage(); + public: + void unsafe_arena_set_allocated_sharedconfigmessage( + ::SessionProtos::SharedConfigMessage* sharedconfigmessage); + ::SessionProtos::SharedConfigMessage* unsafe_arena_release_sharedconfigmessage(); + + // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; + bool has_promessageconfig() const; + private: + bool _internal_has_promessageconfig() const; + public: + void clear_promessageconfig(); + const ::SessionProtos::ProMessageConfig& promessageconfig() const; + PROTOBUF_NODISCARD ::SessionProtos::ProMessageConfig* release_promessageconfig(); + ::SessionProtos::ProMessageConfig* mutable_promessageconfig(); + void set_allocated_promessageconfig(::SessionProtos::ProMessageConfig* promessageconfig); + private: + const ::SessionProtos::ProMessageConfig& _internal_promessageconfig() const; + ::SessionProtos::ProMessageConfig* _internal_mutable_promessageconfig(); + public: + void unsafe_arena_set_allocated_promessageconfig( + ::SessionProtos::ProMessageConfig* promessageconfig); + ::SessionProtos::ProMessageConfig* unsafe_arena_release_promessageconfig(); + + // @@protoc_insertion_point(class_scope:SessionProtos.Content) private: class _Internal; @@ -2083,32 +2026,40 @@ class DataExtractionNotification final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - uint64_t timestamp_; - int type_; + ::SessionProtos::DataMessage* datamessage_; + ::SessionProtos::CallMessage* callmessage_; + ::SessionProtos::ReceiptMessage* receiptmessage_; + ::SessionProtos::TypingMessage* typingmessage_; + ::SessionProtos::ConfigurationMessage* configurationmessage_; + ::SessionProtos::DataExtractionNotification* dataextractionnotification_; + ::SessionProtos::UnsendRequest* unsendrequest_; + ::SessionProtos::MessageRequestResponse* messagerequestresponse_; + ::SessionProtos::SharedConfigMessage* sharedconfigmessage_; + ::SessionProtos::ProMessageConfig* promessageconfig_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class LokiProfile final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.LokiProfile) */ { +class CallMessage final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.CallMessage) */ { public: - inline LokiProfile() : LokiProfile(nullptr) {} - ~LokiProfile() override; - explicit PROTOBUF_CONSTEXPR LokiProfile(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline CallMessage() : CallMessage(nullptr) {} + ~CallMessage() override; + explicit PROTOBUF_CONSTEXPR CallMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - LokiProfile(const LokiProfile& from); - LokiProfile(LokiProfile&& from) noexcept - : LokiProfile() { + CallMessage(const CallMessage& from); + CallMessage(CallMessage&& from) noexcept + : CallMessage() { *this = ::std::move(from); } - inline LokiProfile& operator=(const LokiProfile& from) { + inline CallMessage& operator=(const CallMessage& from) { CopyFrom(from); return *this; } - inline LokiProfile& operator=(LokiProfile&& from) noexcept { + inline CallMessage& operator=(CallMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2129,20 +2080,20 @@ class LokiProfile final : return _internal_metadata_.mutable_unknown_fields(); } - static const LokiProfile& default_instance() { + static const CallMessage& default_instance() { return *internal_default_instance(); } - static inline const LokiProfile* internal_default_instance() { - return reinterpret_cast( - &_LokiProfile_default_instance_); + static inline const CallMessage* internal_default_instance() { + return reinterpret_cast( + &_CallMessage_default_instance_); } static constexpr int kIndexInFileMessages = 8; - friend void swap(LokiProfile& a, LokiProfile& b) { + friend void swap(CallMessage& a, CallMessage& b) { a.Swap(&b); } - inline void Swap(LokiProfile* other) { + inline void Swap(CallMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2155,7 +2106,7 @@ class LokiProfile final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(LokiProfile* other) { + void UnsafeArenaSwap(CallMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2163,12 +2114,12 @@ class LokiProfile final : // implements Message ---------------------------------------------- - LokiProfile* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + CallMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const LokiProfile& from); - void MergeFrom(const LokiProfile& from); + void CopyFrom(const CallMessage& from); + void MergeFrom(const CallMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2182,15 +2133,15 @@ class LokiProfile final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(LokiProfile* other); + void InternalSwap(CallMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.LokiProfile"; + return "SessionProtos.CallMessage"; } protected: - explicit LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -2198,84 +2149,192 @@ class LokiProfile final : // nested types ---------------------------------------------------- + typedef CallMessage_Type Type; + static constexpr Type PRE_OFFER = + CallMessage_Type_PRE_OFFER; + static constexpr Type OFFER = + CallMessage_Type_OFFER; + static constexpr Type ANSWER = + CallMessage_Type_ANSWER; + static constexpr Type PROVISIONAL_ANSWER = + CallMessage_Type_PROVISIONAL_ANSWER; + static constexpr Type ICE_CANDIDATES = + CallMessage_Type_ICE_CANDIDATES; + static constexpr Type END_CALL = + CallMessage_Type_END_CALL; + static inline bool Type_IsValid(int value) { + return CallMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + CallMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + CallMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + CallMessage_Type_Type_ARRAYSIZE; + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return CallMessage_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return CallMessage_Type_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kDisplayNameFieldNumber = 1, - kProfilePictureFieldNumber = 2, + kSdpsFieldNumber = 2, + kSdpMLineIndexesFieldNumber = 3, + kSdpMidsFieldNumber = 4, + kUuidFieldNumber = 5, + kTypeFieldNumber = 1, }; - // optional string displayName = 1; - bool has_displayname() const; + // repeated string sdps = 2; + int sdps_size() const; private: - bool _internal_has_displayname() const; + int _internal_sdps_size() const; public: - void clear_displayname(); - const std::string& displayname() const; - template - void set_displayname(ArgT0&& arg0, ArgT... args); - std::string* mutable_displayname(); - PROTOBUF_NODISCARD std::string* release_displayname(); - void set_allocated_displayname(std::string* displayname); + void clear_sdps(); + const std::string& sdps(int index) const; + std::string* mutable_sdps(int index); + void set_sdps(int index, const std::string& value); + void set_sdps(int index, std::string&& value); + void set_sdps(int index, const char* value); + void set_sdps(int index, const char* value, size_t size); + std::string* add_sdps(); + void add_sdps(const std::string& value); + void add_sdps(std::string&& value); + void add_sdps(const char* value); + void add_sdps(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdps() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdps(); private: - const std::string& _internal_displayname() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); - std::string* _internal_mutable_displayname(); + const std::string& _internal_sdps(int index) const; + std::string* _internal_add_sdps(); public: - // optional string profilePicture = 2; - bool has_profilepicture() const; + // repeated uint32 sdpMLineIndexes = 3; + int sdpmlineindexes_size() const; private: - bool _internal_has_profilepicture() const; + int _internal_sdpmlineindexes_size() const; public: - void clear_profilepicture(); - const std::string& profilepicture() const; + void clear_sdpmlineindexes(); + private: + uint32_t _internal_sdpmlineindexes(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& + _internal_sdpmlineindexes() const; + void _internal_add_sdpmlineindexes(uint32_t value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* + _internal_mutable_sdpmlineindexes(); + public: + uint32_t sdpmlineindexes(int index) const; + void set_sdpmlineindexes(int index, uint32_t value); + void add_sdpmlineindexes(uint32_t value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& + sdpmlineindexes() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* + mutable_sdpmlineindexes(); + + // repeated string sdpMids = 4; + int sdpmids_size() const; + private: + int _internal_sdpmids_size() const; + public: + void clear_sdpmids(); + const std::string& sdpmids(int index) const; + std::string* mutable_sdpmids(int index); + void set_sdpmids(int index, const std::string& value); + void set_sdpmids(int index, std::string&& value); + void set_sdpmids(int index, const char* value); + void set_sdpmids(int index, const char* value, size_t size); + std::string* add_sdpmids(); + void add_sdpmids(const std::string& value); + void add_sdpmids(std::string&& value); + void add_sdpmids(const char* value); + void add_sdpmids(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdpmids() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdpmids(); + private: + const std::string& _internal_sdpmids(int index) const; + std::string* _internal_add_sdpmids(); + public: + + // required string uuid = 5; + bool has_uuid() const; + private: + bool _internal_has_uuid() const; + public: + void clear_uuid(); + const std::string& uuid() const; template - void set_profilepicture(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilepicture(); - PROTOBUF_NODISCARD std::string* release_profilepicture(); - void set_allocated_profilepicture(std::string* profilepicture); + void set_uuid(ArgT0&& arg0, ArgT... args); + std::string* mutable_uuid(); + PROTOBUF_NODISCARD std::string* release_uuid(); + void set_allocated_uuid(std::string* uuid); private: - const std::string& _internal_profilepicture() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); - std::string* _internal_mutable_profilepicture(); + const std::string& _internal_uuid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_uuid(const std::string& value); + std::string* _internal_mutable_uuid(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.LokiProfile) + // required .SessionProtos.CallMessage.Type type = 1; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + ::SessionProtos::CallMessage_Type type() const; + void set_type(::SessionProtos::CallMessage_Type value); + private: + ::SessionProtos::CallMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::CallMessage_Type value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.CallMessage) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdps_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t > sdpmlineindexes_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdpmids_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr uuid_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Quote_QuotedAttachment final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote.QuotedAttachment) */ { +class KeyPair final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.KeyPair) */ { public: - inline DataMessage_Quote_QuotedAttachment() : DataMessage_Quote_QuotedAttachment(nullptr) {} - ~DataMessage_Quote_QuotedAttachment() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline KeyPair() : KeyPair(nullptr) {} + ~KeyPair() override; + explicit PROTOBUF_CONSTEXPR KeyPair(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from); - DataMessage_Quote_QuotedAttachment(DataMessage_Quote_QuotedAttachment&& from) noexcept - : DataMessage_Quote_QuotedAttachment() { + KeyPair(const KeyPair& from); + KeyPair(KeyPair&& from) noexcept + : KeyPair() { *this = ::std::move(from); } - inline DataMessage_Quote_QuotedAttachment& operator=(const DataMessage_Quote_QuotedAttachment& from) { + inline KeyPair& operator=(const KeyPair& from) { CopyFrom(from); return *this; } - inline DataMessage_Quote_QuotedAttachment& operator=(DataMessage_Quote_QuotedAttachment&& from) noexcept { + inline KeyPair& operator=(KeyPair&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2296,20 +2355,20 @@ class DataMessage_Quote_QuotedAttachment final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_Quote_QuotedAttachment& default_instance() { + static const KeyPair& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Quote_QuotedAttachment* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Quote_QuotedAttachment_default_instance_); + static inline const KeyPair* internal_default_instance() { + return reinterpret_cast( + &_KeyPair_default_instance_); } static constexpr int kIndexInFileMessages = 9; - friend void swap(DataMessage_Quote_QuotedAttachment& a, DataMessage_Quote_QuotedAttachment& b) { + friend void swap(KeyPair& a, KeyPair& b) { a.Swap(&b); } - inline void Swap(DataMessage_Quote_QuotedAttachment* other) { + inline void Swap(KeyPair* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2322,7 +2381,7 @@ class DataMessage_Quote_QuotedAttachment final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Quote_QuotedAttachment* other) { + void UnsafeArenaSwap(KeyPair* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2330,12 +2389,12 @@ class DataMessage_Quote_QuotedAttachment final : // implements Message ---------------------------------------------- - DataMessage_Quote_QuotedAttachment* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + KeyPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Quote_QuotedAttachment& from); - void MergeFrom(const DataMessage_Quote_QuotedAttachment& from); + void CopyFrom(const KeyPair& from); + void MergeFrom(const KeyPair& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2349,15 +2408,15 @@ class DataMessage_Quote_QuotedAttachment final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Quote_QuotedAttachment* other); + void InternalSwap(KeyPair* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Quote.QuotedAttachment"; + return "SessionProtos.KeyPair"; } protected: - explicit DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -2365,143 +2424,87 @@ class DataMessage_Quote_QuotedAttachment final : // nested types ---------------------------------------------------- - typedef DataMessage_Quote_QuotedAttachment_Flags Flags; - static constexpr Flags VOICE_MESSAGE = - DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE; - static inline bool Flags_IsValid(int value) { - return DataMessage_Quote_QuotedAttachment_Flags_IsValid(value); - } - static constexpr Flags Flags_MIN = - DataMessage_Quote_QuotedAttachment_Flags_Flags_MIN; - static constexpr Flags Flags_MAX = - DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX; - static constexpr int Flags_ARRAYSIZE = - DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE; - template - static inline const std::string& Flags_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Flags_Name."); - return DataMessage_Quote_QuotedAttachment_Flags_Name(enum_t_value); - } - static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Flags* value) { - return DataMessage_Quote_QuotedAttachment_Flags_Parse(name, value); - } - // accessors ------------------------------------------------------- enum : int { - kContentTypeFieldNumber = 1, - kFileNameFieldNumber = 2, - kThumbnailFieldNumber = 3, - kFlagsFieldNumber = 4, + kPublicKeyFieldNumber = 1, + kPrivateKeyFieldNumber = 2, }; - // optional string contentType = 1; - bool has_contenttype() const; + // required bytes publicKey = 1; + bool has_publickey() const; private: - bool _internal_has_contenttype() const; + bool _internal_has_publickey() const; public: - void clear_contenttype(); - const std::string& contenttype() const; + void clear_publickey(); + const std::string& publickey() const; template - void set_contenttype(ArgT0&& arg0, ArgT... args); - std::string* mutable_contenttype(); - PROTOBUF_NODISCARD std::string* release_contenttype(); - void set_allocated_contenttype(std::string* contenttype); + void set_publickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_publickey(); + PROTOBUF_NODISCARD std::string* release_publickey(); + void set_allocated_publickey(std::string* publickey); private: - const std::string& _internal_contenttype() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); - std::string* _internal_mutable_contenttype(); + const std::string& _internal_publickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); + std::string* _internal_mutable_publickey(); public: - // optional string fileName = 2; - bool has_filename() const; + // required bytes privateKey = 2; + bool has_privatekey() const; private: - bool _internal_has_filename() const; + bool _internal_has_privatekey() const; public: - void clear_filename(); - const std::string& filename() const; + void clear_privatekey(); + const std::string& privatekey() const; template - void set_filename(ArgT0&& arg0, ArgT... args); - std::string* mutable_filename(); - PROTOBUF_NODISCARD std::string* release_filename(); - void set_allocated_filename(std::string* filename); - private: - const std::string& _internal_filename() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); - std::string* _internal_mutable_filename(); - public: - - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - bool has_thumbnail() const; - private: - bool _internal_has_thumbnail() const; - public: - void clear_thumbnail(); - const ::SessionProtos::AttachmentPointer& thumbnail() const; - PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_thumbnail(); - ::SessionProtos::AttachmentPointer* mutable_thumbnail(); - void set_allocated_thumbnail(::SessionProtos::AttachmentPointer* thumbnail); - private: - const ::SessionProtos::AttachmentPointer& _internal_thumbnail() const; - ::SessionProtos::AttachmentPointer* _internal_mutable_thumbnail(); - public: - void unsafe_arena_set_allocated_thumbnail( - ::SessionProtos::AttachmentPointer* thumbnail); - ::SessionProtos::AttachmentPointer* unsafe_arena_release_thumbnail(); - - // optional uint32 flags = 4; - bool has_flags() const; - private: - bool _internal_has_flags() const; - public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); + void set_privatekey(ArgT0&& arg0, ArgT... args); + std::string* mutable_privatekey(); + PROTOBUF_NODISCARD std::string* release_privatekey(); + void set_allocated_privatekey(std::string* privatekey); private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); + const std::string& _internal_privatekey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_privatekey(const std::string& value); + std::string* _internal_mutable_privatekey(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(class_scope:SessionProtos.KeyPair) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; - ::SessionProtos::AttachmentPointer* thumbnail_; - uint32_t flags_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr privatekey_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Quote final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote) */ { +class DataExtractionNotification final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataExtractionNotification) */ { public: - inline DataMessage_Quote() : DataMessage_Quote(nullptr) {} - ~DataMessage_Quote() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataExtractionNotification() : DataExtractionNotification(nullptr) {} + ~DataExtractionNotification() override; + explicit PROTOBUF_CONSTEXPR DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Quote(const DataMessage_Quote& from); - DataMessage_Quote(DataMessage_Quote&& from) noexcept - : DataMessage_Quote() { + DataExtractionNotification(const DataExtractionNotification& from); + DataExtractionNotification(DataExtractionNotification&& from) noexcept + : DataExtractionNotification() { *this = ::std::move(from); } - inline DataMessage_Quote& operator=(const DataMessage_Quote& from) { + inline DataExtractionNotification& operator=(const DataExtractionNotification& from) { CopyFrom(from); return *this; } - inline DataMessage_Quote& operator=(DataMessage_Quote&& from) noexcept { + inline DataExtractionNotification& operator=(DataExtractionNotification&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2522,20 +2525,20 @@ class DataMessage_Quote final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_Quote& default_instance() { + static const DataExtractionNotification& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Quote* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Quote_default_instance_); + static inline const DataExtractionNotification* internal_default_instance() { + return reinterpret_cast( + &_DataExtractionNotification_default_instance_); } static constexpr int kIndexInFileMessages = 10; - friend void swap(DataMessage_Quote& a, DataMessage_Quote& b) { + friend void swap(DataExtractionNotification& a, DataExtractionNotification& b) { a.Swap(&b); } - inline void Swap(DataMessage_Quote* other) { + inline void Swap(DataExtractionNotification* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2548,7 +2551,7 @@ class DataMessage_Quote final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Quote* other) { + void UnsafeArenaSwap(DataExtractionNotification* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2556,12 +2559,12 @@ class DataMessage_Quote final : // implements Message ---------------------------------------------- - DataMessage_Quote* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataExtractionNotification* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Quote& from); - void MergeFrom(const DataMessage_Quote& from); + void CopyFrom(const DataExtractionNotification& from); + void MergeFrom(const DataExtractionNotification& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2575,15 +2578,15 @@ class DataMessage_Quote final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Quote* other); + void InternalSwap(DataExtractionNotification* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Quote"; + return "SessionProtos.DataExtractionNotification"; } protected: - explicit DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -2591,124 +2594,100 @@ class DataMessage_Quote final : // nested types ---------------------------------------------------- - typedef DataMessage_Quote_QuotedAttachment QuotedAttachment; + typedef DataExtractionNotification_Type Type; + static constexpr Type SCREENSHOT = + DataExtractionNotification_Type_SCREENSHOT; + static constexpr Type MEDIA_SAVED = + DataExtractionNotification_Type_MEDIA_SAVED; + static inline bool Type_IsValid(int value) { + return DataExtractionNotification_Type_IsValid(value); + } + static constexpr Type Type_MIN = + DataExtractionNotification_Type_Type_MIN; + static constexpr Type Type_MAX = + DataExtractionNotification_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + DataExtractionNotification_Type_Type_ARRAYSIZE; + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return DataExtractionNotification_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return DataExtractionNotification_Type_Parse(name, value); + } // accessors ------------------------------------------------------- enum : int { - kAttachmentsFieldNumber = 4, - kAuthorFieldNumber = 2, - kTextFieldNumber = 3, - kIdFieldNumber = 1, + kTimestampFieldNumber = 2, + kTypeFieldNumber = 1, }; - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - int attachments_size() const; + // optional uint64 timestamp = 2; + bool has_timestamp() const; private: - int _internal_attachments_size() const; + bool _internal_has_timestamp() const; public: - void clear_attachments(); - ::SessionProtos::DataMessage_Quote_QuotedAttachment* mutable_attachments(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >* - mutable_attachments(); + void clear_timestamp(); + uint64_t timestamp() const; + void set_timestamp(uint64_t value); private: - const ::SessionProtos::DataMessage_Quote_QuotedAttachment& _internal_attachments(int index) const; - ::SessionProtos::DataMessage_Quote_QuotedAttachment* _internal_add_attachments(); + uint64_t _internal_timestamp() const; + void _internal_set_timestamp(uint64_t value); public: - const ::SessionProtos::DataMessage_Quote_QuotedAttachment& attachments(int index) const; - ::SessionProtos::DataMessage_Quote_QuotedAttachment* add_attachments(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >& - attachments() const; - // required string author = 2; - bool has_author() const; + // required .SessionProtos.DataExtractionNotification.Type type = 1; + bool has_type() const; private: - bool _internal_has_author() const; + bool _internal_has_type() const; public: - void clear_author(); - const std::string& author() const; - template - void set_author(ArgT0&& arg0, ArgT... args); - std::string* mutable_author(); - PROTOBUF_NODISCARD std::string* release_author(); - void set_allocated_author(std::string* author); + void clear_type(); + ::SessionProtos::DataExtractionNotification_Type type() const; + void set_type(::SessionProtos::DataExtractionNotification_Type value); private: - const std::string& _internal_author() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); - std::string* _internal_mutable_author(); + ::SessionProtos::DataExtractionNotification_Type _internal_type() const; + void _internal_set_type(::SessionProtos::DataExtractionNotification_Type value); public: - // optional string text = 3; - bool has_text() const; - private: - bool _internal_has_text() const; - public: - void clear_text(); - const std::string& text() const; - template - void set_text(ArgT0&& arg0, ArgT... args); - std::string* mutable_text(); - PROTOBUF_NODISCARD std::string* release_text(); - void set_allocated_text(std::string* text); - private: - const std::string& _internal_text() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_text(const std::string& value); - std::string* _internal_mutable_text(); - public: - - // required uint64 id = 1; - bool has_id() const; - private: - bool _internal_has_id() const; - public: - void clear_id(); - uint64_t id() const; - void set_id(uint64_t value); - private: - uint64_t _internal_id() const; - void _internal_set_id(uint64_t value); - public: - - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(class_scope:SessionProtos.DataExtractionNotification) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment > attachments_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_; - uint64_t id_; + uint64_t timestamp_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Preview final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Preview) */ { +class LokiProfile final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.LokiProfile) */ { public: - inline DataMessage_Preview() : DataMessage_Preview(nullptr) {} - ~DataMessage_Preview() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline LokiProfile() : LokiProfile(nullptr) {} + ~LokiProfile() override; + explicit PROTOBUF_CONSTEXPR LokiProfile(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Preview(const DataMessage_Preview& from); - DataMessage_Preview(DataMessage_Preview&& from) noexcept - : DataMessage_Preview() { + LokiProfile(const LokiProfile& from); + LokiProfile(LokiProfile&& from) noexcept + : LokiProfile() { *this = ::std::move(from); } - inline DataMessage_Preview& operator=(const DataMessage_Preview& from) { + inline LokiProfile& operator=(const LokiProfile& from) { CopyFrom(from); return *this; } - inline DataMessage_Preview& operator=(DataMessage_Preview&& from) noexcept { + inline LokiProfile& operator=(LokiProfile&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2729,20 +2708,20 @@ class DataMessage_Preview final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_Preview& default_instance() { + static const LokiProfile& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Preview* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Preview_default_instance_); + static inline const LokiProfile* internal_default_instance() { + return reinterpret_cast( + &_LokiProfile_default_instance_); } static constexpr int kIndexInFileMessages = 11; - friend void swap(DataMessage_Preview& a, DataMessage_Preview& b) { + friend void swap(LokiProfile& a, LokiProfile& b) { a.Swap(&b); } - inline void Swap(DataMessage_Preview* other) { + inline void Swap(LokiProfile* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2755,7 +2734,7 @@ class DataMessage_Preview final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Preview* other) { + void UnsafeArenaSwap(LokiProfile* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2763,12 +2742,12 @@ class DataMessage_Preview final : // implements Message ---------------------------------------------- - DataMessage_Preview* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + LokiProfile* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Preview& from); - void MergeFrom(const DataMessage_Preview& from); + void CopyFrom(const LokiProfile& from); + void MergeFrom(const LokiProfile& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2782,15 +2761,15 @@ class DataMessage_Preview final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Preview* other); + void InternalSwap(LokiProfile* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Preview"; + return "SessionProtos.LokiProfile"; } protected: - explicit DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -2801,65 +2780,46 @@ class DataMessage_Preview final : // accessors ------------------------------------------------------- enum : int { - kUrlFieldNumber = 1, - kTitleFieldNumber = 2, - kImageFieldNumber = 3, + kDisplayNameFieldNumber = 1, + kProfilePictureFieldNumber = 2, }; - // required string url = 1; - bool has_url() const; + // optional string displayName = 1; + bool has_displayname() const; private: - bool _internal_has_url() const; + bool _internal_has_displayname() const; public: - void clear_url(); - const std::string& url() const; + void clear_displayname(); + const std::string& displayname() const; template - void set_url(ArgT0&& arg0, ArgT... args); - std::string* mutable_url(); - PROTOBUF_NODISCARD std::string* release_url(); - void set_allocated_url(std::string* url); + void set_displayname(ArgT0&& arg0, ArgT... args); + std::string* mutable_displayname(); + PROTOBUF_NODISCARD std::string* release_displayname(); + void set_allocated_displayname(std::string* displayname); private: - const std::string& _internal_url() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); - std::string* _internal_mutable_url(); + const std::string& _internal_displayname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); + std::string* _internal_mutable_displayname(); public: - // optional string title = 2; - bool has_title() const; + // optional string profilePicture = 2; + bool has_profilepicture() const; private: - bool _internal_has_title() const; + bool _internal_has_profilepicture() const; public: - void clear_title(); - const std::string& title() const; + void clear_profilepicture(); + const std::string& profilepicture() const; template - void set_title(ArgT0&& arg0, ArgT... args); - std::string* mutable_title(); - PROTOBUF_NODISCARD std::string* release_title(); - void set_allocated_title(std::string* title); - private: - const std::string& _internal_title() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_title(const std::string& value); - std::string* _internal_mutable_title(); - public: - - // optional .SessionProtos.AttachmentPointer image = 3; - bool has_image() const; - private: - bool _internal_has_image() const; - public: - void clear_image(); - const ::SessionProtos::AttachmentPointer& image() const; - PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_image(); - ::SessionProtos::AttachmentPointer* mutable_image(); - void set_allocated_image(::SessionProtos::AttachmentPointer* image); + void set_profilepicture(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilepicture(); + PROTOBUF_NODISCARD std::string* release_profilepicture(); + void set_allocated_profilepicture(std::string* profilepicture); private: - const ::SessionProtos::AttachmentPointer& _internal_image() const; - ::SessionProtos::AttachmentPointer* _internal_mutable_image(); + const std::string& _internal_profilepicture() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); + std::string* _internal_mutable_profilepicture(); public: - void unsafe_arena_set_allocated_image( - ::SessionProtos::AttachmentPointer* image); - ::SessionProtos::AttachmentPointer* unsafe_arena_release_image(); - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Preview) + // @@protoc_insertion_point(class_scope:SessionProtos.LokiProfile) private: class _Internal; @@ -2869,33 +2829,32 @@ class DataMessage_Preview final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr title_; - ::SessionProtos::AttachmentPointer* image_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Reaction final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Reaction) */ { +class DataMessage_Quote_QuotedAttachment final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote.QuotedAttachment) */ { public: - inline DataMessage_Reaction() : DataMessage_Reaction(nullptr) {} - ~DataMessage_Reaction() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Quote_QuotedAttachment() : DataMessage_Quote_QuotedAttachment(nullptr) {} + ~DataMessage_Quote_QuotedAttachment() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Reaction(const DataMessage_Reaction& from); - DataMessage_Reaction(DataMessage_Reaction&& from) noexcept - : DataMessage_Reaction() { + DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from); + DataMessage_Quote_QuotedAttachment(DataMessage_Quote_QuotedAttachment&& from) noexcept + : DataMessage_Quote_QuotedAttachment() { *this = ::std::move(from); } - inline DataMessage_Reaction& operator=(const DataMessage_Reaction& from) { + inline DataMessage_Quote_QuotedAttachment& operator=(const DataMessage_Quote_QuotedAttachment& from) { CopyFrom(from); return *this; } - inline DataMessage_Reaction& operator=(DataMessage_Reaction&& from) noexcept { + inline DataMessage_Quote_QuotedAttachment& operator=(DataMessage_Quote_QuotedAttachment&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2916,20 +2875,20 @@ class DataMessage_Reaction final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_Reaction& default_instance() { + static const DataMessage_Quote_QuotedAttachment& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Reaction* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Reaction_default_instance_); + static inline const DataMessage_Quote_QuotedAttachment* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Quote_QuotedAttachment_default_instance_); } static constexpr int kIndexInFileMessages = 12; - friend void swap(DataMessage_Reaction& a, DataMessage_Reaction& b) { + friend void swap(DataMessage_Quote_QuotedAttachment& a, DataMessage_Quote_QuotedAttachment& b) { a.Swap(&b); } - inline void Swap(DataMessage_Reaction* other) { + inline void Swap(DataMessage_Quote_QuotedAttachment* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2942,7 +2901,7 @@ class DataMessage_Reaction final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Reaction* other) { + void UnsafeArenaSwap(DataMessage_Quote_QuotedAttachment* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2950,12 +2909,12 @@ class DataMessage_Reaction final : // implements Message ---------------------------------------------- - DataMessage_Reaction* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Quote_QuotedAttachment* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Reaction& from); - void MergeFrom(const DataMessage_Reaction& from); + void CopyFrom(const DataMessage_Quote_QuotedAttachment& from); + void MergeFrom(const DataMessage_Quote_QuotedAttachment& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2969,15 +2928,15 @@ class DataMessage_Reaction final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Reaction* other); + void InternalSwap(DataMessage_Quote_QuotedAttachment* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Reaction"; + return "SessionProtos.DataMessage.Quote.QuotedAttachment"; } protected: - explicit DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -2985,143 +2944,143 @@ class DataMessage_Reaction final : // nested types ---------------------------------------------------- - typedef DataMessage_Reaction_Action Action; - static constexpr Action REACT = - DataMessage_Reaction_Action_REACT; - static constexpr Action REMOVE = - DataMessage_Reaction_Action_REMOVE; - static inline bool Action_IsValid(int value) { - return DataMessage_Reaction_Action_IsValid(value); + typedef DataMessage_Quote_QuotedAttachment_Flags Flags; + static constexpr Flags VOICE_MESSAGE = + DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE; + static inline bool Flags_IsValid(int value) { + return DataMessage_Quote_QuotedAttachment_Flags_IsValid(value); } - static constexpr Action Action_MIN = - DataMessage_Reaction_Action_Action_MIN; - static constexpr Action Action_MAX = - DataMessage_Reaction_Action_Action_MAX; - static constexpr int Action_ARRAYSIZE = - DataMessage_Reaction_Action_Action_ARRAYSIZE; + static constexpr Flags Flags_MIN = + DataMessage_Quote_QuotedAttachment_Flags_Flags_MIN; + static constexpr Flags Flags_MAX = + DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX; + static constexpr int Flags_ARRAYSIZE = + DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE; template - static inline const std::string& Action_Name(T enum_t_value) { - static_assert(::std::is_same::value || + static inline const std::string& Flags_Name(T enum_t_value) { + static_assert(::std::is_same::value || ::std::is_integral::value, - "Incorrect type passed to function Action_Name."); - return DataMessage_Reaction_Action_Name(enum_t_value); + "Incorrect type passed to function Flags_Name."); + return DataMessage_Quote_QuotedAttachment_Flags_Name(enum_t_value); } - static inline bool Action_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Action* value) { - return DataMessage_Reaction_Action_Parse(name, value); + static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Flags* value) { + return DataMessage_Quote_QuotedAttachment_Flags_Parse(name, value); } // accessors ------------------------------------------------------- enum : int { - kAuthorFieldNumber = 2, - kEmojiFieldNumber = 3, - kIdFieldNumber = 1, - kActionFieldNumber = 4, + kContentTypeFieldNumber = 1, + kFileNameFieldNumber = 2, + kThumbnailFieldNumber = 3, + kFlagsFieldNumber = 4, }; - // required string author = 2; - bool has_author() const; + // optional string contentType = 1; + bool has_contenttype() const; private: - bool _internal_has_author() const; + bool _internal_has_contenttype() const; public: - void clear_author(); - const std::string& author() const; + void clear_contenttype(); + const std::string& contenttype() const; template - void set_author(ArgT0&& arg0, ArgT... args); - std::string* mutable_author(); - PROTOBUF_NODISCARD std::string* release_author(); - void set_allocated_author(std::string* author); + void set_contenttype(ArgT0&& arg0, ArgT... args); + std::string* mutable_contenttype(); + PROTOBUF_NODISCARD std::string* release_contenttype(); + void set_allocated_contenttype(std::string* contenttype); private: - const std::string& _internal_author() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); - std::string* _internal_mutable_author(); + const std::string& _internal_contenttype() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); + std::string* _internal_mutable_contenttype(); public: - // optional string emoji = 3; - bool has_emoji() const; + // optional string fileName = 2; + bool has_filename() const; private: - bool _internal_has_emoji() const; + bool _internal_has_filename() const; public: - void clear_emoji(); - const std::string& emoji() const; + void clear_filename(); + const std::string& filename() const; template - void set_emoji(ArgT0&& arg0, ArgT... args); - std::string* mutable_emoji(); - PROTOBUF_NODISCARD std::string* release_emoji(); - void set_allocated_emoji(std::string* emoji); + void set_filename(ArgT0&& arg0, ArgT... args); + std::string* mutable_filename(); + PROTOBUF_NODISCARD std::string* release_filename(); + void set_allocated_filename(std::string* filename); private: - const std::string& _internal_emoji() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_emoji(const std::string& value); - std::string* _internal_mutable_emoji(); + const std::string& _internal_filename() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); + std::string* _internal_mutable_filename(); public: - // required uint64 id = 1; - bool has_id() const; + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + bool has_thumbnail() const; private: - bool _internal_has_id() const; + bool _internal_has_thumbnail() const; public: - void clear_id(); - uint64_t id() const; - void set_id(uint64_t value); + void clear_thumbnail(); + const ::SessionProtos::AttachmentPointer& thumbnail() const; + PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_thumbnail(); + ::SessionProtos::AttachmentPointer* mutable_thumbnail(); + void set_allocated_thumbnail(::SessionProtos::AttachmentPointer* thumbnail); private: - uint64_t _internal_id() const; - void _internal_set_id(uint64_t value); + const ::SessionProtos::AttachmentPointer& _internal_thumbnail() const; + ::SessionProtos::AttachmentPointer* _internal_mutable_thumbnail(); public: + void unsafe_arena_set_allocated_thumbnail( + ::SessionProtos::AttachmentPointer* thumbnail); + ::SessionProtos::AttachmentPointer* unsafe_arena_release_thumbnail(); - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - bool has_action() const; + // optional uint32 flags = 4; + bool has_flags() const; private: - bool _internal_has_action() const; + bool _internal_has_flags() const; public: - void clear_action(); - ::SessionProtos::DataMessage_Reaction_Action action() const; - void set_action(::SessionProtos::DataMessage_Reaction_Action value); + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); private: - ::SessionProtos::DataMessage_Reaction_Action _internal_action() const; - void _internal_set_action(::SessionProtos::DataMessage_Reaction_Action value); + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote.QuotedAttachment) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr emoji_; - uint64_t id_; - int action_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; + ::SessionProtos::AttachmentPointer* thumbnail_; + uint32_t flags_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_OpenGroupInvitation final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.OpenGroupInvitation) */ { +class DataMessage_Quote final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote) */ { public: - inline DataMessage_OpenGroupInvitation() : DataMessage_OpenGroupInvitation(nullptr) {} - ~DataMessage_OpenGroupInvitation() override; - explicit PROTOBUF_CONSTEXPR DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Quote() : DataMessage_Quote(nullptr) {} + ~DataMessage_Quote() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from); - DataMessage_OpenGroupInvitation(DataMessage_OpenGroupInvitation&& from) noexcept - : DataMessage_OpenGroupInvitation() { + DataMessage_Quote(const DataMessage_Quote& from); + DataMessage_Quote(DataMessage_Quote&& from) noexcept + : DataMessage_Quote() { *this = ::std::move(from); } - inline DataMessage_OpenGroupInvitation& operator=(const DataMessage_OpenGroupInvitation& from) { + inline DataMessage_Quote& operator=(const DataMessage_Quote& from) { CopyFrom(from); return *this; } - inline DataMessage_OpenGroupInvitation& operator=(DataMessage_OpenGroupInvitation&& from) noexcept { + inline DataMessage_Quote& operator=(DataMessage_Quote&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3142,20 +3101,20 @@ class DataMessage_OpenGroupInvitation final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_OpenGroupInvitation& default_instance() { + static const DataMessage_Quote& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_OpenGroupInvitation* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_OpenGroupInvitation_default_instance_); + static inline const DataMessage_Quote* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Quote_default_instance_); } static constexpr int kIndexInFileMessages = 13; - friend void swap(DataMessage_OpenGroupInvitation& a, DataMessage_OpenGroupInvitation& b) { + friend void swap(DataMessage_Quote& a, DataMessage_Quote& b) { a.Swap(&b); } - inline void Swap(DataMessage_OpenGroupInvitation* other) { + inline void Swap(DataMessage_Quote* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3168,7 +3127,7 @@ class DataMessage_OpenGroupInvitation final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_OpenGroupInvitation* other) { + void UnsafeArenaSwap(DataMessage_Quote* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3176,12 +3135,12 @@ class DataMessage_OpenGroupInvitation final : // implements Message ---------------------------------------------- - DataMessage_OpenGroupInvitation* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Quote* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_OpenGroupInvitation& from); - void MergeFrom(const DataMessage_OpenGroupInvitation& from); + void CopyFrom(const DataMessage_Quote& from); + void MergeFrom(const DataMessage_Quote& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3195,15 +3154,15 @@ class DataMessage_OpenGroupInvitation final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_OpenGroupInvitation* other); + void InternalSwap(DataMessage_Quote* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.OpenGroupInvitation"; + return "SessionProtos.DataMessage.Quote"; } protected: - explicit DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -3211,49 +3170,84 @@ class DataMessage_OpenGroupInvitation final : // nested types ---------------------------------------------------- + typedef DataMessage_Quote_QuotedAttachment QuotedAttachment; + // accessors ------------------------------------------------------- enum : int { - kUrlFieldNumber = 1, - kNameFieldNumber = 3, + kAttachmentsFieldNumber = 4, + kAuthorFieldNumber = 2, + kTextFieldNumber = 3, + kIdFieldNumber = 1, }; - // required string url = 1; - bool has_url() const; + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + int attachments_size() const; private: - bool _internal_has_url() const; + int _internal_attachments_size() const; public: - void clear_url(); - const std::string& url() const; + void clear_attachments(); + ::SessionProtos::DataMessage_Quote_QuotedAttachment* mutable_attachments(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >* + mutable_attachments(); + private: + const ::SessionProtos::DataMessage_Quote_QuotedAttachment& _internal_attachments(int index) const; + ::SessionProtos::DataMessage_Quote_QuotedAttachment* _internal_add_attachments(); + public: + const ::SessionProtos::DataMessage_Quote_QuotedAttachment& attachments(int index) const; + ::SessionProtos::DataMessage_Quote_QuotedAttachment* add_attachments(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >& + attachments() const; + + // required string author = 2; + bool has_author() const; + private: + bool _internal_has_author() const; + public: + void clear_author(); + const std::string& author() const; template - void set_url(ArgT0&& arg0, ArgT... args); - std::string* mutable_url(); - PROTOBUF_NODISCARD std::string* release_url(); - void set_allocated_url(std::string* url); + void set_author(ArgT0&& arg0, ArgT... args); + std::string* mutable_author(); + PROTOBUF_NODISCARD std::string* release_author(); + void set_allocated_author(std::string* author); private: - const std::string& _internal_url() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); - std::string* _internal_mutable_url(); + const std::string& _internal_author() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); + std::string* _internal_mutable_author(); public: - // required string name = 3; - bool has_name() const; + // optional string text = 3; + bool has_text() const; private: - bool _internal_has_name() const; + bool _internal_has_text() const; public: - void clear_name(); - const std::string& name() const; + void clear_text(); + const std::string& text() const; template - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); + void set_text(ArgT0&& arg0, ArgT... args); + std::string* mutable_text(); + PROTOBUF_NODISCARD std::string* release_text(); + void set_allocated_text(std::string* text); private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); + const std::string& _internal_text() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_text(const std::string& value); + std::string* _internal_mutable_text(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.OpenGroupInvitation) + // required uint64 id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + uint64_t id() const; + void set_id(uint64_t value); + private: + uint64_t _internal_id() const; + void _internal_set_id(uint64_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote) private: class _Internal; @@ -3266,32 +3260,34 @@ class DataMessage_OpenGroupInvitation final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment > attachments_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_; + uint64_t id_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) */ { +class DataMessage_Preview final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Preview) */ { public: - inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper() : DataMessage_ClosedGroupControlMessage_KeyPairWrapper(nullptr) {} - ~DataMessage_ClosedGroupControlMessage_KeyPairWrapper() override; - explicit PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Preview() : DataMessage_Preview(nullptr) {} + ~DataMessage_Preview() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_ClosedGroupControlMessage_KeyPairWrapper(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); - DataMessage_ClosedGroupControlMessage_KeyPairWrapper(DataMessage_ClosedGroupControlMessage_KeyPairWrapper&& from) noexcept - : DataMessage_ClosedGroupControlMessage_KeyPairWrapper() { + DataMessage_Preview(const DataMessage_Preview& from); + DataMessage_Preview(DataMessage_Preview&& from) noexcept + : DataMessage_Preview() { *this = ::std::move(from); } - inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper& operator=(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { + inline DataMessage_Preview& operator=(const DataMessage_Preview& from) { CopyFrom(from); return *this; } - inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper& operator=(DataMessage_ClosedGroupControlMessage_KeyPairWrapper&& from) noexcept { + inline DataMessage_Preview& operator=(DataMessage_Preview&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3312,20 +3308,20 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& default_instance() { + static const DataMessage_Preview& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_ClosedGroupControlMessage_KeyPairWrapper* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_ClosedGroupControlMessage_KeyPairWrapper_default_instance_); + static inline const DataMessage_Preview* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Preview_default_instance_); } static constexpr int kIndexInFileMessages = 14; - friend void swap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper& a, DataMessage_ClosedGroupControlMessage_KeyPairWrapper& b) { + friend void swap(DataMessage_Preview& a, DataMessage_Preview& b) { a.Swap(&b); } - inline void Swap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { + inline void Swap(DataMessage_Preview* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3338,7 +3334,7 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { + void UnsafeArenaSwap(DataMessage_Preview* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3346,12 +3342,12 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : // implements Message ---------------------------------------------- - DataMessage_ClosedGroupControlMessage_KeyPairWrapper* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Preview* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); - void MergeFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); + void CopyFrom(const DataMessage_Preview& from); + void MergeFrom(const DataMessage_Preview& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3365,15 +3361,15 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other); + void InternalSwap(DataMessage_Preview* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper"; + return "SessionProtos.DataMessage.Preview"; } protected: - explicit DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -3384,84 +3380,101 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : // accessors ------------------------------------------------------- enum : int { - kPublicKeyFieldNumber = 1, - kEncryptedKeyPairFieldNumber = 2, + kUrlFieldNumber = 1, + kTitleFieldNumber = 2, + kImageFieldNumber = 3, }; - // required bytes publicKey = 1; - bool has_publickey() const; + // required string url = 1; + bool has_url() const; private: - bool _internal_has_publickey() const; + bool _internal_has_url() const; public: - void clear_publickey(); - const std::string& publickey() const; + void clear_url(); + const std::string& url() const; template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); public: - // required bytes encryptedKeyPair = 2; - bool has_encryptedkeypair() const; + // optional string title = 2; + bool has_title() const; private: - bool _internal_has_encryptedkeypair() const; + bool _internal_has_title() const; public: - void clear_encryptedkeypair(); - const std::string& encryptedkeypair() const; + void clear_title(); + const std::string& title() const; template - void set_encryptedkeypair(ArgT0&& arg0, ArgT... args); - std::string* mutable_encryptedkeypair(); - PROTOBUF_NODISCARD std::string* release_encryptedkeypair(); - void set_allocated_encryptedkeypair(std::string* encryptedkeypair); + void set_title(ArgT0&& arg0, ArgT... args); + std::string* mutable_title(); + PROTOBUF_NODISCARD std::string* release_title(); + void set_allocated_title(std::string* title); private: - const std::string& _internal_encryptedkeypair() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_encryptedkeypair(const std::string& value); - std::string* _internal_mutable_encryptedkeypair(); + const std::string& _internal_title() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_title(const std::string& value); + std::string* _internal_mutable_title(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // optional .SessionProtos.AttachmentPointer image = 3; + bool has_image() const; + private: + bool _internal_has_image() const; + public: + void clear_image(); + const ::SessionProtos::AttachmentPointer& image() const; + PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_image(); + ::SessionProtos::AttachmentPointer* mutable_image(); + void set_allocated_image(::SessionProtos::AttachmentPointer* image); + private: + const ::SessionProtos::AttachmentPointer& _internal_image() const; + ::SessionProtos::AttachmentPointer* _internal_mutable_image(); + public: + void unsafe_arena_set_allocated_image( + ::SessionProtos::AttachmentPointer* image); + ::SessionProtos::AttachmentPointer* unsafe_arena_release_image(); + + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Preview) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr encryptedkeypair_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr title_; + ::SessionProtos::AttachmentPointer* image_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_ClosedGroupControlMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.ClosedGroupControlMessage) */ { +class DataMessage_Reaction final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Reaction) */ { public: - inline DataMessage_ClosedGroupControlMessage() : DataMessage_ClosedGroupControlMessage(nullptr) {} - ~DataMessage_ClosedGroupControlMessage() override; - explicit PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Reaction() : DataMessage_Reaction(nullptr) {} + ~DataMessage_Reaction() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_ClosedGroupControlMessage(const DataMessage_ClosedGroupControlMessage& from); - DataMessage_ClosedGroupControlMessage(DataMessage_ClosedGroupControlMessage&& from) noexcept - : DataMessage_ClosedGroupControlMessage() { + DataMessage_Reaction(const DataMessage_Reaction& from); + DataMessage_Reaction(DataMessage_Reaction&& from) noexcept + : DataMessage_Reaction() { *this = ::std::move(from); } - inline DataMessage_ClosedGroupControlMessage& operator=(const DataMessage_ClosedGroupControlMessage& from) { + inline DataMessage_Reaction& operator=(const DataMessage_Reaction& from) { CopyFrom(from); return *this; } - inline DataMessage_ClosedGroupControlMessage& operator=(DataMessage_ClosedGroupControlMessage&& from) noexcept { + inline DataMessage_Reaction& operator=(DataMessage_Reaction&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3482,20 +3495,20 @@ class DataMessage_ClosedGroupControlMessage final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage_ClosedGroupControlMessage& default_instance() { + static const DataMessage_Reaction& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_ClosedGroupControlMessage* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_ClosedGroupControlMessage_default_instance_); + static inline const DataMessage_Reaction* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Reaction_default_instance_); } static constexpr int kIndexInFileMessages = 15; - friend void swap(DataMessage_ClosedGroupControlMessage& a, DataMessage_ClosedGroupControlMessage& b) { + friend void swap(DataMessage_Reaction& a, DataMessage_Reaction& b) { a.Swap(&b); } - inline void Swap(DataMessage_ClosedGroupControlMessage* other) { + inline void Swap(DataMessage_Reaction* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3508,7 +3521,7 @@ class DataMessage_ClosedGroupControlMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_ClosedGroupControlMessage* other) { + void UnsafeArenaSwap(DataMessage_Reaction* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3516,12 +3529,12 @@ class DataMessage_ClosedGroupControlMessage final : // implements Message ---------------------------------------------- - DataMessage_ClosedGroupControlMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Reaction* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_ClosedGroupControlMessage& from); - void MergeFrom(const DataMessage_ClosedGroupControlMessage& from); + void CopyFrom(const DataMessage_Reaction& from); + void MergeFrom(const DataMessage_Reaction& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3535,15 +3548,15 @@ class DataMessage_ClosedGroupControlMessage final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage_ClosedGroupControlMessage* other); + void InternalSwap(DataMessage_Reaction* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.ClosedGroupControlMessage"; + return "SessionProtos.DataMessage.Reaction"; } protected: - explicit DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -3551,244 +3564,143 @@ class DataMessage_ClosedGroupControlMessage final : // nested types ---------------------------------------------------- - typedef DataMessage_ClosedGroupControlMessage_KeyPairWrapper KeyPairWrapper; - - typedef DataMessage_ClosedGroupControlMessage_Type Type; - static constexpr Type NEW = - DataMessage_ClosedGroupControlMessage_Type_NEW; - static constexpr Type ENCRYPTION_KEY_PAIR = - DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR; - static constexpr Type NAME_CHANGE = - DataMessage_ClosedGroupControlMessage_Type_NAME_CHANGE; - static constexpr Type MEMBERS_ADDED = - DataMessage_ClosedGroupControlMessage_Type_MEMBERS_ADDED; - static constexpr Type MEMBERS_REMOVED = - DataMessage_ClosedGroupControlMessage_Type_MEMBERS_REMOVED; - static constexpr Type MEMBER_LEFT = - DataMessage_ClosedGroupControlMessage_Type_MEMBER_LEFT; - static constexpr Type ENCRYPTION_KEY_PAIR_REQUEST = - DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR_REQUEST; - static inline bool Type_IsValid(int value) { - return DataMessage_ClosedGroupControlMessage_Type_IsValid(value); + typedef DataMessage_Reaction_Action Action; + static constexpr Action REACT = + DataMessage_Reaction_Action_REACT; + static constexpr Action REMOVE = + DataMessage_Reaction_Action_REMOVE; + static inline bool Action_IsValid(int value) { + return DataMessage_Reaction_Action_IsValid(value); } - static constexpr Type Type_MIN = - DataMessage_ClosedGroupControlMessage_Type_Type_MIN; - static constexpr Type Type_MAX = - DataMessage_ClosedGroupControlMessage_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - DataMessage_ClosedGroupControlMessage_Type_Type_ARRAYSIZE; + static constexpr Action Action_MIN = + DataMessage_Reaction_Action_Action_MIN; + static constexpr Action Action_MAX = + DataMessage_Reaction_Action_Action_MAX; + static constexpr int Action_ARRAYSIZE = + DataMessage_Reaction_Action_Action_ARRAYSIZE; template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || + static inline const std::string& Action_Name(T enum_t_value) { + static_assert(::std::is_same::value || ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return DataMessage_ClosedGroupControlMessage_Type_Name(enum_t_value); + "Incorrect type passed to function Action_Name."); + return DataMessage_Reaction_Action_Name(enum_t_value); } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return DataMessage_ClosedGroupControlMessage_Type_Parse(name, value); + static inline bool Action_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Action* value) { + return DataMessage_Reaction_Action_Parse(name, value); } // accessors ------------------------------------------------------- enum : int { - kMembersFieldNumber = 5, - kAdminsFieldNumber = 6, - kWrappersFieldNumber = 7, - kPublicKeyFieldNumber = 2, - kNameFieldNumber = 3, - kEncryptionKeyPairFieldNumber = 4, - kExpirationTimerFieldNumber = 8, - kTypeFieldNumber = 1, + kAuthorFieldNumber = 2, + kEmojiFieldNumber = 3, + kIdFieldNumber = 1, + kActionFieldNumber = 4, }; - // repeated bytes members = 5; - int members_size() const; + // required string author = 2; + bool has_author() const; private: - int _internal_members_size() const; + bool _internal_has_author() const; public: - void clear_members(); - const std::string& members(int index) const; - std::string* mutable_members(int index); - void set_members(int index, const std::string& value); - void set_members(int index, std::string&& value); - void set_members(int index, const char* value); - void set_members(int index, const void* value, size_t size); - std::string* add_members(); - void add_members(const std::string& value); - void add_members(std::string&& value); - void add_members(const char* value); - void add_members(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& members() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_members(); + void clear_author(); + const std::string& author() const; + template + void set_author(ArgT0&& arg0, ArgT... args); + std::string* mutable_author(); + PROTOBUF_NODISCARD std::string* release_author(); + void set_allocated_author(std::string* author); private: - const std::string& _internal_members(int index) const; - std::string* _internal_add_members(); + const std::string& _internal_author() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); + std::string* _internal_mutable_author(); public: - // repeated bytes admins = 6; - int admins_size() const; + // optional string emoji = 3; + bool has_emoji() const; private: - int _internal_admins_size() const; - public: - void clear_admins(); - const std::string& admins(int index) const; - std::string* mutable_admins(int index); - void set_admins(int index, const std::string& value); - void set_admins(int index, std::string&& value); - void set_admins(int index, const char* value); - void set_admins(int index, const void* value, size_t size); - std::string* add_admins(); - void add_admins(const std::string& value); - void add_admins(std::string&& value); - void add_admins(const char* value); - void add_admins(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& admins() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_admins(); - private: - const std::string& _internal_admins(int index) const; - std::string* _internal_add_admins(); - public: - - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - int wrappers_size() const; - private: - int _internal_wrappers_size() const; - public: - void clear_wrappers(); - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* mutable_wrappers(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >* - mutable_wrappers(); - private: - const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& _internal_wrappers(int index) const; - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* _internal_add_wrappers(); - public: - const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& wrappers(int index) const; - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* add_wrappers(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >& - wrappers() const; - - // optional bytes publicKey = 2; - bool has_publickey() const; - private: - bool _internal_has_publickey() const; - public: - void clear_publickey(); - const std::string& publickey() const; - template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); - private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); - public: - - // optional string name = 3; - bool has_name() const; - private: - bool _internal_has_name() const; + bool _internal_has_emoji() const; public: - void clear_name(); - const std::string& name() const; + void clear_emoji(); + const std::string& emoji() const; template - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; - bool has_encryptionkeypair() const; - private: - bool _internal_has_encryptionkeypair() const; - public: - void clear_encryptionkeypair(); - const ::SessionProtos::KeyPair& encryptionkeypair() const; - PROTOBUF_NODISCARD ::SessionProtos::KeyPair* release_encryptionkeypair(); - ::SessionProtos::KeyPair* mutable_encryptionkeypair(); - void set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair); + void set_emoji(ArgT0&& arg0, ArgT... args); + std::string* mutable_emoji(); + PROTOBUF_NODISCARD std::string* release_emoji(); + void set_allocated_emoji(std::string* emoji); private: - const ::SessionProtos::KeyPair& _internal_encryptionkeypair() const; - ::SessionProtos::KeyPair* _internal_mutable_encryptionkeypair(); + const std::string& _internal_emoji() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_emoji(const std::string& value); + std::string* _internal_mutable_emoji(); public: - void unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair); - ::SessionProtos::KeyPair* unsafe_arena_release_encryptionkeypair(); - // optional uint32 expirationTimer = 8; - bool has_expirationtimer() const; + // required uint64 id = 1; + bool has_id() const; private: - bool _internal_has_expirationtimer() const; + bool _internal_has_id() const; public: - void clear_expirationtimer(); - uint32_t expirationtimer() const; - void set_expirationtimer(uint32_t value); + void clear_id(); + uint64_t id() const; + void set_id(uint64_t value); private: - uint32_t _internal_expirationtimer() const; - void _internal_set_expirationtimer(uint32_t value); + uint64_t _internal_id() const; + void _internal_set_id(uint64_t value); public: - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; - bool has_type() const; + // required .SessionProtos.DataMessage.Reaction.Action action = 4; + bool has_action() const; private: - bool _internal_has_type() const; + bool _internal_has_action() const; public: - void clear_type(); - ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type type() const; - void set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value); + void clear_action(); + ::SessionProtos::DataMessage_Reaction_Action action() const; + void set_action(::SessionProtos::DataMessage_Reaction_Action value); private: - ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type _internal_type() const; - void _internal_set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value); + ::SessionProtos::DataMessage_Reaction_Action _internal_action() const; + void _internal_set_action(::SessionProtos::DataMessage_Reaction_Action value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Reaction) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField members_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField admins_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper > wrappers_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::SessionProtos::KeyPair* encryptionkeypair_; - uint32_t expirationtimer_; - int type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr emoji_; + uint64_t id_; + int action_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage) */ { +class DataMessage_OpenGroupInvitation final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.OpenGroupInvitation) */ { public: - inline DataMessage() : DataMessage(nullptr) {} - ~DataMessage() override; - explicit PROTOBUF_CONSTEXPR DataMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_OpenGroupInvitation() : DataMessage_OpenGroupInvitation(nullptr) {} + ~DataMessage_OpenGroupInvitation() override; + explicit PROTOBUF_CONSTEXPR DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage(const DataMessage& from); - DataMessage(DataMessage&& from) noexcept - : DataMessage() { + DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from); + DataMessage_OpenGroupInvitation(DataMessage_OpenGroupInvitation&& from) noexcept + : DataMessage_OpenGroupInvitation() { *this = ::std::move(from); } - inline DataMessage& operator=(const DataMessage& from) { + inline DataMessage_OpenGroupInvitation& operator=(const DataMessage_OpenGroupInvitation& from) { CopyFrom(from); return *this; } - inline DataMessage& operator=(DataMessage&& from) noexcept { + inline DataMessage_OpenGroupInvitation& operator=(DataMessage_OpenGroupInvitation&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3809,20 +3721,20 @@ class DataMessage final : return _internal_metadata_.mutable_unknown_fields(); } - static const DataMessage& default_instance() { + static const DataMessage_OpenGroupInvitation& default_instance() { return *internal_default_instance(); } - static inline const DataMessage* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_default_instance_); + static inline const DataMessage_OpenGroupInvitation* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_OpenGroupInvitation_default_instance_); } static constexpr int kIndexInFileMessages = 16; - friend void swap(DataMessage& a, DataMessage& b) { + friend void swap(DataMessage_OpenGroupInvitation& a, DataMessage_OpenGroupInvitation& b) { a.Swap(&b); } - inline void Swap(DataMessage* other) { + inline void Swap(DataMessage_OpenGroupInvitation* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3835,7 +3747,7 @@ class DataMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage* other) { + void UnsafeArenaSwap(DataMessage_OpenGroupInvitation* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3843,12 +3755,12 @@ class DataMessage final : // implements Message ---------------------------------------------- - DataMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_OpenGroupInvitation* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage& from); - void MergeFrom(const DataMessage& from); + void CopyFrom(const DataMessage_OpenGroupInvitation& from); + void MergeFrom(const DataMessage_OpenGroupInvitation& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3862,15 +3774,15 @@ class DataMessage final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(DataMessage* other); + void InternalSwap(DataMessage_OpenGroupInvitation* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage"; + return "SessionProtos.DataMessage.OpenGroupInvitation"; } protected: - explicit DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -3878,334 +3790,87 @@ class DataMessage final : // nested types ---------------------------------------------------- - typedef DataMessage_Quote Quote; - typedef DataMessage_Preview Preview; - typedef DataMessage_Reaction Reaction; - typedef DataMessage_OpenGroupInvitation OpenGroupInvitation; - typedef DataMessage_ClosedGroupControlMessage ClosedGroupControlMessage; - - typedef DataMessage_Flags Flags; - static constexpr Flags EXPIRATION_TIMER_UPDATE = - DataMessage_Flags_EXPIRATION_TIMER_UPDATE; - static inline bool Flags_IsValid(int value) { - return DataMessage_Flags_IsValid(value); - } - static constexpr Flags Flags_MIN = - DataMessage_Flags_Flags_MIN; - static constexpr Flags Flags_MAX = - DataMessage_Flags_Flags_MAX; - static constexpr int Flags_ARRAYSIZE = - DataMessage_Flags_Flags_ARRAYSIZE; - template - static inline const std::string& Flags_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Flags_Name."); - return DataMessage_Flags_Name(enum_t_value); - } - static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Flags* value) { - return DataMessage_Flags_Parse(name, value); - } - // accessors ------------------------------------------------------- enum : int { - kAttachmentsFieldNumber = 2, - kPreviewFieldNumber = 10, - kBodyFieldNumber = 1, - kProfileKeyFieldNumber = 6, - kSyncTargetFieldNumber = 105, - kQuoteFieldNumber = 8, - kReactionFieldNumber = 11, - kProfileFieldNumber = 101, - kOpenGroupInvitationFieldNumber = 102, - kClosedGroupControlMessageFieldNumber = 104, - kFlagsFieldNumber = 4, - kExpireTimerFieldNumber = 5, - kTimestampFieldNumber = 7, - kBlocksCommunityMessageRequestsFieldNumber = 106, + kUrlFieldNumber = 1, + kNameFieldNumber = 3, }; - // repeated .SessionProtos.AttachmentPointer attachments = 2; - int attachments_size() const; - private: - int _internal_attachments_size() const; - public: - void clear_attachments(); - ::SessionProtos::AttachmentPointer* mutable_attachments(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >* - mutable_attachments(); + // required string url = 1; + bool has_url() const; private: - const ::SessionProtos::AttachmentPointer& _internal_attachments(int index) const; - ::SessionProtos::AttachmentPointer* _internal_add_attachments(); + bool _internal_has_url() const; public: - const ::SessionProtos::AttachmentPointer& attachments(int index) const; - ::SessionProtos::AttachmentPointer* add_attachments(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >& - attachments() const; - - // repeated .SessionProtos.DataMessage.Preview preview = 10; - int preview_size() const; - private: - int _internal_preview_size() const; - public: - void clear_preview(); - ::SessionProtos::DataMessage_Preview* mutable_preview(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >* - mutable_preview(); - private: - const ::SessionProtos::DataMessage_Preview& _internal_preview(int index) const; - ::SessionProtos::DataMessage_Preview* _internal_add_preview(); - public: - const ::SessionProtos::DataMessage_Preview& preview(int index) const; - ::SessionProtos::DataMessage_Preview* add_preview(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >& - preview() const; - - // optional string body = 1; - bool has_body() const; - private: - bool _internal_has_body() const; - public: - void clear_body(); - const std::string& body() const; - template - void set_body(ArgT0&& arg0, ArgT... args); - std::string* mutable_body(); - PROTOBUF_NODISCARD std::string* release_body(); - void set_allocated_body(std::string* body); - private: - const std::string& _internal_body() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_body(const std::string& value); - std::string* _internal_mutable_body(); - public: - - // optional bytes profileKey = 6; - bool has_profilekey() const; - private: - bool _internal_has_profilekey() const; - public: - void clear_profilekey(); - const std::string& profilekey() const; + void clear_url(); + const std::string& url() const; template - void set_profilekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilekey(); - PROTOBUF_NODISCARD std::string* release_profilekey(); - void set_allocated_profilekey(std::string* profilekey); + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); private: - const std::string& _internal_profilekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); - std::string* _internal_mutable_profilekey(); + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); public: - // optional string syncTarget = 105; - bool has_synctarget() const; + // required string name = 3; + bool has_name() const; private: - bool _internal_has_synctarget() const; + bool _internal_has_name() const; public: - void clear_synctarget(); - const std::string& synctarget() const; + void clear_name(); + const std::string& name() const; template - void set_synctarget(ArgT0&& arg0, ArgT... args); - std::string* mutable_synctarget(); - PROTOBUF_NODISCARD std::string* release_synctarget(); - void set_allocated_synctarget(std::string* synctarget); - private: - const std::string& _internal_synctarget() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_synctarget(const std::string& value); - std::string* _internal_mutable_synctarget(); - public: - - // optional .SessionProtos.DataMessage.Quote quote = 8; - bool has_quote() const; - private: - bool _internal_has_quote() const; - public: - void clear_quote(); - const ::SessionProtos::DataMessage_Quote& quote() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Quote* release_quote(); - ::SessionProtos::DataMessage_Quote* mutable_quote(); - void set_allocated_quote(::SessionProtos::DataMessage_Quote* quote); - private: - const ::SessionProtos::DataMessage_Quote& _internal_quote() const; - ::SessionProtos::DataMessage_Quote* _internal_mutable_quote(); - public: - void unsafe_arena_set_allocated_quote( - ::SessionProtos::DataMessage_Quote* quote); - ::SessionProtos::DataMessage_Quote* unsafe_arena_release_quote(); - - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - bool has_reaction() const; - private: - bool _internal_has_reaction() const; - public: - void clear_reaction(); - const ::SessionProtos::DataMessage_Reaction& reaction() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Reaction* release_reaction(); - ::SessionProtos::DataMessage_Reaction* mutable_reaction(); - void set_allocated_reaction(::SessionProtos::DataMessage_Reaction* reaction); - private: - const ::SessionProtos::DataMessage_Reaction& _internal_reaction() const; - ::SessionProtos::DataMessage_Reaction* _internal_mutable_reaction(); - public: - void unsafe_arena_set_allocated_reaction( - ::SessionProtos::DataMessage_Reaction* reaction); - ::SessionProtos::DataMessage_Reaction* unsafe_arena_release_reaction(); - - // optional .SessionProtos.LokiProfile profile = 101; - bool has_profile() const; - private: - bool _internal_has_profile() const; - public: - void clear_profile(); - const ::SessionProtos::LokiProfile& profile() const; - PROTOBUF_NODISCARD ::SessionProtos::LokiProfile* release_profile(); - ::SessionProtos::LokiProfile* mutable_profile(); - void set_allocated_profile(::SessionProtos::LokiProfile* profile); - private: - const ::SessionProtos::LokiProfile& _internal_profile() const; - ::SessionProtos::LokiProfile* _internal_mutable_profile(); - public: - void unsafe_arena_set_allocated_profile( - ::SessionProtos::LokiProfile* profile); - ::SessionProtos::LokiProfile* unsafe_arena_release_profile(); - - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - bool has_opengroupinvitation() const; - private: - bool _internal_has_opengroupinvitation() const; - public: - void clear_opengroupinvitation(); - const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_OpenGroupInvitation* release_opengroupinvitation(); - ::SessionProtos::DataMessage_OpenGroupInvitation* mutable_opengroupinvitation(); - void set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); - private: - const ::SessionProtos::DataMessage_OpenGroupInvitation& _internal_opengroupinvitation() const; - ::SessionProtos::DataMessage_OpenGroupInvitation* _internal_mutable_opengroupinvitation(); - public: - void unsafe_arena_set_allocated_opengroupinvitation( - ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); - ::SessionProtos::DataMessage_OpenGroupInvitation* unsafe_arena_release_opengroupinvitation(); - - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - bool has_closedgroupcontrolmessage() const; - private: - bool _internal_has_closedgroupcontrolmessage() const; - public: - void clear_closedgroupcontrolmessage(); - const ::SessionProtos::DataMessage_ClosedGroupControlMessage& closedgroupcontrolmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_ClosedGroupControlMessage* release_closedgroupcontrolmessage(); - ::SessionProtos::DataMessage_ClosedGroupControlMessage* mutable_closedgroupcontrolmessage(); - void set_allocated_closedgroupcontrolmessage(::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage); - private: - const ::SessionProtos::DataMessage_ClosedGroupControlMessage& _internal_closedgroupcontrolmessage() const; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* _internal_mutable_closedgroupcontrolmessage(); - public: - void unsafe_arena_set_allocated_closedgroupcontrolmessage( - ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage); - ::SessionProtos::DataMessage_ClosedGroupControlMessage* unsafe_arena_release_closedgroupcontrolmessage(); - - // optional uint32 flags = 4; - bool has_flags() const; - private: - bool _internal_has_flags() const; - public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); - private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); - public: - - // optional uint32 expireTimer = 5; - bool has_expiretimer() const; - private: - bool _internal_has_expiretimer() const; - public: - void clear_expiretimer(); - uint32_t expiretimer() const; - void set_expiretimer(uint32_t value); - private: - uint32_t _internal_expiretimer() const; - void _internal_set_expiretimer(uint32_t value); - public: - - // optional uint64 timestamp = 7; - bool has_timestamp() const; - private: - bool _internal_has_timestamp() const; - public: - void clear_timestamp(); - uint64_t timestamp() const; - void set_timestamp(uint64_t value); - private: - uint64_t _internal_timestamp() const; - void _internal_set_timestamp(uint64_t value); - public: - - // optional bool blocksCommunityMessageRequests = 106; - bool has_blockscommunitymessagerequests() const; - private: - bool _internal_has_blockscommunitymessagerequests() const; - public: - void clear_blockscommunitymessagerequests(); - bool blockscommunitymessagerequests() const; - void set_blockscommunitymessagerequests(bool value); + void set_name(ArgT0&& arg0, ArgT... args); + std::string* mutable_name(); + PROTOBUF_NODISCARD std::string* release_name(); + void set_allocated_name(std::string* name); private: - bool _internal_blockscommunitymessagerequests() const; - void _internal_set_blockscommunitymessagerequests(bool value); + const std::string& _internal_name() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.OpenGroupInvitation) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer > attachments_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview > preview_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr body_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr synctarget_; - ::SessionProtos::DataMessage_Quote* quote_; - ::SessionProtos::DataMessage_Reaction* reaction_; - ::SessionProtos::LokiProfile* profile_; - ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation_; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage_; - uint32_t flags_; - uint32_t expiretimer_; - uint64_t timestamp_; - bool blockscommunitymessagerequests_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ConfigurationMessage_ClosedGroup final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.ClosedGroup) */ { +class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) */ { public: - inline ConfigurationMessage_ClosedGroup() : ConfigurationMessage_ClosedGroup(nullptr) {} - ~ConfigurationMessage_ClosedGroup() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper() : DataMessage_ClosedGroupControlMessage_KeyPairWrapper(nullptr) {} + ~DataMessage_ClosedGroupControlMessage_KeyPairWrapper() override; + explicit PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage_ClosedGroup(const ConfigurationMessage_ClosedGroup& from); - ConfigurationMessage_ClosedGroup(ConfigurationMessage_ClosedGroup&& from) noexcept - : ConfigurationMessage_ClosedGroup() { + DataMessage_ClosedGroupControlMessage_KeyPairWrapper(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); + DataMessage_ClosedGroupControlMessage_KeyPairWrapper(DataMessage_ClosedGroupControlMessage_KeyPairWrapper&& from) noexcept + : DataMessage_ClosedGroupControlMessage_KeyPairWrapper() { *this = ::std::move(from); } - inline ConfigurationMessage_ClosedGroup& operator=(const ConfigurationMessage_ClosedGroup& from) { + inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper& operator=(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage_ClosedGroup& operator=(ConfigurationMessage_ClosedGroup&& from) noexcept { + inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper& operator=(DataMessage_ClosedGroupControlMessage_KeyPairWrapper&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -4226,20 +3891,20 @@ class ConfigurationMessage_ClosedGroup final : return _internal_metadata_.mutable_unknown_fields(); } - static const ConfigurationMessage_ClosedGroup& default_instance() { + static const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage_ClosedGroup* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_ClosedGroup_default_instance_); + static inline const DataMessage_ClosedGroupControlMessage_KeyPairWrapper* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_ClosedGroupControlMessage_KeyPairWrapper_default_instance_); } static constexpr int kIndexInFileMessages = 17; - friend void swap(ConfigurationMessage_ClosedGroup& a, ConfigurationMessage_ClosedGroup& b) { + friend void swap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper& a, DataMessage_ClosedGroupControlMessage_KeyPairWrapper& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage_ClosedGroup* other) { + inline void Swap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -4252,7 +3917,7 @@ class ConfigurationMessage_ClosedGroup final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage_ClosedGroup* other) { + void UnsafeArenaSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -4260,12 +3925,12 @@ class ConfigurationMessage_ClosedGroup final : // implements Message ---------------------------------------------- - ConfigurationMessage_ClosedGroup* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_ClosedGroupControlMessage_KeyPairWrapper* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage_ClosedGroup& from); - void MergeFrom(const ConfigurationMessage_ClosedGroup& from); + void CopyFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); + void MergeFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4279,15 +3944,15 @@ class ConfigurationMessage_ClosedGroup final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage_ClosedGroup* other); + void InternalSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage.ClosedGroup"; + return "SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper"; } protected: - explicit ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -4298,62 +3963,10 @@ class ConfigurationMessage_ClosedGroup final : // accessors ------------------------------------------------------- enum : int { - kMembersFieldNumber = 4, - kAdminsFieldNumber = 5, kPublicKeyFieldNumber = 1, - kNameFieldNumber = 2, - kEncryptionKeyPairFieldNumber = 3, - kExpirationTimerFieldNumber = 6, + kEncryptedKeyPairFieldNumber = 2, }; - // repeated bytes members = 4; - int members_size() const; - private: - int _internal_members_size() const; - public: - void clear_members(); - const std::string& members(int index) const; - std::string* mutable_members(int index); - void set_members(int index, const std::string& value); - void set_members(int index, std::string&& value); - void set_members(int index, const char* value); - void set_members(int index, const void* value, size_t size); - std::string* add_members(); - void add_members(const std::string& value); - void add_members(std::string&& value); - void add_members(const char* value); - void add_members(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& members() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_members(); - private: - const std::string& _internal_members(int index) const; - std::string* _internal_add_members(); - public: - - // repeated bytes admins = 5; - int admins_size() const; - private: - int _internal_admins_size() const; - public: - void clear_admins(); - const std::string& admins(int index) const; - std::string* mutable_admins(int index); - void set_admins(int index, const std::string& value); - void set_admins(int index, std::string&& value); - void set_admins(int index, const char* value); - void set_admins(int index, const void* value, size_t size); - std::string* add_admins(); - void add_admins(const std::string& value); - void add_admins(std::string&& value); - void add_admins(const char* value); - void add_admins(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& admins() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_admins(); - private: - const std::string& _internal_admins(int index) const; - std::string* _internal_add_admins(); - public: - - // optional bytes publicKey = 1; + // required bytes publicKey = 1; bool has_publickey() const; private: bool _internal_has_publickey() const; @@ -4371,95 +3984,63 @@ class ConfigurationMessage_ClosedGroup final : std::string* _internal_mutable_publickey(); public: - // optional string name = 2; - bool has_name() const; + // required bytes encryptedKeyPair = 2; + bool has_encryptedkeypair() const; private: - bool _internal_has_name() const; + bool _internal_has_encryptedkeypair() const; public: - void clear_name(); - const std::string& name() const; + void clear_encryptedkeypair(); + const std::string& encryptedkeypair() const; template - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; - bool has_encryptionkeypair() const; - private: - bool _internal_has_encryptionkeypair() const; - public: - void clear_encryptionkeypair(); - const ::SessionProtos::KeyPair& encryptionkeypair() const; - PROTOBUF_NODISCARD ::SessionProtos::KeyPair* release_encryptionkeypair(); - ::SessionProtos::KeyPair* mutable_encryptionkeypair(); - void set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair); - private: - const ::SessionProtos::KeyPair& _internal_encryptionkeypair() const; - ::SessionProtos::KeyPair* _internal_mutable_encryptionkeypair(); - public: - void unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair); - ::SessionProtos::KeyPair* unsafe_arena_release_encryptionkeypair(); - - // optional uint32 expirationTimer = 6; - bool has_expirationtimer() const; - private: - bool _internal_has_expirationtimer() const; - public: - void clear_expirationtimer(); - uint32_t expirationtimer() const; - void set_expirationtimer(uint32_t value); + void set_encryptedkeypair(ArgT0&& arg0, ArgT... args); + std::string* mutable_encryptedkeypair(); + PROTOBUF_NODISCARD std::string* release_encryptedkeypair(); + void set_allocated_encryptedkeypair(std::string* encryptedkeypair); private: - uint32_t _internal_expirationtimer() const; - void _internal_set_expirationtimer(uint32_t value); + const std::string& _internal_encryptedkeypair() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_encryptedkeypair(const std::string& value); + std::string* _internal_mutable_encryptedkeypair(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField members_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField admins_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::SessionProtos::KeyPair* encryptionkeypair_; - uint32_t expirationtimer_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr encryptedkeypair_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ConfigurationMessage_Contact final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.Contact) */ { +class DataMessage_ClosedGroupControlMessage final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.ClosedGroupControlMessage) */ { public: - inline ConfigurationMessage_Contact() : ConfigurationMessage_Contact(nullptr) {} - ~ConfigurationMessage_Contact() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_ClosedGroupControlMessage() : DataMessage_ClosedGroupControlMessage(nullptr) {} + ~DataMessage_ClosedGroupControlMessage() override; + explicit PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage_Contact(const ConfigurationMessage_Contact& from); - ConfigurationMessage_Contact(ConfigurationMessage_Contact&& from) noexcept - : ConfigurationMessage_Contact() { + DataMessage_ClosedGroupControlMessage(const DataMessage_ClosedGroupControlMessage& from); + DataMessage_ClosedGroupControlMessage(DataMessage_ClosedGroupControlMessage&& from) noexcept + : DataMessage_ClosedGroupControlMessage() { *this = ::std::move(from); } - inline ConfigurationMessage_Contact& operator=(const ConfigurationMessage_Contact& from) { + inline DataMessage_ClosedGroupControlMessage& operator=(const DataMessage_ClosedGroupControlMessage& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage_Contact& operator=(ConfigurationMessage_Contact&& from) noexcept { + inline DataMessage_ClosedGroupControlMessage& operator=(DataMessage_ClosedGroupControlMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -4480,20 +4061,20 @@ class ConfigurationMessage_Contact final : return _internal_metadata_.mutable_unknown_fields(); } - static const ConfigurationMessage_Contact& default_instance() { + static const DataMessage_ClosedGroupControlMessage& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage_Contact* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_Contact_default_instance_); + static inline const DataMessage_ClosedGroupControlMessage* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_ClosedGroupControlMessage_default_instance_); } static constexpr int kIndexInFileMessages = 18; - friend void swap(ConfigurationMessage_Contact& a, ConfigurationMessage_Contact& b) { + friend void swap(DataMessage_ClosedGroupControlMessage& a, DataMessage_ClosedGroupControlMessage& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage_Contact* other) { + inline void Swap(DataMessage_ClosedGroupControlMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -4506,7 +4087,7 @@ class ConfigurationMessage_Contact final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage_Contact* other) { + void UnsafeArenaSwap(DataMessage_ClosedGroupControlMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -4514,12 +4095,12 @@ class ConfigurationMessage_Contact final : // implements Message ---------------------------------------------- - ConfigurationMessage_Contact* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_ClosedGroupControlMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage_Contact& from); - void MergeFrom(const ConfigurationMessage_Contact& from); + void CopyFrom(const DataMessage_ClosedGroupControlMessage& from); + void MergeFrom(const DataMessage_ClosedGroupControlMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4533,15 +4114,15 @@ class ConfigurationMessage_Contact final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage_Contact* other); + void InternalSwap(DataMessage_ClosedGroupControlMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage.Contact"; + return "SessionProtos.DataMessage.ClosedGroupControlMessage"; } protected: - explicit ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -4549,18 +4130,123 @@ class ConfigurationMessage_Contact final : // nested types ---------------------------------------------------- + typedef DataMessage_ClosedGroupControlMessage_KeyPairWrapper KeyPairWrapper; + + typedef DataMessage_ClosedGroupControlMessage_Type Type; + static constexpr Type NEW = + DataMessage_ClosedGroupControlMessage_Type_NEW; + static constexpr Type ENCRYPTION_KEY_PAIR = + DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR; + static constexpr Type NAME_CHANGE = + DataMessage_ClosedGroupControlMessage_Type_NAME_CHANGE; + static constexpr Type MEMBERS_ADDED = + DataMessage_ClosedGroupControlMessage_Type_MEMBERS_ADDED; + static constexpr Type MEMBERS_REMOVED = + DataMessage_ClosedGroupControlMessage_Type_MEMBERS_REMOVED; + static constexpr Type MEMBER_LEFT = + DataMessage_ClosedGroupControlMessage_Type_MEMBER_LEFT; + static constexpr Type ENCRYPTION_KEY_PAIR_REQUEST = + DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR_REQUEST; + static inline bool Type_IsValid(int value) { + return DataMessage_ClosedGroupControlMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + DataMessage_ClosedGroupControlMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + DataMessage_ClosedGroupControlMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + DataMessage_ClosedGroupControlMessage_Type_Type_ARRAYSIZE; + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return DataMessage_ClosedGroupControlMessage_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return DataMessage_ClosedGroupControlMessage_Type_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kPublicKeyFieldNumber = 1, - kNameFieldNumber = 2, - kProfilePictureFieldNumber = 3, - kProfileKeyFieldNumber = 4, - kIsApprovedFieldNumber = 5, - kIsBlockedFieldNumber = 6, - kDidApproveMeFieldNumber = 7, + kMembersFieldNumber = 5, + kAdminsFieldNumber = 6, + kWrappersFieldNumber = 7, + kPublicKeyFieldNumber = 2, + kNameFieldNumber = 3, + kEncryptionKeyPairFieldNumber = 4, + kExpirationTimerFieldNumber = 8, + kTypeFieldNumber = 1, }; - // required bytes publicKey = 1; + // repeated bytes members = 5; + int members_size() const; + private: + int _internal_members_size() const; + public: + void clear_members(); + const std::string& members(int index) const; + std::string* mutable_members(int index); + void set_members(int index, const std::string& value); + void set_members(int index, std::string&& value); + void set_members(int index, const char* value); + void set_members(int index, const void* value, size_t size); + std::string* add_members(); + void add_members(const std::string& value); + void add_members(std::string&& value); + void add_members(const char* value); + void add_members(const void* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& members() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_members(); + private: + const std::string& _internal_members(int index) const; + std::string* _internal_add_members(); + public: + + // repeated bytes admins = 6; + int admins_size() const; + private: + int _internal_admins_size() const; + public: + void clear_admins(); + const std::string& admins(int index) const; + std::string* mutable_admins(int index); + void set_admins(int index, const std::string& value); + void set_admins(int index, std::string&& value); + void set_admins(int index, const char* value); + void set_admins(int index, const void* value, size_t size); + std::string* add_admins(); + void add_admins(const std::string& value); + void add_admins(std::string&& value); + void add_admins(const char* value); + void add_admins(const void* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& admins() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_admins(); + private: + const std::string& _internal_admins(int index) const; + std::string* _internal_add_admins(); + public: + + // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; + int wrappers_size() const; + private: + int _internal_wrappers_size() const; + public: + void clear_wrappers(); + ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* mutable_wrappers(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >* + mutable_wrappers(); + private: + const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& _internal_wrappers(int index) const; + ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* _internal_add_wrappers(); + public: + const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& wrappers(int index) const; + ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* add_wrappers(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >& + wrappers() const; + + // optional bytes publicKey = 2; bool has_publickey() const; private: bool _internal_has_publickey() const; @@ -4578,7 +4264,7 @@ class ConfigurationMessage_Contact final : std::string* _internal_mutable_publickey(); public: - // required string name = 2; + // optional string name = 3; bool has_name() const; private: bool _internal_has_name() const; @@ -4596,125 +4282,92 @@ class ConfigurationMessage_Contact final : std::string* _internal_mutable_name(); public: - // optional string profilePicture = 3; - bool has_profilepicture() const; - private: - bool _internal_has_profilepicture() const; - public: - void clear_profilepicture(); - const std::string& profilepicture() const; - template - void set_profilepicture(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilepicture(); - PROTOBUF_NODISCARD std::string* release_profilepicture(); - void set_allocated_profilepicture(std::string* profilepicture); - private: - const std::string& _internal_profilepicture() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); - std::string* _internal_mutable_profilepicture(); - public: - - // optional bytes profileKey = 4; - bool has_profilekey() const; - private: - bool _internal_has_profilekey() const; - public: - void clear_profilekey(); - const std::string& profilekey() const; - template - void set_profilekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilekey(); - PROTOBUF_NODISCARD std::string* release_profilekey(); - void set_allocated_profilekey(std::string* profilekey); - private: - const std::string& _internal_profilekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); - std::string* _internal_mutable_profilekey(); - public: - - // optional bool isApproved = 5; - bool has_isapproved() const; + // optional .SessionProtos.KeyPair encryptionKeyPair = 4; + bool has_encryptionkeypair() const; private: - bool _internal_has_isapproved() const; + bool _internal_has_encryptionkeypair() const; public: - void clear_isapproved(); - bool isapproved() const; - void set_isapproved(bool value); + void clear_encryptionkeypair(); + const ::SessionProtos::KeyPair& encryptionkeypair() const; + PROTOBUF_NODISCARD ::SessionProtos::KeyPair* release_encryptionkeypair(); + ::SessionProtos::KeyPair* mutable_encryptionkeypair(); + void set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair); private: - bool _internal_isapproved() const; - void _internal_set_isapproved(bool value); + const ::SessionProtos::KeyPair& _internal_encryptionkeypair() const; + ::SessionProtos::KeyPair* _internal_mutable_encryptionkeypair(); public: + void unsafe_arena_set_allocated_encryptionkeypair( + ::SessionProtos::KeyPair* encryptionkeypair); + ::SessionProtos::KeyPair* unsafe_arena_release_encryptionkeypair(); - // optional bool isBlocked = 6; - bool has_isblocked() const; + // optional uint32 expirationTimer = 8; + bool has_expirationtimer() const; private: - bool _internal_has_isblocked() const; + bool _internal_has_expirationtimer() const; public: - void clear_isblocked(); - bool isblocked() const; - void set_isblocked(bool value); + void clear_expirationtimer(); + uint32_t expirationtimer() const; + void set_expirationtimer(uint32_t value); private: - bool _internal_isblocked() const; - void _internal_set_isblocked(bool value); + uint32_t _internal_expirationtimer() const; + void _internal_set_expirationtimer(uint32_t value); public: - // optional bool didApproveMe = 7; - bool has_didapproveme() const; + // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; + bool has_type() const; private: - bool _internal_has_didapproveme() const; + bool _internal_has_type() const; public: - void clear_didapproveme(); - bool didapproveme() const; - void set_didapproveme(bool value); + void clear_type(); + ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type type() const; + void set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value); private: - bool _internal_didapproveme() const; - void _internal_set_didapproveme(bool value); + ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.ClosedGroupControlMessage) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField members_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField admins_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper > wrappers_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; - bool isapproved_; - bool isblocked_; - bool didapproveme_; + ::SessionProtos::KeyPair* encryptionkeypair_; + uint32_t expirationtimer_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ConfigurationMessage_ProProof final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.ProProof) */ { +class DataMessage final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage) */ { public: - inline ConfigurationMessage_ProProof() : ConfigurationMessage_ProProof(nullptr) {} - ~ConfigurationMessage_ProProof() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage_ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage() : DataMessage(nullptr) {} + ~DataMessage() override; + explicit PROTOBUF_CONSTEXPR DataMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage_ProProof(const ConfigurationMessage_ProProof& from); - ConfigurationMessage_ProProof(ConfigurationMessage_ProProof&& from) noexcept - : ConfigurationMessage_ProProof() { + DataMessage(const DataMessage& from); + DataMessage(DataMessage&& from) noexcept + : DataMessage() { *this = ::std::move(from); } - inline ConfigurationMessage_ProProof& operator=(const ConfigurationMessage_ProProof& from) { + inline DataMessage& operator=(const DataMessage& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage_ProProof& operator=(ConfigurationMessage_ProProof&& from) noexcept { + inline DataMessage& operator=(DataMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -4735,20 +4388,20 @@ class ConfigurationMessage_ProProof final : return _internal_metadata_.mutable_unknown_fields(); } - static const ConfigurationMessage_ProProof& default_instance() { + static const DataMessage& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage_ProProof* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_ProProof_default_instance_); + static inline const DataMessage* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_default_instance_); } static constexpr int kIndexInFileMessages = 19; - friend void swap(ConfigurationMessage_ProProof& a, ConfigurationMessage_ProProof& b) { + friend void swap(DataMessage& a, DataMessage& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage_ProProof* other) { + inline void Swap(DataMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -4761,7 +4414,7 @@ class ConfigurationMessage_ProProof final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage_ProProof* other) { + void UnsafeArenaSwap(DataMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -4769,12 +4422,12 @@ class ConfigurationMessage_ProProof final : // implements Message ---------------------------------------------- - ConfigurationMessage_ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage_ProProof& from); - void MergeFrom(const ConfigurationMessage_ProProof& from); + void CopyFrom(const DataMessage& from); + void MergeFrom(const DataMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4788,15 +4441,15 @@ class ConfigurationMessage_ProProof final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage_ProProof* other); + void InternalSwap(DataMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage.ProProof"; + return "SessionProtos.DataMessage"; } protected: - explicit ConfigurationMessage_ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -4804,307 +4457,334 @@ class ConfigurationMessage_ProProof final : // nested types ---------------------------------------------------- + typedef DataMessage_Quote Quote; + typedef DataMessage_Preview Preview; + typedef DataMessage_Reaction Reaction; + typedef DataMessage_OpenGroupInvitation OpenGroupInvitation; + typedef DataMessage_ClosedGroupControlMessage ClosedGroupControlMessage; + + typedef DataMessage_Flags Flags; + static constexpr Flags EXPIRATION_TIMER_UPDATE = + DataMessage_Flags_EXPIRATION_TIMER_UPDATE; + static inline bool Flags_IsValid(int value) { + return DataMessage_Flags_IsValid(value); + } + static constexpr Flags Flags_MIN = + DataMessage_Flags_Flags_MIN; + static constexpr Flags Flags_MAX = + DataMessage_Flags_Flags_MAX; + static constexpr int Flags_ARRAYSIZE = + DataMessage_Flags_Flags_ARRAYSIZE; + template + static inline const std::string& Flags_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Flags_Name."); + return DataMessage_Flags_Name(enum_t_value); + } + static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Flags* value) { + return DataMessage_Flags_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kGenIndexHashFieldNumber = 2, - kRotatingPublicKeyFieldNumber = 3, - kSigFieldNumber = 5, - kExpiryUnixTsFieldNumber = 4, - kVersionFieldNumber = 1, - }; - // required bytes genIndexHash = 2; - bool has_genindexhash() const; - private: - bool _internal_has_genindexhash() const; - public: - void clear_genindexhash(); - const std::string& genindexhash() const; - template - void set_genindexhash(ArgT0&& arg0, ArgT... args); - std::string* mutable_genindexhash(); - PROTOBUF_NODISCARD std::string* release_genindexhash(); - void set_allocated_genindexhash(std::string* genindexhash); + kAttachmentsFieldNumber = 2, + kPreviewFieldNumber = 10, + kBodyFieldNumber = 1, + kProfileKeyFieldNumber = 6, + kSyncTargetFieldNumber = 105, + kQuoteFieldNumber = 8, + kReactionFieldNumber = 11, + kProfileFieldNumber = 101, + kOpenGroupInvitationFieldNumber = 102, + kClosedGroupControlMessageFieldNumber = 104, + kFlagsFieldNumber = 4, + kExpireTimerFieldNumber = 5, + kTimestampFieldNumber = 7, + kBlocksCommunityMessageRequestsFieldNumber = 106, + }; + // repeated .SessionProtos.AttachmentPointer attachments = 2; + int attachments_size() const; private: - const std::string& _internal_genindexhash() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); - std::string* _internal_mutable_genindexhash(); + int _internal_attachments_size() const; + public: + void clear_attachments(); + ::SessionProtos::AttachmentPointer* mutable_attachments(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >* + mutable_attachments(); + private: + const ::SessionProtos::AttachmentPointer& _internal_attachments(int index) const; + ::SessionProtos::AttachmentPointer* _internal_add_attachments(); public: + const ::SessionProtos::AttachmentPointer& attachments(int index) const; + ::SessionProtos::AttachmentPointer* add_attachments(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >& + attachments() const; - // required bytes rotatingPublicKey = 3; - bool has_rotatingpublickey() const; + // repeated .SessionProtos.DataMessage.Preview preview = 10; + int preview_size() const; private: - bool _internal_has_rotatingpublickey() const; + int _internal_preview_size() const; public: - void clear_rotatingpublickey(); - const std::string& rotatingpublickey() const; - template - void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_rotatingpublickey(); - PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); - void set_allocated_rotatingpublickey(std::string* rotatingpublickey); + void clear_preview(); + ::SessionProtos::DataMessage_Preview* mutable_preview(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >* + mutable_preview(); private: - const std::string& _internal_rotatingpublickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); - std::string* _internal_mutable_rotatingpublickey(); + const ::SessionProtos::DataMessage_Preview& _internal_preview(int index) const; + ::SessionProtos::DataMessage_Preview* _internal_add_preview(); public: + const ::SessionProtos::DataMessage_Preview& preview(int index) const; + ::SessionProtos::DataMessage_Preview* add_preview(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >& + preview() const; - // required bytes sig = 5; - bool has_sig() const; + // optional string body = 1; + bool has_body() const; private: - bool _internal_has_sig() const; + bool _internal_has_body() const; public: - void clear_sig(); - const std::string& sig() const; + void clear_body(); + const std::string& body() const; template - void set_sig(ArgT0&& arg0, ArgT... args); - std::string* mutable_sig(); - PROTOBUF_NODISCARD std::string* release_sig(); - void set_allocated_sig(std::string* sig); + void set_body(ArgT0&& arg0, ArgT... args); + std::string* mutable_body(); + PROTOBUF_NODISCARD std::string* release_body(); + void set_allocated_body(std::string* body); private: - const std::string& _internal_sig() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); - std::string* _internal_mutable_sig(); + const std::string& _internal_body() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_body(const std::string& value); + std::string* _internal_mutable_body(); public: - // required uint64 expiryUnixTs = 4; - bool has_expiryunixts() const; + // optional bytes profileKey = 6; + bool has_profilekey() const; private: - bool _internal_has_expiryunixts() const; + bool _internal_has_profilekey() const; public: - void clear_expiryunixts(); - uint64_t expiryunixts() const; - void set_expiryunixts(uint64_t value); + void clear_profilekey(); + const std::string& profilekey() const; + template + void set_profilekey(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilekey(); + PROTOBUF_NODISCARD std::string* release_profilekey(); + void set_allocated_profilekey(std::string* profilekey); private: - uint64_t _internal_expiryunixts() const; - void _internal_set_expiryunixts(uint64_t value); + const std::string& _internal_profilekey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); + std::string* _internal_mutable_profilekey(); public: - // required uint32 version = 1; - bool has_version() const; + // optional string syncTarget = 105; + bool has_synctarget() const; private: - bool _internal_has_version() const; + bool _internal_has_synctarget() const; public: - void clear_version(); - uint32_t version() const; - void set_version(uint32_t value); + void clear_synctarget(); + const std::string& synctarget() const; + template + void set_synctarget(ArgT0&& arg0, ArgT... args); + std::string* mutable_synctarget(); + PROTOBUF_NODISCARD std::string* release_synctarget(); + void set_allocated_synctarget(std::string* synctarget); private: - uint32_t _internal_version() const; - void _internal_set_version(uint32_t value); + const std::string& _internal_synctarget() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_synctarget(const std::string& value); + std::string* _internal_mutable_synctarget(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.ProProof) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; - uint64_t expiryunixts_; - uint32_t version_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_SessionProtos_2eproto; -}; -// ------------------------------------------------------------------- - -class ConfigurationMessage_Pro final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.Pro) */ { - public: - inline ConfigurationMessage_Pro() : ConfigurationMessage_Pro(nullptr) {} - ~ConfigurationMessage_Pro() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage_Pro(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - ConfigurationMessage_Pro(const ConfigurationMessage_Pro& from); - ConfigurationMessage_Pro(ConfigurationMessage_Pro&& from) noexcept - : ConfigurationMessage_Pro() { - *this = ::std::move(from); - } - - inline ConfigurationMessage_Pro& operator=(const ConfigurationMessage_Pro& from) { - CopyFrom(from); - return *this; - } - inline ConfigurationMessage_Pro& operator=(ConfigurationMessage_Pro&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); - } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); - } - - static const ConfigurationMessage_Pro& default_instance() { - return *internal_default_instance(); - } - static inline const ConfigurationMessage_Pro* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_Pro_default_instance_); - } - static constexpr int kIndexInFileMessages = - 20; - - friend void swap(ConfigurationMessage_Pro& a, ConfigurationMessage_Pro& b) { - a.Swap(&b); - } - inline void Swap(ConfigurationMessage_Pro* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(ConfigurationMessage_Pro* other) { - if (other == this) return; - GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - ConfigurationMessage_Pro* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage_Pro& from); - void MergeFrom(const ConfigurationMessage_Pro& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - uint8_t* _InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - + // optional .SessionProtos.DataMessage.Quote quote = 8; + bool has_quote() const; private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage_Pro* other); - + bool _internal_has_quote() const; + public: + void clear_quote(); + const ::SessionProtos::DataMessage_Quote& quote() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Quote* release_quote(); + ::SessionProtos::DataMessage_Quote* mutable_quote(); + void set_allocated_quote(::SessionProtos::DataMessage_Quote* quote); private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage.Pro"; - } - protected: - explicit ConfigurationMessage_Pro(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned = false); + const ::SessionProtos::DataMessage_Quote& _internal_quote() const; + ::SessionProtos::DataMessage_Quote* _internal_mutable_quote(); public: + void unsafe_arena_set_allocated_quote( + ::SessionProtos::DataMessage_Quote* quote); + ::SessionProtos::DataMessage_Quote* unsafe_arena_release_quote(); - std::string GetTypeName() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kRotatingPrivKeyFieldNumber = 1, - kProofFieldNumber = 2, - }; - // required bytes rotatingPrivKey = 1; - bool has_rotatingprivkey() const; + // optional .SessionProtos.DataMessage.Reaction reaction = 11; + bool has_reaction() const; private: - bool _internal_has_rotatingprivkey() const; + bool _internal_has_reaction() const; public: - void clear_rotatingprivkey(); - const std::string& rotatingprivkey() const; - template - void set_rotatingprivkey(ArgT0&& arg0, ArgT... args); - std::string* mutable_rotatingprivkey(); - PROTOBUF_NODISCARD std::string* release_rotatingprivkey(); - void set_allocated_rotatingprivkey(std::string* rotatingprivkey); + void clear_reaction(); + const ::SessionProtos::DataMessage_Reaction& reaction() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Reaction* release_reaction(); + ::SessionProtos::DataMessage_Reaction* mutable_reaction(); + void set_allocated_reaction(::SessionProtos::DataMessage_Reaction* reaction); private: - const std::string& _internal_rotatingprivkey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingprivkey(const std::string& value); - std::string* _internal_mutable_rotatingprivkey(); + const ::SessionProtos::DataMessage_Reaction& _internal_reaction() const; + ::SessionProtos::DataMessage_Reaction* _internal_mutable_reaction(); public: + void unsafe_arena_set_allocated_reaction( + ::SessionProtos::DataMessage_Reaction* reaction); + ::SessionProtos::DataMessage_Reaction* unsafe_arena_release_reaction(); - // required bytes proof = 2; - bool has_proof() const; + // optional .SessionProtos.LokiProfile profile = 101; + bool has_profile() const; private: - bool _internal_has_proof() const; + bool _internal_has_profile() const; public: - void clear_proof(); - const std::string& proof() const; - template - void set_proof(ArgT0&& arg0, ArgT... args); - std::string* mutable_proof(); - PROTOBUF_NODISCARD std::string* release_proof(); - void set_allocated_proof(std::string* proof); + void clear_profile(); + const ::SessionProtos::LokiProfile& profile() const; + PROTOBUF_NODISCARD ::SessionProtos::LokiProfile* release_profile(); + ::SessionProtos::LokiProfile* mutable_profile(); + void set_allocated_profile(::SessionProtos::LokiProfile* profile); + private: + const ::SessionProtos::LokiProfile& _internal_profile() const; + ::SessionProtos::LokiProfile* _internal_mutable_profile(); + public: + void unsafe_arena_set_allocated_profile( + ::SessionProtos::LokiProfile* profile); + ::SessionProtos::LokiProfile* unsafe_arena_release_profile(); + + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; + bool has_opengroupinvitation() const; + private: + bool _internal_has_opengroupinvitation() const; + public: + void clear_opengroupinvitation(); + const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_OpenGroupInvitation* release_opengroupinvitation(); + ::SessionProtos::DataMessage_OpenGroupInvitation* mutable_opengroupinvitation(); + void set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); + private: + const ::SessionProtos::DataMessage_OpenGroupInvitation& _internal_opengroupinvitation() const; + ::SessionProtos::DataMessage_OpenGroupInvitation* _internal_mutable_opengroupinvitation(); + public: + void unsafe_arena_set_allocated_opengroupinvitation( + ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); + ::SessionProtos::DataMessage_OpenGroupInvitation* unsafe_arena_release_opengroupinvitation(); + + // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; + bool has_closedgroupcontrolmessage() const; + private: + bool _internal_has_closedgroupcontrolmessage() const; + public: + void clear_closedgroupcontrolmessage(); + const ::SessionProtos::DataMessage_ClosedGroupControlMessage& closedgroupcontrolmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_ClosedGroupControlMessage* release_closedgroupcontrolmessage(); + ::SessionProtos::DataMessage_ClosedGroupControlMessage* mutable_closedgroupcontrolmessage(); + void set_allocated_closedgroupcontrolmessage(::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage); + private: + const ::SessionProtos::DataMessage_ClosedGroupControlMessage& _internal_closedgroupcontrolmessage() const; + ::SessionProtos::DataMessage_ClosedGroupControlMessage* _internal_mutable_closedgroupcontrolmessage(); + public: + void unsafe_arena_set_allocated_closedgroupcontrolmessage( + ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage); + ::SessionProtos::DataMessage_ClosedGroupControlMessage* unsafe_arena_release_closedgroupcontrolmessage(); + + // optional uint32 flags = 4; + bool has_flags() const; + private: + bool _internal_has_flags() const; + public: + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); + private: + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); + public: + + // optional uint32 expireTimer = 5; + bool has_expiretimer() const; + private: + bool _internal_has_expiretimer() const; + public: + void clear_expiretimer(); + uint32_t expiretimer() const; + void set_expiretimer(uint32_t value); + private: + uint32_t _internal_expiretimer() const; + void _internal_set_expiretimer(uint32_t value); + public: + + // optional uint64 timestamp = 7; + bool has_timestamp() const; + private: + bool _internal_has_timestamp() const; + public: + void clear_timestamp(); + uint64_t timestamp() const; + void set_timestamp(uint64_t value); + private: + uint64_t _internal_timestamp() const; + void _internal_set_timestamp(uint64_t value); + public: + + // optional bool blocksCommunityMessageRequests = 106; + bool has_blockscommunitymessagerequests() const; + private: + bool _internal_has_blockscommunitymessagerequests() const; + public: + void clear_blockscommunitymessagerequests(); + bool blockscommunitymessagerequests() const; + void set_blockscommunitymessagerequests(bool value); private: - const std::string& _internal_proof() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_proof(const std::string& value); - std::string* _internal_mutable_proof(); + bool _internal_blockscommunitymessagerequests() const; + void _internal_set_blockscommunitymessagerequests(bool value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.Pro) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingprivkey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr proof_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer > attachments_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview > preview_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr body_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr synctarget_; + ::SessionProtos::DataMessage_Quote* quote_; + ::SessionProtos::DataMessage_Reaction* reaction_; + ::SessionProtos::LokiProfile* profile_; + ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation_; + ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage_; + uint32_t flags_; + uint32_t expiretimer_; + uint64_t timestamp_; + bool blockscommunitymessagerequests_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ConfigurationMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage) */ { +class ConfigurationMessage_ClosedGroup final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.ClosedGroup) */ { public: - inline ConfigurationMessage() : ConfigurationMessage(nullptr) {} - ~ConfigurationMessage() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ConfigurationMessage_ClosedGroup() : ConfigurationMessage_ClosedGroup(nullptr) {} + ~ConfigurationMessage_ClosedGroup() override; + explicit PROTOBUF_CONSTEXPR ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage(const ConfigurationMessage& from); - ConfigurationMessage(ConfigurationMessage&& from) noexcept - : ConfigurationMessage() { + ConfigurationMessage_ClosedGroup(const ConfigurationMessage_ClosedGroup& from); + ConfigurationMessage_ClosedGroup(ConfigurationMessage_ClosedGroup&& from) noexcept + : ConfigurationMessage_ClosedGroup() { *this = ::std::move(from); } - inline ConfigurationMessage& operator=(const ConfigurationMessage& from) { + inline ConfigurationMessage_ClosedGroup& operator=(const ConfigurationMessage_ClosedGroup& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage& operator=(ConfigurationMessage&& from) noexcept { + inline ConfigurationMessage_ClosedGroup& operator=(ConfigurationMessage_ClosedGroup&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5125,20 +4805,20 @@ class ConfigurationMessage final : return _internal_metadata_.mutable_unknown_fields(); } - static const ConfigurationMessage& default_instance() { + static const ConfigurationMessage_ClosedGroup& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_default_instance_); + static inline const ConfigurationMessage_ClosedGroup* internal_default_instance() { + return reinterpret_cast( + &_ConfigurationMessage_ClosedGroup_default_instance_); } static constexpr int kIndexInFileMessages = - 21; + 20; - friend void swap(ConfigurationMessage& a, ConfigurationMessage& b) { + friend void swap(ConfigurationMessage_ClosedGroup& a, ConfigurationMessage_ClosedGroup& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage* other) { + inline void Swap(ConfigurationMessage_ClosedGroup* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5151,7 +4831,7 @@ class ConfigurationMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage* other) { + void UnsafeArenaSwap(ConfigurationMessage_ClosedGroup* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5159,12 +4839,12 @@ class ConfigurationMessage final : // implements Message ---------------------------------------------- - ConfigurationMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ConfigurationMessage_ClosedGroup* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage& from); - void MergeFrom(const ConfigurationMessage& from); + void CopyFrom(const ConfigurationMessage_ClosedGroup& from); + void MergeFrom(const ConfigurationMessage_ClosedGroup& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5178,15 +4858,15 @@ class ConfigurationMessage final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage* other); + void InternalSwap(ConfigurationMessage_ClosedGroup* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage"; + return "SessionProtos.ConfigurationMessage.ClosedGroup"; } protected: - explicit ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -5194,155 +4874,132 @@ class ConfigurationMessage final : // nested types ---------------------------------------------------- - typedef ConfigurationMessage_ClosedGroup ClosedGroup; - typedef ConfigurationMessage_Contact Contact; - typedef ConfigurationMessage_ProProof ProProof; - typedef ConfigurationMessage_Pro Pro; - // accessors ------------------------------------------------------- enum : int { - kClosedGroupsFieldNumber = 1, - kOpenGroupsFieldNumber = 2, - kContactsFieldNumber = 6, - kDisplayNameFieldNumber = 3, - kProfilePictureFieldNumber = 4, - kProfileKeyFieldNumber = 5, - kProFieldNumber = 7, + kMembersFieldNumber = 4, + kAdminsFieldNumber = 5, + kPublicKeyFieldNumber = 1, + kNameFieldNumber = 2, + kEncryptionKeyPairFieldNumber = 3, + kExpirationTimerFieldNumber = 6, }; - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; - int closedgroups_size() const; + // repeated bytes members = 4; + int members_size() const; private: - int _internal_closedgroups_size() const; + int _internal_members_size() const; public: - void clear_closedgroups(); - ::SessionProtos::ConfigurationMessage_ClosedGroup* mutable_closedgroups(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >* - mutable_closedgroups(); + void clear_members(); + const std::string& members(int index) const; + std::string* mutable_members(int index); + void set_members(int index, const std::string& value); + void set_members(int index, std::string&& value); + void set_members(int index, const char* value); + void set_members(int index, const void* value, size_t size); + std::string* add_members(); + void add_members(const std::string& value); + void add_members(std::string&& value); + void add_members(const char* value); + void add_members(const void* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& members() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_members(); private: - const ::SessionProtos::ConfigurationMessage_ClosedGroup& _internal_closedgroups(int index) const; - ::SessionProtos::ConfigurationMessage_ClosedGroup* _internal_add_closedgroups(); + const std::string& _internal_members(int index) const; + std::string* _internal_add_members(); public: - const ::SessionProtos::ConfigurationMessage_ClosedGroup& closedgroups(int index) const; - ::SessionProtos::ConfigurationMessage_ClosedGroup* add_closedgroups(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >& - closedgroups() const; - // repeated string openGroups = 2; - int opengroups_size() const; + // repeated bytes admins = 5; + int admins_size() const; private: - int _internal_opengroups_size() const; + int _internal_admins_size() const; public: - void clear_opengroups(); - const std::string& opengroups(int index) const; - std::string* mutable_opengroups(int index); - void set_opengroups(int index, const std::string& value); - void set_opengroups(int index, std::string&& value); - void set_opengroups(int index, const char* value); - void set_opengroups(int index, const char* value, size_t size); - std::string* add_opengroups(); - void add_opengroups(const std::string& value); - void add_opengroups(std::string&& value); - void add_opengroups(const char* value); - void add_opengroups(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& opengroups() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_opengroups(); - private: - const std::string& _internal_opengroups(int index) const; - std::string* _internal_add_opengroups(); - public: - - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - int contacts_size() const; - private: - int _internal_contacts_size() const; - public: - void clear_contacts(); - ::SessionProtos::ConfigurationMessage_Contact* mutable_contacts(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >* - mutable_contacts(); + void clear_admins(); + const std::string& admins(int index) const; + std::string* mutable_admins(int index); + void set_admins(int index, const std::string& value); + void set_admins(int index, std::string&& value); + void set_admins(int index, const char* value); + void set_admins(int index, const void* value, size_t size); + std::string* add_admins(); + void add_admins(const std::string& value); + void add_admins(std::string&& value); + void add_admins(const char* value); + void add_admins(const void* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& admins() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_admins(); private: - const ::SessionProtos::ConfigurationMessage_Contact& _internal_contacts(int index) const; - ::SessionProtos::ConfigurationMessage_Contact* _internal_add_contacts(); + const std::string& _internal_admins(int index) const; + std::string* _internal_add_admins(); public: - const ::SessionProtos::ConfigurationMessage_Contact& contacts(int index) const; - ::SessionProtos::ConfigurationMessage_Contact* add_contacts(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >& - contacts() const; - // optional string displayName = 3; - bool has_displayname() const; + // optional bytes publicKey = 1; + bool has_publickey() const; private: - bool _internal_has_displayname() const; + bool _internal_has_publickey() const; public: - void clear_displayname(); - const std::string& displayname() const; + void clear_publickey(); + const std::string& publickey() const; template - void set_displayname(ArgT0&& arg0, ArgT... args); - std::string* mutable_displayname(); - PROTOBUF_NODISCARD std::string* release_displayname(); - void set_allocated_displayname(std::string* displayname); + void set_publickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_publickey(); + PROTOBUF_NODISCARD std::string* release_publickey(); + void set_allocated_publickey(std::string* publickey); private: - const std::string& _internal_displayname() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); - std::string* _internal_mutable_displayname(); + const std::string& _internal_publickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); + std::string* _internal_mutable_publickey(); public: - // optional string profilePicture = 4; - bool has_profilepicture() const; + // optional string name = 2; + bool has_name() const; private: - bool _internal_has_profilepicture() const; + bool _internal_has_name() const; public: - void clear_profilepicture(); - const std::string& profilepicture() const; + void clear_name(); + const std::string& name() const; template - void set_profilepicture(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilepicture(); - PROTOBUF_NODISCARD std::string* release_profilepicture(); - void set_allocated_profilepicture(std::string* profilepicture); + void set_name(ArgT0&& arg0, ArgT... args); + std::string* mutable_name(); + PROTOBUF_NODISCARD std::string* release_name(); + void set_allocated_name(std::string* name); private: - const std::string& _internal_profilepicture() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); - std::string* _internal_mutable_profilepicture(); + const std::string& _internal_name() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); public: - // optional bytes profileKey = 5; - bool has_profilekey() const; + // optional .SessionProtos.KeyPair encryptionKeyPair = 3; + bool has_encryptionkeypair() const; private: - bool _internal_has_profilekey() const; + bool _internal_has_encryptionkeypair() const; public: - void clear_profilekey(); - const std::string& profilekey() const; - template - void set_profilekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilekey(); - PROTOBUF_NODISCARD std::string* release_profilekey(); - void set_allocated_profilekey(std::string* profilekey); + void clear_encryptionkeypair(); + const ::SessionProtos::KeyPair& encryptionkeypair() const; + PROTOBUF_NODISCARD ::SessionProtos::KeyPair* release_encryptionkeypair(); + ::SessionProtos::KeyPair* mutable_encryptionkeypair(); + void set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair); private: - const std::string& _internal_profilekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); - std::string* _internal_mutable_profilekey(); + const ::SessionProtos::KeyPair& _internal_encryptionkeypair() const; + ::SessionProtos::KeyPair* _internal_mutable_encryptionkeypair(); public: + void unsafe_arena_set_allocated_encryptionkeypair( + ::SessionProtos::KeyPair* encryptionkeypair); + ::SessionProtos::KeyPair* unsafe_arena_release_encryptionkeypair(); - // optional .SessionProtos.ConfigurationMessage.Pro pro = 7; - bool has_pro() const; + // optional uint32 expirationTimer = 6; + bool has_expirationtimer() const; private: - bool _internal_has_pro() const; + bool _internal_has_expirationtimer() const; public: - void clear_pro(); - const ::SessionProtos::ConfigurationMessage_Pro& pro() const; - PROTOBUF_NODISCARD ::SessionProtos::ConfigurationMessage_Pro* release_pro(); - ::SessionProtos::ConfigurationMessage_Pro* mutable_pro(); - void set_allocated_pro(::SessionProtos::ConfigurationMessage_Pro* pro); + void clear_expirationtimer(); + uint32_t expirationtimer() const; + void set_expirationtimer(uint32_t value); private: - const ::SessionProtos::ConfigurationMessage_Pro& _internal_pro() const; - ::SessionProtos::ConfigurationMessage_Pro* _internal_mutable_pro(); + uint32_t _internal_expirationtimer() const; + void _internal_set_expirationtimer(uint32_t value); public: - void unsafe_arena_set_allocated_pro( - ::SessionProtos::ConfigurationMessage_Pro* pro); - ::SessionProtos::ConfigurationMessage_Pro* unsafe_arena_release_pro(); - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.ClosedGroup) private: class _Internal; @@ -5352,37 +5009,36 @@ class ConfigurationMessage final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup > closedgroups_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField opengroups_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact > contacts_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; - ::SessionProtos::ConfigurationMessage_Pro* pro_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField members_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField admins_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::SessionProtos::KeyPair* encryptionkeypair_; + uint32_t expirationtimer_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ReceiptMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ReceiptMessage) */ { +class ConfigurationMessage_Contact final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.Contact) */ { public: - inline ReceiptMessage() : ReceiptMessage(nullptr) {} - ~ReceiptMessage() override; - explicit PROTOBUF_CONSTEXPR ReceiptMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ConfigurationMessage_Contact() : ConfigurationMessage_Contact(nullptr) {} + ~ConfigurationMessage_Contact() override; + explicit PROTOBUF_CONSTEXPR ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ReceiptMessage(const ReceiptMessage& from); - ReceiptMessage(ReceiptMessage&& from) noexcept - : ReceiptMessage() { + ConfigurationMessage_Contact(const ConfigurationMessage_Contact& from); + ConfigurationMessage_Contact(ConfigurationMessage_Contact&& from) noexcept + : ConfigurationMessage_Contact() { *this = ::std::move(from); } - inline ReceiptMessage& operator=(const ReceiptMessage& from) { + inline ConfigurationMessage_Contact& operator=(const ConfigurationMessage_Contact& from) { CopyFrom(from); return *this; } - inline ReceiptMessage& operator=(ReceiptMessage&& from) noexcept { + inline ConfigurationMessage_Contact& operator=(ConfigurationMessage_Contact&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5403,20 +5059,20 @@ class ReceiptMessage final : return _internal_metadata_.mutable_unknown_fields(); } - static const ReceiptMessage& default_instance() { + static const ConfigurationMessage_Contact& default_instance() { return *internal_default_instance(); } - static inline const ReceiptMessage* internal_default_instance() { - return reinterpret_cast( - &_ReceiptMessage_default_instance_); + static inline const ConfigurationMessage_Contact* internal_default_instance() { + return reinterpret_cast( + &_ConfigurationMessage_Contact_default_instance_); } static constexpr int kIndexInFileMessages = - 22; + 21; - friend void swap(ReceiptMessage& a, ReceiptMessage& b) { + friend void swap(ConfigurationMessage_Contact& a, ConfigurationMessage_Contact& b) { a.Swap(&b); } - inline void Swap(ReceiptMessage* other) { + inline void Swap(ConfigurationMessage_Contact* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5429,7 +5085,7 @@ class ReceiptMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ReceiptMessage* other) { + void UnsafeArenaSwap(ConfigurationMessage_Contact* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5437,12 +5093,12 @@ class ReceiptMessage final : // implements Message ---------------------------------------------- - ReceiptMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ConfigurationMessage_Contact* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ReceiptMessage& from); - void MergeFrom(const ReceiptMessage& from); + void CopyFrom(const ConfigurationMessage_Contact& from); + void MergeFrom(const ConfigurationMessage_Contact& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5456,15 +5112,15 @@ class ReceiptMessage final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(ReceiptMessage* other); + void InternalSwap(ConfigurationMessage_Contact* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ReceiptMessage"; + return "SessionProtos.ConfigurationMessage.Contact"; } protected: - explicit ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -5472,109 +5128,172 @@ class ReceiptMessage final : // nested types ---------------------------------------------------- - typedef ReceiptMessage_Type Type; - static constexpr Type DELIVERY = - ReceiptMessage_Type_DELIVERY; - static constexpr Type READ = - ReceiptMessage_Type_READ; - static inline bool Type_IsValid(int value) { - return ReceiptMessage_Type_IsValid(value); - } - static constexpr Type Type_MIN = - ReceiptMessage_Type_Type_MIN; - static constexpr Type Type_MAX = - ReceiptMessage_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - ReceiptMessage_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return ReceiptMessage_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return ReceiptMessage_Type_Parse(name, value); - } - // accessors ------------------------------------------------------- enum : int { - kTimestampFieldNumber = 2, - kTypeFieldNumber = 1, + kPublicKeyFieldNumber = 1, + kNameFieldNumber = 2, + kProfilePictureFieldNumber = 3, + kProfileKeyFieldNumber = 4, + kIsApprovedFieldNumber = 5, + kIsBlockedFieldNumber = 6, + kDidApproveMeFieldNumber = 7, }; - // repeated uint64 timestamp = 2; - int timestamp_size() const; + // required bytes publicKey = 1; + bool has_publickey() const; private: - int _internal_timestamp_size() const; + bool _internal_has_publickey() const; public: - void clear_timestamp(); + void clear_publickey(); + const std::string& publickey() const; + template + void set_publickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_publickey(); + PROTOBUF_NODISCARD std::string* release_publickey(); + void set_allocated_publickey(std::string* publickey); private: - uint64_t _internal_timestamp(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& - _internal_timestamp() const; - void _internal_add_timestamp(uint64_t value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* - _internal_mutable_timestamp(); + const std::string& _internal_publickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); + std::string* _internal_mutable_publickey(); public: - uint64_t timestamp(int index) const; - void set_timestamp(int index, uint64_t value); - void add_timestamp(uint64_t value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& - timestamp() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* - mutable_timestamp(); - // required .SessionProtos.ReceiptMessage.Type type = 1; - bool has_type() const; + // required string name = 2; + bool has_name() const; private: - bool _internal_has_type() const; + bool _internal_has_name() const; public: - void clear_type(); - ::SessionProtos::ReceiptMessage_Type type() const; - void set_type(::SessionProtos::ReceiptMessage_Type value); + void clear_name(); + const std::string& name() const; + template + void set_name(ArgT0&& arg0, ArgT... args); + std::string* mutable_name(); + PROTOBUF_NODISCARD std::string* release_name(); + void set_allocated_name(std::string* name); private: - ::SessionProtos::ReceiptMessage_Type _internal_type() const; - void _internal_set_type(::SessionProtos::ReceiptMessage_Type value); + const std::string& _internal_name() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ReceiptMessage) + // optional string profilePicture = 3; + bool has_profilepicture() const; + private: + bool _internal_has_profilepicture() const; + public: + void clear_profilepicture(); + const std::string& profilepicture() const; + template + void set_profilepicture(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilepicture(); + PROTOBUF_NODISCARD std::string* release_profilepicture(); + void set_allocated_profilepicture(std::string* profilepicture); + private: + const std::string& _internal_profilepicture() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); + std::string* _internal_mutable_profilepicture(); + public: + + // optional bytes profileKey = 4; + bool has_profilekey() const; + private: + bool _internal_has_profilekey() const; + public: + void clear_profilekey(); + const std::string& profilekey() const; + template + void set_profilekey(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilekey(); + PROTOBUF_NODISCARD std::string* release_profilekey(); + void set_allocated_profilekey(std::string* profilekey); + private: + const std::string& _internal_profilekey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); + std::string* _internal_mutable_profilekey(); + public: + + // optional bool isApproved = 5; + bool has_isapproved() const; + private: + bool _internal_has_isapproved() const; + public: + void clear_isapproved(); + bool isapproved() const; + void set_isapproved(bool value); + private: + bool _internal_isapproved() const; + void _internal_set_isapproved(bool value); + public: + + // optional bool isBlocked = 6; + bool has_isblocked() const; + private: + bool _internal_has_isblocked() const; + public: + void clear_isblocked(); + bool isblocked() const; + void set_isblocked(bool value); + private: + bool _internal_isblocked() const; + void _internal_set_isblocked(bool value); + public: + + // optional bool didApproveMe = 7; + bool has_didapproveme() const; + private: + bool _internal_has_didapproveme() const; + public: + void clear_didapproveme(); + bool didapproveme() const; + void set_didapproveme(bool value); + private: + bool _internal_didapproveme() const; + void _internal_set_didapproveme(bool value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.Contact) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t > timestamp_; - int type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; + bool isapproved_; + bool isblocked_; + bool didapproveme_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class AttachmentPointer final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.AttachmentPointer) */ { +class ConfigurationMessage final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage) */ { public: - inline AttachmentPointer() : AttachmentPointer(nullptr) {} - ~AttachmentPointer() override; - explicit PROTOBUF_CONSTEXPR AttachmentPointer(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ConfigurationMessage() : ConfigurationMessage(nullptr) {} + ~ConfigurationMessage() override; + explicit PROTOBUF_CONSTEXPR ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - AttachmentPointer(const AttachmentPointer& from); - AttachmentPointer(AttachmentPointer&& from) noexcept - : AttachmentPointer() { + ConfigurationMessage(const ConfigurationMessage& from); + ConfigurationMessage(ConfigurationMessage&& from) noexcept + : ConfigurationMessage() { *this = ::std::move(from); } - inline AttachmentPointer& operator=(const AttachmentPointer& from) { + inline ConfigurationMessage& operator=(const ConfigurationMessage& from) { CopyFrom(from); return *this; } - inline AttachmentPointer& operator=(AttachmentPointer&& from) noexcept { + inline ConfigurationMessage& operator=(ConfigurationMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5595,20 +5314,20 @@ class AttachmentPointer final : return _internal_metadata_.mutable_unknown_fields(); } - static const AttachmentPointer& default_instance() { + static const ConfigurationMessage& default_instance() { return *internal_default_instance(); } - static inline const AttachmentPointer* internal_default_instance() { - return reinterpret_cast( - &_AttachmentPointer_default_instance_); + static inline const ConfigurationMessage* internal_default_instance() { + return reinterpret_cast( + &_ConfigurationMessage_default_instance_); } static constexpr int kIndexInFileMessages = - 23; + 22; - friend void swap(AttachmentPointer& a, AttachmentPointer& b) { + friend void swap(ConfigurationMessage& a, ConfigurationMessage& b) { a.Swap(&b); } - inline void Swap(AttachmentPointer* other) { + inline void Swap(ConfigurationMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5621,7 +5340,7 @@ class AttachmentPointer final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(AttachmentPointer* other) { + void UnsafeArenaSwap(ConfigurationMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5629,12 +5348,12 @@ class AttachmentPointer final : // implements Message ---------------------------------------------- - AttachmentPointer* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ConfigurationMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const AttachmentPointer& from); - void MergeFrom(const AttachmentPointer& from); + void CopyFrom(const ConfigurationMessage& from); + void MergeFrom(const ConfigurationMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5648,15 +5367,15 @@ class AttachmentPointer final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(AttachmentPointer* other); + void InternalSwap(ConfigurationMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.AttachmentPointer"; + return "SessionProtos.ConfigurationMessage"; } protected: - explicit AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -5664,238 +5383,153 @@ class AttachmentPointer final : // nested types ---------------------------------------------------- - typedef AttachmentPointer_Flags Flags; - static constexpr Flags VOICE_MESSAGE = - AttachmentPointer_Flags_VOICE_MESSAGE; - static inline bool Flags_IsValid(int value) { - return AttachmentPointer_Flags_IsValid(value); - } - static constexpr Flags Flags_MIN = - AttachmentPointer_Flags_Flags_MIN; - static constexpr Flags Flags_MAX = - AttachmentPointer_Flags_Flags_MAX; - static constexpr int Flags_ARRAYSIZE = - AttachmentPointer_Flags_Flags_ARRAYSIZE; - template - static inline const std::string& Flags_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Flags_Name."); - return AttachmentPointer_Flags_Name(enum_t_value); - } - static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Flags* value) { - return AttachmentPointer_Flags_Parse(name, value); - } + typedef ConfigurationMessage_ClosedGroup ClosedGroup; + typedef ConfigurationMessage_Contact Contact; // accessors ------------------------------------------------------- enum : int { - kContentTypeFieldNumber = 2, - kKeyFieldNumber = 3, - kThumbnailFieldNumber = 5, - kDigestFieldNumber = 6, - kFileNameFieldNumber = 7, - kCaptionFieldNumber = 11, - kUrlFieldNumber = 101, - kIdFieldNumber = 1, - kSizeFieldNumber = 4, - kFlagsFieldNumber = 8, - kWidthFieldNumber = 9, - kHeightFieldNumber = 10, + kClosedGroupsFieldNumber = 1, + kOpenGroupsFieldNumber = 2, + kContactsFieldNumber = 6, + kDisplayNameFieldNumber = 3, + kProfilePictureFieldNumber = 4, + kProfileKeyFieldNumber = 5, + kProConfigFieldNumber = 7, }; - // optional string contentType = 2; - bool has_contenttype() const; + // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; + int closedgroups_size() const; private: - bool _internal_has_contenttype() const; + int _internal_closedgroups_size() const; public: - void clear_contenttype(); - const std::string& contenttype() const; - template - void set_contenttype(ArgT0&& arg0, ArgT... args); - std::string* mutable_contenttype(); - PROTOBUF_NODISCARD std::string* release_contenttype(); - void set_allocated_contenttype(std::string* contenttype); + void clear_closedgroups(); + ::SessionProtos::ConfigurationMessage_ClosedGroup* mutable_closedgroups(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >* + mutable_closedgroups(); private: - const std::string& _internal_contenttype() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); - std::string* _internal_mutable_contenttype(); + const ::SessionProtos::ConfigurationMessage_ClosedGroup& _internal_closedgroups(int index) const; + ::SessionProtos::ConfigurationMessage_ClosedGroup* _internal_add_closedgroups(); public: + const ::SessionProtos::ConfigurationMessage_ClosedGroup& closedgroups(int index) const; + ::SessionProtos::ConfigurationMessage_ClosedGroup* add_closedgroups(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >& + closedgroups() const; - // optional bytes key = 3; - bool has_key() const; + // repeated string openGroups = 2; + int opengroups_size() const; private: - bool _internal_has_key() const; + int _internal_opengroups_size() const; public: - void clear_key(); - const std::string& key() const; - template - void set_key(ArgT0&& arg0, ArgT... args); - std::string* mutable_key(); - PROTOBUF_NODISCARD std::string* release_key(); - void set_allocated_key(std::string* key); + void clear_opengroups(); + const std::string& opengroups(int index) const; + std::string* mutable_opengroups(int index); + void set_opengroups(int index, const std::string& value); + void set_opengroups(int index, std::string&& value); + void set_opengroups(int index, const char* value); + void set_opengroups(int index, const char* value, size_t size); + std::string* add_opengroups(); + void add_opengroups(const std::string& value); + void add_opengroups(std::string&& value); + void add_opengroups(const char* value); + void add_opengroups(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& opengroups() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_opengroups(); private: - const std::string& _internal_key() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_key(const std::string& value); - std::string* _internal_mutable_key(); + const std::string& _internal_opengroups(int index) const; + std::string* _internal_add_opengroups(); public: - // optional bytes thumbnail = 5; - bool has_thumbnail() const; - private: - bool _internal_has_thumbnail() const; - public: - void clear_thumbnail(); - const std::string& thumbnail() const; - template - void set_thumbnail(ArgT0&& arg0, ArgT... args); - std::string* mutable_thumbnail(); - PROTOBUF_NODISCARD std::string* release_thumbnail(); - void set_allocated_thumbnail(std::string* thumbnail); - private: - const std::string& _internal_thumbnail() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_thumbnail(const std::string& value); - std::string* _internal_mutable_thumbnail(); - public: - - // optional bytes digest = 6; - bool has_digest() const; + // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; + int contacts_size() const; private: - bool _internal_has_digest() const; + int _internal_contacts_size() const; public: - void clear_digest(); - const std::string& digest() const; - template - void set_digest(ArgT0&& arg0, ArgT... args); - std::string* mutable_digest(); - PROTOBUF_NODISCARD std::string* release_digest(); - void set_allocated_digest(std::string* digest); + void clear_contacts(); + ::SessionProtos::ConfigurationMessage_Contact* mutable_contacts(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >* + mutable_contacts(); private: - const std::string& _internal_digest() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_digest(const std::string& value); - std::string* _internal_mutable_digest(); + const ::SessionProtos::ConfigurationMessage_Contact& _internal_contacts(int index) const; + ::SessionProtos::ConfigurationMessage_Contact* _internal_add_contacts(); public: + const ::SessionProtos::ConfigurationMessage_Contact& contacts(int index) const; + ::SessionProtos::ConfigurationMessage_Contact* add_contacts(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >& + contacts() const; - // optional string fileName = 7; - bool has_filename() const; + // optional string displayName = 3; + bool has_displayname() const; private: - bool _internal_has_filename() const; + bool _internal_has_displayname() const; public: - void clear_filename(); - const std::string& filename() const; + void clear_displayname(); + const std::string& displayname() const; template - void set_filename(ArgT0&& arg0, ArgT... args); - std::string* mutable_filename(); - PROTOBUF_NODISCARD std::string* release_filename(); - void set_allocated_filename(std::string* filename); + void set_displayname(ArgT0&& arg0, ArgT... args); + std::string* mutable_displayname(); + PROTOBUF_NODISCARD std::string* release_displayname(); + void set_allocated_displayname(std::string* displayname); private: - const std::string& _internal_filename() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); - std::string* _internal_mutable_filename(); + const std::string& _internal_displayname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); + std::string* _internal_mutable_displayname(); public: - // optional string caption = 11; - bool has_caption() const; + // optional string profilePicture = 4; + bool has_profilepicture() const; private: - bool _internal_has_caption() const; + bool _internal_has_profilepicture() const; public: - void clear_caption(); - const std::string& caption() const; + void clear_profilepicture(); + const std::string& profilepicture() const; template - void set_caption(ArgT0&& arg0, ArgT... args); - std::string* mutable_caption(); - PROTOBUF_NODISCARD std::string* release_caption(); - void set_allocated_caption(std::string* caption); + void set_profilepicture(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilepicture(); + PROTOBUF_NODISCARD std::string* release_profilepicture(); + void set_allocated_profilepicture(std::string* profilepicture); private: - const std::string& _internal_caption() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_caption(const std::string& value); - std::string* _internal_mutable_caption(); + const std::string& _internal_profilepicture() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); + std::string* _internal_mutable_profilepicture(); public: - // optional string url = 101; - bool has_url() const; + // optional bytes profileKey = 5; + bool has_profilekey() const; private: - bool _internal_has_url() const; + bool _internal_has_profilekey() const; public: - void clear_url(); - const std::string& url() const; + void clear_profilekey(); + const std::string& profilekey() const; template - void set_url(ArgT0&& arg0, ArgT... args); - std::string* mutable_url(); - PROTOBUF_NODISCARD std::string* release_url(); - void set_allocated_url(std::string* url); - private: - const std::string& _internal_url() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); - std::string* _internal_mutable_url(); - public: - - // required fixed64 id = 1; - bool has_id() const; - private: - bool _internal_has_id() const; - public: - void clear_id(); - uint64_t id() const; - void set_id(uint64_t value); - private: - uint64_t _internal_id() const; - void _internal_set_id(uint64_t value); - public: - - // optional uint32 size = 4; - bool has_size() const; - private: - bool _internal_has_size() const; - public: - void clear_size(); - uint32_t size() const; - void set_size(uint32_t value); - private: - uint32_t _internal_size() const; - void _internal_set_size(uint32_t value); - public: - - // optional uint32 flags = 8; - bool has_flags() const; - private: - bool _internal_has_flags() const; - public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); - private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); - public: - - // optional uint32 width = 9; - bool has_width() const; - private: - bool _internal_has_width() const; - public: - void clear_width(); - uint32_t width() const; - void set_width(uint32_t value); + void set_profilekey(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilekey(); + PROTOBUF_NODISCARD std::string* release_profilekey(); + void set_allocated_profilekey(std::string* profilekey); private: - uint32_t _internal_width() const; - void _internal_set_width(uint32_t value); + const std::string& _internal_profilekey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); + std::string* _internal_mutable_profilekey(); public: - // optional uint32 height = 10; - bool has_height() const; + // optional .SessionProtos.ProConfig proConfig = 7; + bool has_proconfig() const; private: - bool _internal_has_height() const; + bool _internal_has_proconfig() const; public: - void clear_height(); - uint32_t height() const; - void set_height(uint32_t value); + void clear_proconfig(); + const ::SessionProtos::ProConfig& proconfig() const; + PROTOBUF_NODISCARD ::SessionProtos::ProConfig* release_proconfig(); + ::SessionProtos::ProConfig* mutable_proconfig(); + void set_allocated_proconfig(::SessionProtos::ProConfig* proconfig); private: - uint32_t _internal_height() const; - void _internal_set_height(uint32_t value); + const ::SessionProtos::ProConfig& _internal_proconfig() const; + ::SessionProtos::ProConfig* _internal_mutable_proconfig(); public: + void unsafe_arena_set_allocated_proconfig( + ::SessionProtos::ProConfig* proconfig); + ::SessionProtos::ProConfig* unsafe_arena_release_proconfig(); - // @@protoc_insertion_point(class_scope:SessionProtos.AttachmentPointer) + // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage) private: class _Internal; @@ -5905,42 +5539,37 @@ class AttachmentPointer final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr key_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr thumbnail_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr digest_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr caption_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; - uint64_t id_; - uint32_t size_; - uint32_t flags_; - uint32_t width_; - uint32_t height_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup > closedgroups_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField opengroups_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact > contacts_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; + ::SessionProtos::ProConfig* proconfig_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class SharedConfigMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.SharedConfigMessage) */ { +class ReceiptMessage final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ReceiptMessage) */ { public: - inline SharedConfigMessage() : SharedConfigMessage(nullptr) {} - ~SharedConfigMessage() override; - explicit PROTOBUF_CONSTEXPR SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline ReceiptMessage() : ReceiptMessage(nullptr) {} + ~ReceiptMessage() override; + explicit PROTOBUF_CONSTEXPR ReceiptMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - SharedConfigMessage(const SharedConfigMessage& from); - SharedConfigMessage(SharedConfigMessage&& from) noexcept - : SharedConfigMessage() { + ReceiptMessage(const ReceiptMessage& from); + ReceiptMessage(ReceiptMessage&& from) noexcept + : ReceiptMessage() { *this = ::std::move(from); } - inline SharedConfigMessage& operator=(const SharedConfigMessage& from) { + inline ReceiptMessage& operator=(const ReceiptMessage& from) { CopyFrom(from); return *this; } - inline SharedConfigMessage& operator=(SharedConfigMessage&& from) noexcept { + inline ReceiptMessage& operator=(ReceiptMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5961,20 +5590,20 @@ class SharedConfigMessage final : return _internal_metadata_.mutable_unknown_fields(); } - static const SharedConfigMessage& default_instance() { + static const ReceiptMessage& default_instance() { return *internal_default_instance(); } - static inline const SharedConfigMessage* internal_default_instance() { - return reinterpret_cast( - &_SharedConfigMessage_default_instance_); + static inline const ReceiptMessage* internal_default_instance() { + return reinterpret_cast( + &_ReceiptMessage_default_instance_); } static constexpr int kIndexInFileMessages = - 24; + 23; - friend void swap(SharedConfigMessage& a, SharedConfigMessage& b) { + friend void swap(ReceiptMessage& a, ReceiptMessage& b) { a.Swap(&b); } - inline void Swap(SharedConfigMessage* other) { + inline void Swap(ReceiptMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5987,7 +5616,7 @@ class SharedConfigMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(SharedConfigMessage* other) { + void UnsafeArenaSwap(ReceiptMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5995,12 +5624,12 @@ class SharedConfigMessage final : // implements Message ---------------------------------------------- - SharedConfigMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ReceiptMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const SharedConfigMessage& from); - void MergeFrom(const SharedConfigMessage& from); + void CopyFrom(const ReceiptMessage& from); + void MergeFrom(const ReceiptMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6014,15 +5643,15 @@ class SharedConfigMessage final : void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(SharedConfigMessage* other); + void InternalSwap(ReceiptMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.SharedConfigMessage"; + return "SessionProtos.ReceiptMessage"; } protected: - explicit SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: @@ -6030,667 +5659,1651 @@ class SharedConfigMessage final : // nested types ---------------------------------------------------- - typedef SharedConfigMessage_Kind Kind; - static constexpr Kind USER_PROFILE = - SharedConfigMessage_Kind_USER_PROFILE; - static constexpr Kind CONTACTS = - SharedConfigMessage_Kind_CONTACTS; - static constexpr Kind CONVO_INFO_VOLATILE = - SharedConfigMessage_Kind_CONVO_INFO_VOLATILE; - static constexpr Kind USER_GROUPS = - SharedConfigMessage_Kind_USER_GROUPS; - static inline bool Kind_IsValid(int value) { - return SharedConfigMessage_Kind_IsValid(value); - } - static constexpr Kind Kind_MIN = - SharedConfigMessage_Kind_Kind_MIN; - static constexpr Kind Kind_MAX = - SharedConfigMessage_Kind_Kind_MAX; - static constexpr int Kind_ARRAYSIZE = - SharedConfigMessage_Kind_Kind_ARRAYSIZE; + typedef ReceiptMessage_Type Type; + static constexpr Type DELIVERY = + ReceiptMessage_Type_DELIVERY; + static constexpr Type READ = + ReceiptMessage_Type_READ; + static inline bool Type_IsValid(int value) { + return ReceiptMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + ReceiptMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + ReceiptMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + ReceiptMessage_Type_Type_ARRAYSIZE; template - static inline const std::string& Kind_Name(T enum_t_value) { - static_assert(::std::is_same::value || + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || ::std::is_integral::value, - "Incorrect type passed to function Kind_Name."); - return SharedConfigMessage_Kind_Name(enum_t_value); + "Incorrect type passed to function Type_Name."); + return ReceiptMessage_Type_Name(enum_t_value); } - static inline bool Kind_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Kind* value) { - return SharedConfigMessage_Kind_Parse(name, value); + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return ReceiptMessage_Type_Parse(name, value); } // accessors ------------------------------------------------------- enum : int { - kDataFieldNumber = 3, - kSeqnoFieldNumber = 2, - kKindFieldNumber = 1, + kTimestampFieldNumber = 2, + kTypeFieldNumber = 1, }; - // required bytes data = 3; - bool has_data() const; - private: - bool _internal_has_data() const; - public: - void clear_data(); - const std::string& data() const; - template - void set_data(ArgT0&& arg0, ArgT... args); - std::string* mutable_data(); - PROTOBUF_NODISCARD std::string* release_data(); - void set_allocated_data(std::string* data); - private: - const std::string& _internal_data() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_data(const std::string& value); - std::string* _internal_mutable_data(); - public: - - // required int64 seqno = 2; - bool has_seqno() const; + // repeated uint64 timestamp = 2; + int timestamp_size() const; private: - bool _internal_has_seqno() const; + int _internal_timestamp_size() const; public: - void clear_seqno(); - int64_t seqno() const; - void set_seqno(int64_t value); + void clear_timestamp(); private: - int64_t _internal_seqno() const; - void _internal_set_seqno(int64_t value); + uint64_t _internal_timestamp(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& + _internal_timestamp() const; + void _internal_add_timestamp(uint64_t value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* + _internal_mutable_timestamp(); public: + uint64_t timestamp(int index) const; + void set_timestamp(int index, uint64_t value); + void add_timestamp(uint64_t value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& + timestamp() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* + mutable_timestamp(); - // required .SessionProtos.SharedConfigMessage.Kind kind = 1; - bool has_kind() const; + // required .SessionProtos.ReceiptMessage.Type type = 1; + bool has_type() const; private: - bool _internal_has_kind() const; + bool _internal_has_type() const; public: - void clear_kind(); - ::SessionProtos::SharedConfigMessage_Kind kind() const; - void set_kind(::SessionProtos::SharedConfigMessage_Kind value); + void clear_type(); + ::SessionProtos::ReceiptMessage_Type type() const; + void set_type(::SessionProtos::ReceiptMessage_Type value); private: - ::SessionProtos::SharedConfigMessage_Kind _internal_kind() const; - void _internal_set_kind(::SessionProtos::SharedConfigMessage_Kind value); + ::SessionProtos::ReceiptMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::ReceiptMessage_Type value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.SharedConfigMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.ReceiptMessage) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr data_; - int64_t seqno_; - int kind_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t > timestamp_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; -// =================================================================== +// ------------------------------------------------------------------- +class AttachmentPointer final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.AttachmentPointer) */ { + public: + inline AttachmentPointer() : AttachmentPointer(nullptr) {} + ~AttachmentPointer() override; + explicit PROTOBUF_CONSTEXPR AttachmentPointer(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); -// =================================================================== + AttachmentPointer(const AttachmentPointer& from); + AttachmentPointer(AttachmentPointer&& from) noexcept + : AttachmentPointer() { + *this = ::std::move(from); + } -#ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// Envelope + inline AttachmentPointer& operator=(const AttachmentPointer& from) { + CopyFrom(from); + return *this; + } + inline AttachmentPointer& operator=(AttachmentPointer&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } -// required .SessionProtos.Envelope.Type type = 1; -inline bool Envelope::_internal_has_type() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; - return value; -} -inline bool Envelope::has_type() const { - return _internal_has_type(); -} -inline void Envelope::clear_type() { - _impl_.type_ = 6; - _impl_._has_bits_[0] &= ~0x00000020u; -} -inline ::SessionProtos::Envelope_Type Envelope::_internal_type() const { - return static_cast< ::SessionProtos::Envelope_Type >(_impl_.type_); -} -inline ::SessionProtos::Envelope_Type Envelope::type() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.type) - return _internal_type(); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + } + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const AttachmentPointer& default_instance() { + return *internal_default_instance(); + } + static inline const AttachmentPointer* internal_default_instance() { + return reinterpret_cast( + &_AttachmentPointer_default_instance_); + } + static constexpr int kIndexInFileMessages = + 24; + + friend void swap(AttachmentPointer& a, AttachmentPointer& b) { + a.Swap(&b); + } + inline void Swap(AttachmentPointer* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(AttachmentPointer* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + AttachmentPointer* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const AttachmentPointer& from); + void MergeFrom(const AttachmentPointer& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(AttachmentPointer* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.AttachmentPointer"; + } + protected: + explicit AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + typedef AttachmentPointer_Flags Flags; + static constexpr Flags VOICE_MESSAGE = + AttachmentPointer_Flags_VOICE_MESSAGE; + static inline bool Flags_IsValid(int value) { + return AttachmentPointer_Flags_IsValid(value); + } + static constexpr Flags Flags_MIN = + AttachmentPointer_Flags_Flags_MIN; + static constexpr Flags Flags_MAX = + AttachmentPointer_Flags_Flags_MAX; + static constexpr int Flags_ARRAYSIZE = + AttachmentPointer_Flags_Flags_ARRAYSIZE; + template + static inline const std::string& Flags_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Flags_Name."); + return AttachmentPointer_Flags_Name(enum_t_value); + } + static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Flags* value) { + return AttachmentPointer_Flags_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + enum : int { + kContentTypeFieldNumber = 2, + kKeyFieldNumber = 3, + kThumbnailFieldNumber = 5, + kDigestFieldNumber = 6, + kFileNameFieldNumber = 7, + kCaptionFieldNumber = 11, + kUrlFieldNumber = 101, + kIdFieldNumber = 1, + kSizeFieldNumber = 4, + kFlagsFieldNumber = 8, + kWidthFieldNumber = 9, + kHeightFieldNumber = 10, + }; + // optional string contentType = 2; + bool has_contenttype() const; + private: + bool _internal_has_contenttype() const; + public: + void clear_contenttype(); + const std::string& contenttype() const; + template + void set_contenttype(ArgT0&& arg0, ArgT... args); + std::string* mutable_contenttype(); + PROTOBUF_NODISCARD std::string* release_contenttype(); + void set_allocated_contenttype(std::string* contenttype); + private: + const std::string& _internal_contenttype() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); + std::string* _internal_mutable_contenttype(); + public: + + // optional bytes key = 3; + bool has_key() const; + private: + bool _internal_has_key() const; + public: + void clear_key(); + const std::string& key() const; + template + void set_key(ArgT0&& arg0, ArgT... args); + std::string* mutable_key(); + PROTOBUF_NODISCARD std::string* release_key(); + void set_allocated_key(std::string* key); + private: + const std::string& _internal_key() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_key(const std::string& value); + std::string* _internal_mutable_key(); + public: + + // optional bytes thumbnail = 5; + bool has_thumbnail() const; + private: + bool _internal_has_thumbnail() const; + public: + void clear_thumbnail(); + const std::string& thumbnail() const; + template + void set_thumbnail(ArgT0&& arg0, ArgT... args); + std::string* mutable_thumbnail(); + PROTOBUF_NODISCARD std::string* release_thumbnail(); + void set_allocated_thumbnail(std::string* thumbnail); + private: + const std::string& _internal_thumbnail() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_thumbnail(const std::string& value); + std::string* _internal_mutable_thumbnail(); + public: + + // optional bytes digest = 6; + bool has_digest() const; + private: + bool _internal_has_digest() const; + public: + void clear_digest(); + const std::string& digest() const; + template + void set_digest(ArgT0&& arg0, ArgT... args); + std::string* mutable_digest(); + PROTOBUF_NODISCARD std::string* release_digest(); + void set_allocated_digest(std::string* digest); + private: + const std::string& _internal_digest() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_digest(const std::string& value); + std::string* _internal_mutable_digest(); + public: + + // optional string fileName = 7; + bool has_filename() const; + private: + bool _internal_has_filename() const; + public: + void clear_filename(); + const std::string& filename() const; + template + void set_filename(ArgT0&& arg0, ArgT... args); + std::string* mutable_filename(); + PROTOBUF_NODISCARD std::string* release_filename(); + void set_allocated_filename(std::string* filename); + private: + const std::string& _internal_filename() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); + std::string* _internal_mutable_filename(); + public: + + // optional string caption = 11; + bool has_caption() const; + private: + bool _internal_has_caption() const; + public: + void clear_caption(); + const std::string& caption() const; + template + void set_caption(ArgT0&& arg0, ArgT... args); + std::string* mutable_caption(); + PROTOBUF_NODISCARD std::string* release_caption(); + void set_allocated_caption(std::string* caption); + private: + const std::string& _internal_caption() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_caption(const std::string& value); + std::string* _internal_mutable_caption(); + public: + + // optional string url = 101; + bool has_url() const; + private: + bool _internal_has_url() const; + public: + void clear_url(); + const std::string& url() const; + template + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); + private: + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); + public: + + // required fixed64 id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + uint64_t id() const; + void set_id(uint64_t value); + private: + uint64_t _internal_id() const; + void _internal_set_id(uint64_t value); + public: + + // optional uint32 size = 4; + bool has_size() const; + private: + bool _internal_has_size() const; + public: + void clear_size(); + uint32_t size() const; + void set_size(uint32_t value); + private: + uint32_t _internal_size() const; + void _internal_set_size(uint32_t value); + public: + + // optional uint32 flags = 8; + bool has_flags() const; + private: + bool _internal_has_flags() const; + public: + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); + private: + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); + public: + + // optional uint32 width = 9; + bool has_width() const; + private: + bool _internal_has_width() const; + public: + void clear_width(); + uint32_t width() const; + void set_width(uint32_t value); + private: + uint32_t _internal_width() const; + void _internal_set_width(uint32_t value); + public: + + // optional uint32 height = 10; + bool has_height() const; + private: + bool _internal_has_height() const; + public: + void clear_height(); + uint32_t height() const; + void set_height(uint32_t value); + private: + uint32_t _internal_height() const; + void _internal_set_height(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.AttachmentPointer) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr key_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr thumbnail_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr digest_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr caption_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + uint64_t id_; + uint32_t size_; + uint32_t flags_; + uint32_t width_; + uint32_t height_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + +class SharedConfigMessage final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.SharedConfigMessage) */ { + public: + inline SharedConfigMessage() : SharedConfigMessage(nullptr) {} + ~SharedConfigMessage() override; + explicit PROTOBUF_CONSTEXPR SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + SharedConfigMessage(const SharedConfigMessage& from); + SharedConfigMessage(SharedConfigMessage&& from) noexcept + : SharedConfigMessage() { + *this = ::std::move(from); + } + + inline SharedConfigMessage& operator=(const SharedConfigMessage& from) { + CopyFrom(from); + return *this; + } + inline SharedConfigMessage& operator=(SharedConfigMessage&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + } + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const SharedConfigMessage& default_instance() { + return *internal_default_instance(); + } + static inline const SharedConfigMessage* internal_default_instance() { + return reinterpret_cast( + &_SharedConfigMessage_default_instance_); + } + static constexpr int kIndexInFileMessages = + 25; + + friend void swap(SharedConfigMessage& a, SharedConfigMessage& b) { + a.Swap(&b); + } + inline void Swap(SharedConfigMessage* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SharedConfigMessage* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SharedConfigMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const SharedConfigMessage& from); + void MergeFrom(const SharedConfigMessage& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(SharedConfigMessage* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.SharedConfigMessage"; + } + protected: + explicit SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + typedef SharedConfigMessage_Kind Kind; + static constexpr Kind USER_PROFILE = + SharedConfigMessage_Kind_USER_PROFILE; + static constexpr Kind CONTACTS = + SharedConfigMessage_Kind_CONTACTS; + static constexpr Kind CONVO_INFO_VOLATILE = + SharedConfigMessage_Kind_CONVO_INFO_VOLATILE; + static constexpr Kind USER_GROUPS = + SharedConfigMessage_Kind_USER_GROUPS; + static inline bool Kind_IsValid(int value) { + return SharedConfigMessage_Kind_IsValid(value); + } + static constexpr Kind Kind_MIN = + SharedConfigMessage_Kind_Kind_MIN; + static constexpr Kind Kind_MAX = + SharedConfigMessage_Kind_Kind_MAX; + static constexpr int Kind_ARRAYSIZE = + SharedConfigMessage_Kind_Kind_ARRAYSIZE; + template + static inline const std::string& Kind_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Kind_Name."); + return SharedConfigMessage_Kind_Name(enum_t_value); + } + static inline bool Kind_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Kind* value) { + return SharedConfigMessage_Kind_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + enum : int { + kDataFieldNumber = 3, + kSeqnoFieldNumber = 2, + kKindFieldNumber = 1, + }; + // required bytes data = 3; + bool has_data() const; + private: + bool _internal_has_data() const; + public: + void clear_data(); + const std::string& data() const; + template + void set_data(ArgT0&& arg0, ArgT... args); + std::string* mutable_data(); + PROTOBUF_NODISCARD std::string* release_data(); + void set_allocated_data(std::string* data); + private: + const std::string& _internal_data() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_data(const std::string& value); + std::string* _internal_mutable_data(); + public: + + // required int64 seqno = 2; + bool has_seqno() const; + private: + bool _internal_has_seqno() const; + public: + void clear_seqno(); + int64_t seqno() const; + void set_seqno(int64_t value); + private: + int64_t _internal_seqno() const; + void _internal_set_seqno(int64_t value); + public: + + // required .SessionProtos.SharedConfigMessage.Kind kind = 1; + bool has_kind() const; + private: + bool _internal_has_kind() const; + public: + void clear_kind(); + ::SessionProtos::SharedConfigMessage_Kind kind() const; + void set_kind(::SessionProtos::SharedConfigMessage_Kind value); + private: + ::SessionProtos::SharedConfigMessage_Kind _internal_kind() const; + void _internal_set_kind(::SessionProtos::SharedConfigMessage_Kind value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.SharedConfigMessage) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr data_; + int64_t seqno_; + int kind_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Envelope + +// required .SessionProtos.Envelope.Type type = 1; +inline bool Envelope::_internal_has_type() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + return value; +} +inline bool Envelope::has_type() const { + return _internal_has_type(); +} +inline void Envelope::clear_type() { + _impl_.type_ = 6; + _impl_._has_bits_[0] &= ~0x00000020u; +} +inline ::SessionProtos::Envelope_Type Envelope::_internal_type() const { + return static_cast< ::SessionProtos::Envelope_Type >(_impl_.type_); +} +inline ::SessionProtos::Envelope_Type Envelope::type() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.type) + return _internal_type(); +} +inline void Envelope::_internal_set_type(::SessionProtos::Envelope_Type value) { + assert(::SessionProtos::Envelope_Type_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.type_ = value; +} +inline void Envelope::set_type(::SessionProtos::Envelope_Type value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.type) +} + +// optional string source = 2; +inline bool Envelope::_internal_has_source() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Envelope::has_source() const { + return _internal_has_source(); +} +inline void Envelope::clear_source() { + _impl_.source_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Envelope::source() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.source) + return _internal_source(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Envelope::set_source(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.source_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.source) +} +inline std::string* Envelope::mutable_source() { + std::string* _s = _internal_mutable_source(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.source) + return _s; +} +inline const std::string& Envelope::_internal_source() const { + return _impl_.source_.Get(); +} +inline void Envelope::_internal_set_source(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.source_.Set(value, GetArenaForAllocation()); +} +inline std::string* Envelope::_internal_mutable_source() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.source_.Mutable(GetArenaForAllocation()); +} +inline std::string* Envelope::release_source() { + // @@protoc_insertion_point(field_release:SessionProtos.Envelope.source) + if (!_internal_has_source()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.source_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.source_.IsDefault()) { + _impl_.source_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Envelope::set_allocated_source(std::string* source) { + if (source != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.source_.SetAllocated(source, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.source_.IsDefault()) { + _impl_.source_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.source) +} + +// optional uint32 sourceDevice = 7; +inline bool Envelope::_internal_has_sourcedevice() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool Envelope::has_sourcedevice() const { + return _internal_has_sourcedevice(); +} +inline void Envelope::clear_sourcedevice() { + _impl_.sourcedevice_ = 0u; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline uint32_t Envelope::_internal_sourcedevice() const { + return _impl_.sourcedevice_; +} +inline uint32_t Envelope::sourcedevice() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.sourceDevice) + return _internal_sourcedevice(); +} +inline void Envelope::_internal_set_sourcedevice(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.sourcedevice_ = value; +} +inline void Envelope::set_sourcedevice(uint32_t value) { + _internal_set_sourcedevice(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.sourceDevice) +} + +// required uint64 timestamp = 5; +inline bool Envelope::_internal_has_timestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool Envelope::has_timestamp() const { + return _internal_has_timestamp(); +} +inline void Envelope::clear_timestamp() { + _impl_.timestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline uint64_t Envelope::_internal_timestamp() const { + return _impl_.timestamp_; +} +inline uint64_t Envelope::timestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.timestamp) + return _internal_timestamp(); +} +inline void Envelope::_internal_set_timestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.timestamp_ = value; +} +inline void Envelope::set_timestamp(uint64_t value) { + _internal_set_timestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.timestamp) +} + +// optional bytes content = 8; +inline bool Envelope::_internal_has_content() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Envelope::has_content() const { + return _internal_has_content(); +} +inline void Envelope::clear_content() { + _impl_.content_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& Envelope::content() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.content) + return _internal_content(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Envelope::set_content(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.content_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.content) +} +inline std::string* Envelope::mutable_content() { + std::string* _s = _internal_mutable_content(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.content) + return _s; +} +inline const std::string& Envelope::_internal_content() const { + return _impl_.content_.Get(); +} +inline void Envelope::_internal_set_content(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.content_.Set(value, GetArenaForAllocation()); +} +inline std::string* Envelope::_internal_mutable_content() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.content_.Mutable(GetArenaForAllocation()); +} +inline std::string* Envelope::release_content() { + // @@protoc_insertion_point(field_release:SessionProtos.Envelope.content) + if (!_internal_has_content()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.content_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.content_.IsDefault()) { + _impl_.content_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Envelope::set_allocated_content(std::string* content) { + if (content != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.content_.SetAllocated(content, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.content_.IsDefault()) { + _impl_.content_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.content) +} + +// optional uint64 serverTimestamp = 10; +inline bool Envelope::_internal_has_servertimestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool Envelope::has_servertimestamp() const { + return _internal_has_servertimestamp(); +} +inline void Envelope::clear_servertimestamp() { + _impl_.servertimestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline uint64_t Envelope::_internal_servertimestamp() const { + return _impl_.servertimestamp_; +} +inline uint64_t Envelope::servertimestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.serverTimestamp) + return _internal_servertimestamp(); +} +inline void Envelope::_internal_set_servertimestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.servertimestamp_ = value; +} +inline void Envelope::set_servertimestamp(uint64_t value) { + _internal_set_servertimestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.serverTimestamp) +} + +// ------------------------------------------------------------------- + +// TypingMessage + +// required uint64 timestamp = 1; +inline bool TypingMessage::_internal_has_timestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool TypingMessage::has_timestamp() const { + return _internal_has_timestamp(); +} +inline void TypingMessage::clear_timestamp() { + _impl_.timestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline uint64_t TypingMessage::_internal_timestamp() const { + return _impl_.timestamp_; +} +inline uint64_t TypingMessage::timestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.TypingMessage.timestamp) + return _internal_timestamp(); +} +inline void TypingMessage::_internal_set_timestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.timestamp_ = value; +} +inline void TypingMessage::set_timestamp(uint64_t value) { + _internal_set_timestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.TypingMessage.timestamp) +} + +// required .SessionProtos.TypingMessage.Action action = 2; +inline bool TypingMessage::_internal_has_action() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool TypingMessage::has_action() const { + return _internal_has_action(); +} +inline void TypingMessage::clear_action() { + _impl_.action_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline ::SessionProtos::TypingMessage_Action TypingMessage::_internal_action() const { + return static_cast< ::SessionProtos::TypingMessage_Action >(_impl_.action_); +} +inline ::SessionProtos::TypingMessage_Action TypingMessage::action() const { + // @@protoc_insertion_point(field_get:SessionProtos.TypingMessage.action) + return _internal_action(); +} +inline void TypingMessage::_internal_set_action(::SessionProtos::TypingMessage_Action value) { + assert(::SessionProtos::TypingMessage_Action_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.action_ = value; +} +inline void TypingMessage::set_action(::SessionProtos::TypingMessage_Action value) { + _internal_set_action(value); + // @@protoc_insertion_point(field_set:SessionProtos.TypingMessage.action) +} + +// ------------------------------------------------------------------- + +// UnsendRequest + +// required uint64 timestamp = 1; +inline bool UnsendRequest::_internal_has_timestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool UnsendRequest::has_timestamp() const { + return _internal_has_timestamp(); +} +inline void UnsendRequest::clear_timestamp() { + _impl_.timestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline uint64_t UnsendRequest::_internal_timestamp() const { + return _impl_.timestamp_; +} +inline uint64_t UnsendRequest::timestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.UnsendRequest.timestamp) + return _internal_timestamp(); +} +inline void UnsendRequest::_internal_set_timestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.timestamp_ = value; +} +inline void UnsendRequest::set_timestamp(uint64_t value) { + _internal_set_timestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.UnsendRequest.timestamp) +} + +// required string author = 2; +inline bool UnsendRequest::_internal_has_author() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool UnsendRequest::has_author() const { + return _internal_has_author(); +} +inline void UnsendRequest::clear_author() { + _impl_.author_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& UnsendRequest::author() const { + // @@protoc_insertion_point(field_get:SessionProtos.UnsendRequest.author) + return _internal_author(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void UnsendRequest::set_author(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.author_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.UnsendRequest.author) +} +inline std::string* UnsendRequest::mutable_author() { + std::string* _s = _internal_mutable_author(); + // @@protoc_insertion_point(field_mutable:SessionProtos.UnsendRequest.author) + return _s; +} +inline const std::string& UnsendRequest::_internal_author() const { + return _impl_.author_.Get(); +} +inline void UnsendRequest::_internal_set_author(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.author_.Set(value, GetArenaForAllocation()); +} +inline std::string* UnsendRequest::_internal_mutable_author() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.author_.Mutable(GetArenaForAllocation()); +} +inline std::string* UnsendRequest::release_author() { + // @@protoc_insertion_point(field_release:SessionProtos.UnsendRequest.author) + if (!_internal_has_author()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.author_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.author_.IsDefault()) { + _impl_.author_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void UnsendRequest::set_allocated_author(std::string* author) { + if (author != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.author_.SetAllocated(author, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.author_.IsDefault()) { + _impl_.author_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.UnsendRequest.author) +} + +// ------------------------------------------------------------------- + +// MessageRequestResponse + +// required bool isApproved = 1; +inline bool MessageRequestResponse::_internal_has_isapproved() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool MessageRequestResponse::has_isapproved() const { + return _internal_has_isapproved(); +} +inline void MessageRequestResponse::clear_isapproved() { + _impl_.isapproved_ = false; + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline bool MessageRequestResponse::_internal_isapproved() const { + return _impl_.isapproved_; +} +inline bool MessageRequestResponse::isapproved() const { + // @@protoc_insertion_point(field_get:SessionProtos.MessageRequestResponse.isApproved) + return _internal_isapproved(); +} +inline void MessageRequestResponse::_internal_set_isapproved(bool value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.isapproved_ = value; +} +inline void MessageRequestResponse::set_isapproved(bool value) { + _internal_set_isapproved(value); + // @@protoc_insertion_point(field_set:SessionProtos.MessageRequestResponse.isApproved) +} + +// optional bytes profileKey = 2; +inline bool MessageRequestResponse::_internal_has_profilekey() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool MessageRequestResponse::has_profilekey() const { + return _internal_has_profilekey(); +} +inline void MessageRequestResponse::clear_profilekey() { + _impl_.profilekey_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& MessageRequestResponse::profilekey() const { + // @@protoc_insertion_point(field_get:SessionProtos.MessageRequestResponse.profileKey) + return _internal_profilekey(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void MessageRequestResponse::set_profilekey(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.MessageRequestResponse.profileKey) +} +inline std::string* MessageRequestResponse::mutable_profilekey() { + std::string* _s = _internal_mutable_profilekey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.MessageRequestResponse.profileKey) + return _s; +} +inline const std::string& MessageRequestResponse::_internal_profilekey() const { + return _impl_.profilekey_.Get(); +} +inline void MessageRequestResponse::_internal_set_profilekey(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.profilekey_.Set(value, GetArenaForAllocation()); +} +inline std::string* MessageRequestResponse::_internal_mutable_profilekey() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.profilekey_.Mutable(GetArenaForAllocation()); +} +inline std::string* MessageRequestResponse::release_profilekey() { + // @@protoc_insertion_point(field_release:SessionProtos.MessageRequestResponse.profileKey) + if (!_internal_has_profilekey()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.profilekey_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.profilekey_.IsDefault()) { + _impl_.profilekey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void MessageRequestResponse::set_allocated_profilekey(std::string* profilekey) { + if (profilekey != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.profilekey_.IsDefault()) { + _impl_.profilekey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.MessageRequestResponse.profileKey) +} + +// optional .SessionProtos.LokiProfile profile = 3; +inline bool MessageRequestResponse::_internal_has_profile() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.profile_ != nullptr); + return value; +} +inline bool MessageRequestResponse::has_profile() const { + return _internal_has_profile(); +} +inline void MessageRequestResponse::clear_profile() { + if (_impl_.profile_ != nullptr) _impl_.profile_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const ::SessionProtos::LokiProfile& MessageRequestResponse::_internal_profile() const { + const ::SessionProtos::LokiProfile* p = _impl_.profile_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_LokiProfile_default_instance_); +} +inline const ::SessionProtos::LokiProfile& MessageRequestResponse::profile() const { + // @@protoc_insertion_point(field_get:SessionProtos.MessageRequestResponse.profile) + return _internal_profile(); +} +inline void MessageRequestResponse::unsafe_arena_set_allocated_profile( + ::SessionProtos::LokiProfile* profile) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.profile_); + } + _impl_.profile_ = profile; + if (profile) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.MessageRequestResponse.profile) +} +inline ::SessionProtos::LokiProfile* MessageRequestResponse::release_profile() { + _impl_._has_bits_[0] &= ~0x00000002u; + ::SessionProtos::LokiProfile* temp = _impl_.profile_; + _impl_.profile_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::SessionProtos::LokiProfile* MessageRequestResponse::unsafe_arena_release_profile() { + // @@protoc_insertion_point(field_release:SessionProtos.MessageRequestResponse.profile) + _impl_._has_bits_[0] &= ~0x00000002u; + ::SessionProtos::LokiProfile* temp = _impl_.profile_; + _impl_.profile_ = nullptr; + return temp; +} +inline ::SessionProtos::LokiProfile* MessageRequestResponse::_internal_mutable_profile() { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.profile_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::LokiProfile>(GetArenaForAllocation()); + _impl_.profile_ = p; + } + return _impl_.profile_; +} +inline ::SessionProtos::LokiProfile* MessageRequestResponse::mutable_profile() { + ::SessionProtos::LokiProfile* _msg = _internal_mutable_profile(); + // @@protoc_insertion_point(field_mutable:SessionProtos.MessageRequestResponse.profile) + return _msg; +} +inline void MessageRequestResponse::set_allocated_profile(::SessionProtos::LokiProfile* profile) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.profile_; + } + if (profile) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(profile); + if (message_arena != submessage_arena) { + profile = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, profile, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.profile_ = profile; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.MessageRequestResponse.profile) +} + +// ------------------------------------------------------------------- + +// ProProof + +// required uint32 version = 1; +inline bool ProProof::_internal_has_version() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool ProProof::has_version() const { + return _internal_has_version(); +} +inline void ProProof::clear_version() { + _impl_.version_ = 0u; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline uint32_t ProProof::_internal_version() const { + return _impl_.version_; +} +inline uint32_t ProProof::version() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.version) + return _internal_version(); } -inline void Envelope::_internal_set_type(::SessionProtos::Envelope_Type value) { - assert(::SessionProtos::Envelope_Type_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.type_ = value; +inline void ProProof::_internal_set_version(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.version_ = value; } -inline void Envelope::set_type(::SessionProtos::Envelope_Type value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.type) +inline void ProProof::set_version(uint32_t value) { + _internal_set_version(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.version) } -// optional string source = 2; -inline bool Envelope::_internal_has_source() const { +// required bytes genIndexHash = 2; +inline bool ProProof::_internal_has_genindexhash() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool Envelope::has_source() const { - return _internal_has_source(); +inline bool ProProof::has_genindexhash() const { + return _internal_has_genindexhash(); } -inline void Envelope::clear_source() { - _impl_.source_.ClearToEmpty(); +inline void ProProof::clear_genindexhash() { + _impl_.genindexhash_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& Envelope::source() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.source) - return _internal_source(); +inline const std::string& ProProof::genindexhash() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.genIndexHash) + return _internal_genindexhash(); } template inline PROTOBUF_ALWAYS_INLINE -void Envelope::set_source(ArgT0&& arg0, ArgT... args) { +void ProProof::set_genindexhash(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.source_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.source) + _impl_.genindexhash_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.genIndexHash) } -inline std::string* Envelope::mutable_source() { - std::string* _s = _internal_mutable_source(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.source) +inline std::string* ProProof::mutable_genindexhash() { + std::string* _s = _internal_mutable_genindexhash(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.genIndexHash) return _s; } -inline const std::string& Envelope::_internal_source() const { - return _impl_.source_.Get(); +inline const std::string& ProProof::_internal_genindexhash() const { + return _impl_.genindexhash_.Get(); } -inline void Envelope::_internal_set_source(const std::string& value) { +inline void ProProof::_internal_set_genindexhash(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.source_.Set(value, GetArenaForAllocation()); + _impl_.genindexhash_.Set(value, GetArenaForAllocation()); } -inline std::string* Envelope::_internal_mutable_source() { +inline std::string* ProProof::_internal_mutable_genindexhash() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.source_.Mutable(GetArenaForAllocation()); + return _impl_.genindexhash_.Mutable(GetArenaForAllocation()); } -inline std::string* Envelope::release_source() { - // @@protoc_insertion_point(field_release:SessionProtos.Envelope.source) - if (!_internal_has_source()) { +inline std::string* ProProof::release_genindexhash() { + // @@protoc_insertion_point(field_release:SessionProtos.ProProof.genIndexHash) + if (!_internal_has_genindexhash()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.source_.Release(); + auto* p = _impl_.genindexhash_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.source_.IsDefault()) { - _impl_.source_.Set("", GetArenaForAllocation()); + if (_impl_.genindexhash_.IsDefault()) { + _impl_.genindexhash_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void Envelope::set_allocated_source(std::string* source) { - if (source != nullptr) { +inline void ProProof::set_allocated_genindexhash(std::string* genindexhash) { + if (genindexhash != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.source_.SetAllocated(source, GetArenaForAllocation()); + _impl_.genindexhash_.SetAllocated(genindexhash, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.source_.IsDefault()) { - _impl_.source_.Set("", GetArenaForAllocation()); + if (_impl_.genindexhash_.IsDefault()) { + _impl_.genindexhash_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.source) -} - -// optional uint32 sourceDevice = 7; -inline bool Envelope::_internal_has_sourcedevice() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - return value; -} -inline bool Envelope::has_sourcedevice() const { - return _internal_has_sourcedevice(); -} -inline void Envelope::clear_sourcedevice() { - _impl_.sourcedevice_ = 0u; - _impl_._has_bits_[0] &= ~0x00000010u; -} -inline uint32_t Envelope::_internal_sourcedevice() const { - return _impl_.sourcedevice_; -} -inline uint32_t Envelope::sourcedevice() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.sourceDevice) - return _internal_sourcedevice(); -} -inline void Envelope::_internal_set_sourcedevice(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.sourcedevice_ = value; -} -inline void Envelope::set_sourcedevice(uint32_t value) { - _internal_set_sourcedevice(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.sourceDevice) -} - -// required uint64 timestamp = 5; -inline bool Envelope::_internal_has_timestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool Envelope::has_timestamp() const { - return _internal_has_timestamp(); -} -inline void Envelope::clear_timestamp() { - _impl_.timestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline uint64_t Envelope::_internal_timestamp() const { - return _impl_.timestamp_; -} -inline uint64_t Envelope::timestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.timestamp) - return _internal_timestamp(); -} -inline void Envelope::_internal_set_timestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.timestamp_ = value; -} -inline void Envelope::set_timestamp(uint64_t value) { - _internal_set_timestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.timestamp) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.genIndexHash) } -// optional bytes content = 8; -inline bool Envelope::_internal_has_content() const { +// required bytes rotatingPublicKey = 3; +inline bool ProProof::_internal_has_rotatingpublickey() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool Envelope::has_content() const { - return _internal_has_content(); +inline bool ProProof::has_rotatingpublickey() const { + return _internal_has_rotatingpublickey(); } -inline void Envelope::clear_content() { - _impl_.content_.ClearToEmpty(); +inline void ProProof::clear_rotatingpublickey() { + _impl_.rotatingpublickey_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const std::string& Envelope::content() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.content) - return _internal_content(); +inline const std::string& ProProof::rotatingpublickey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.rotatingPublicKey) + return _internal_rotatingpublickey(); } template inline PROTOBUF_ALWAYS_INLINE -void Envelope::set_content(ArgT0&& arg0, ArgT... args) { +void ProProof::set_rotatingpublickey(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.content_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.content) + _impl_.rotatingpublickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.rotatingPublicKey) } -inline std::string* Envelope::mutable_content() { - std::string* _s = _internal_mutable_content(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.content) +inline std::string* ProProof::mutable_rotatingpublickey() { + std::string* _s = _internal_mutable_rotatingpublickey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.rotatingPublicKey) return _s; } -inline const std::string& Envelope::_internal_content() const { - return _impl_.content_.Get(); +inline const std::string& ProProof::_internal_rotatingpublickey() const { + return _impl_.rotatingpublickey_.Get(); } -inline void Envelope::_internal_set_content(const std::string& value) { +inline void ProProof::_internal_set_rotatingpublickey(const std::string& value) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.content_.Set(value, GetArenaForAllocation()); + _impl_.rotatingpublickey_.Set(value, GetArenaForAllocation()); } -inline std::string* Envelope::_internal_mutable_content() { +inline std::string* ProProof::_internal_mutable_rotatingpublickey() { _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.content_.Mutable(GetArenaForAllocation()); + return _impl_.rotatingpublickey_.Mutable(GetArenaForAllocation()); } -inline std::string* Envelope::release_content() { - // @@protoc_insertion_point(field_release:SessionProtos.Envelope.content) - if (!_internal_has_content()) { +inline std::string* ProProof::release_rotatingpublickey() { + // @@protoc_insertion_point(field_release:SessionProtos.ProProof.rotatingPublicKey) + if (!_internal_has_rotatingpublickey()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.content_.Release(); + auto* p = _impl_.rotatingpublickey_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); + if (_impl_.rotatingpublickey_.IsDefault()) { + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void Envelope::set_allocated_content(std::string* content) { - if (content != nullptr) { +inline void ProProof::set_allocated_rotatingpublickey(std::string* rotatingpublickey) { + if (rotatingpublickey != nullptr) { _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.content_.SetAllocated(content, GetArenaForAllocation()); + _impl_.rotatingpublickey_.SetAllocated(rotatingpublickey, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); + if (_impl_.rotatingpublickey_.IsDefault()) { + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.content) -} - -// optional uint64 serverTimestamp = 10; -inline bool Envelope::_internal_has_servertimestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool Envelope::has_servertimestamp() const { - return _internal_has_servertimestamp(); -} -inline void Envelope::clear_servertimestamp() { - _impl_.servertimestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000008u; -} -inline uint64_t Envelope::_internal_servertimestamp() const { - return _impl_.servertimestamp_; -} -inline uint64_t Envelope::servertimestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.serverTimestamp) - return _internal_servertimestamp(); -} -inline void Envelope::_internal_set_servertimestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.servertimestamp_ = value; -} -inline void Envelope::set_servertimestamp(uint64_t value) { - _internal_set_servertimestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.serverTimestamp) -} - -// ------------------------------------------------------------------- - -// TypingMessage - -// required uint64 timestamp = 1; -inline bool TypingMessage::_internal_has_timestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool TypingMessage::has_timestamp() const { - return _internal_has_timestamp(); -} -inline void TypingMessage::clear_timestamp() { - _impl_.timestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline uint64_t TypingMessage::_internal_timestamp() const { - return _impl_.timestamp_; -} -inline uint64_t TypingMessage::timestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.TypingMessage.timestamp) - return _internal_timestamp(); -} -inline void TypingMessage::_internal_set_timestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.timestamp_ = value; -} -inline void TypingMessage::set_timestamp(uint64_t value) { - _internal_set_timestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.TypingMessage.timestamp) -} - -// required .SessionProtos.TypingMessage.Action action = 2; -inline bool TypingMessage::_internal_has_action() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool TypingMessage::has_action() const { - return _internal_has_action(); -} -inline void TypingMessage::clear_action() { - _impl_.action_ = 0; - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline ::SessionProtos::TypingMessage_Action TypingMessage::_internal_action() const { - return static_cast< ::SessionProtos::TypingMessage_Action >(_impl_.action_); -} -inline ::SessionProtos::TypingMessage_Action TypingMessage::action() const { - // @@protoc_insertion_point(field_get:SessionProtos.TypingMessage.action) - return _internal_action(); -} -inline void TypingMessage::_internal_set_action(::SessionProtos::TypingMessage_Action value) { - assert(::SessionProtos::TypingMessage_Action_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.action_ = value; -} -inline void TypingMessage::set_action(::SessionProtos::TypingMessage_Action value) { - _internal_set_action(value); - // @@protoc_insertion_point(field_set:SessionProtos.TypingMessage.action) +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.rotatingPublicKey) } -// ------------------------------------------------------------------- - -// UnsendRequest - -// required uint64 timestamp = 1; -inline bool UnsendRequest::_internal_has_timestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; +// required uint64 expiryUnixTs = 4; +inline bool ProProof::_internal_has_expiryunixts() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } -inline bool UnsendRequest::has_timestamp() const { - return _internal_has_timestamp(); +inline bool ProProof::has_expiryunixts() const { + return _internal_has_expiryunixts(); } -inline void UnsendRequest::clear_timestamp() { - _impl_.timestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000002u; +inline void ProProof::clear_expiryunixts() { + _impl_.expiryunixts_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000008u; } -inline uint64_t UnsendRequest::_internal_timestamp() const { - return _impl_.timestamp_; +inline uint64_t ProProof::_internal_expiryunixts() const { + return _impl_.expiryunixts_; } -inline uint64_t UnsendRequest::timestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.UnsendRequest.timestamp) - return _internal_timestamp(); +inline uint64_t ProProof::expiryunixts() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.expiryUnixTs) + return _internal_expiryunixts(); } -inline void UnsendRequest::_internal_set_timestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.timestamp_ = value; +inline void ProProof::_internal_set_expiryunixts(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.expiryunixts_ = value; } -inline void UnsendRequest::set_timestamp(uint64_t value) { - _internal_set_timestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.UnsendRequest.timestamp) +inline void ProProof::set_expiryunixts(uint64_t value) { + _internal_set_expiryunixts(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.expiryUnixTs) } -// required string author = 2; -inline bool UnsendRequest::_internal_has_author() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; +// required bytes sig = 5; +inline bool ProProof::_internal_has_sig() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool UnsendRequest::has_author() const { - return _internal_has_author(); +inline bool ProProof::has_sig() const { + return _internal_has_sig(); } -inline void UnsendRequest::clear_author() { - _impl_.author_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; +inline void ProProof::clear_sig() { + _impl_.sig_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } -inline const std::string& UnsendRequest::author() const { - // @@protoc_insertion_point(field_get:SessionProtos.UnsendRequest.author) - return _internal_author(); +inline const std::string& ProProof::sig() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.sig) + return _internal_sig(); } template inline PROTOBUF_ALWAYS_INLINE -void UnsendRequest::set_author(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.author_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.UnsendRequest.author) +void ProProof::set_sig(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.sig_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.sig) } -inline std::string* UnsendRequest::mutable_author() { - std::string* _s = _internal_mutable_author(); - // @@protoc_insertion_point(field_mutable:SessionProtos.UnsendRequest.author) +inline std::string* ProProof::mutable_sig() { + std::string* _s = _internal_mutable_sig(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.sig) return _s; } -inline const std::string& UnsendRequest::_internal_author() const { - return _impl_.author_.Get(); +inline const std::string& ProProof::_internal_sig() const { + return _impl_.sig_.Get(); } -inline void UnsendRequest::_internal_set_author(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.author_.Set(value, GetArenaForAllocation()); +inline void ProProof::_internal_set_sig(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.sig_.Set(value, GetArenaForAllocation()); } -inline std::string* UnsendRequest::_internal_mutable_author() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.author_.Mutable(GetArenaForAllocation()); +inline std::string* ProProof::_internal_mutable_sig() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.sig_.Mutable(GetArenaForAllocation()); } -inline std::string* UnsendRequest::release_author() { - // @@protoc_insertion_point(field_release:SessionProtos.UnsendRequest.author) - if (!_internal_has_author()) { +inline std::string* ProProof::release_sig() { + // @@protoc_insertion_point(field_release:SessionProtos.ProProof.sig) + if (!_internal_has_sig()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.author_.Release(); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.sig_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.author_.IsDefault()) { - _impl_.author_.Set("", GetArenaForAllocation()); + if (_impl_.sig_.IsDefault()) { + _impl_.sig_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void UnsendRequest::set_allocated_author(std::string* author) { - if (author != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; +inline void ProProof::set_allocated_sig(std::string* sig) { + if (sig != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000004u; } - _impl_.author_.SetAllocated(author, GetArenaForAllocation()); + _impl_.sig_.SetAllocated(sig, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.author_.IsDefault()) { - _impl_.author_.Set("", GetArenaForAllocation()); + if (_impl_.sig_.IsDefault()) { + _impl_.sig_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.UnsendRequest.author) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.sig) } // ------------------------------------------------------------------- -// MessageRequestResponse - -// required bool isApproved = 1; -inline bool MessageRequestResponse::_internal_has_isapproved() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool MessageRequestResponse::has_isapproved() const { - return _internal_has_isapproved(); -} -inline void MessageRequestResponse::clear_isapproved() { - _impl_.isapproved_ = false; - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline bool MessageRequestResponse::_internal_isapproved() const { - return _impl_.isapproved_; -} -inline bool MessageRequestResponse::isapproved() const { - // @@protoc_insertion_point(field_get:SessionProtos.MessageRequestResponse.isApproved) - return _internal_isapproved(); -} -inline void MessageRequestResponse::_internal_set_isapproved(bool value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.isapproved_ = value; -} -inline void MessageRequestResponse::set_isapproved(bool value) { - _internal_set_isapproved(value); - // @@protoc_insertion_point(field_set:SessionProtos.MessageRequestResponse.isApproved) -} +// ProConfig -// optional bytes profileKey = 2; -inline bool MessageRequestResponse::_internal_has_profilekey() const { +// required bytes rotatingPrivKey = 1; +inline bool ProConfig::_internal_has_rotatingprivkey() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool MessageRequestResponse::has_profilekey() const { - return _internal_has_profilekey(); +inline bool ProConfig::has_rotatingprivkey() const { + return _internal_has_rotatingprivkey(); } -inline void MessageRequestResponse::clear_profilekey() { - _impl_.profilekey_.ClearToEmpty(); +inline void ProConfig::clear_rotatingprivkey() { + _impl_.rotatingprivkey_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& MessageRequestResponse::profilekey() const { - // @@protoc_insertion_point(field_get:SessionProtos.MessageRequestResponse.profileKey) - return _internal_profilekey(); +inline const std::string& ProConfig::rotatingprivkey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.rotatingPrivKey) + return _internal_rotatingprivkey(); } template inline PROTOBUF_ALWAYS_INLINE -void MessageRequestResponse::set_profilekey(ArgT0&& arg0, ArgT... args) { +void ProConfig::set_rotatingprivkey(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.MessageRequestResponse.profileKey) + _impl_.rotatingprivkey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProConfig.rotatingPrivKey) } -inline std::string* MessageRequestResponse::mutable_profilekey() { - std::string* _s = _internal_mutable_profilekey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.MessageRequestResponse.profileKey) +inline std::string* ProConfig::mutable_rotatingprivkey() { + std::string* _s = _internal_mutable_rotatingprivkey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.rotatingPrivKey) return _s; } -inline const std::string& MessageRequestResponse::_internal_profilekey() const { - return _impl_.profilekey_.Get(); +inline const std::string& ProConfig::_internal_rotatingprivkey() const { + return _impl_.rotatingprivkey_.Get(); } -inline void MessageRequestResponse::_internal_set_profilekey(const std::string& value) { +inline void ProConfig::_internal_set_rotatingprivkey(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.profilekey_.Set(value, GetArenaForAllocation()); + _impl_.rotatingprivkey_.Set(value, GetArenaForAllocation()); } -inline std::string* MessageRequestResponse::_internal_mutable_profilekey() { +inline std::string* ProConfig::_internal_mutable_rotatingprivkey() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.profilekey_.Mutable(GetArenaForAllocation()); + return _impl_.rotatingprivkey_.Mutable(GetArenaForAllocation()); } -inline std::string* MessageRequestResponse::release_profilekey() { - // @@protoc_insertion_point(field_release:SessionProtos.MessageRequestResponse.profileKey) - if (!_internal_has_profilekey()) { +inline std::string* ProConfig::release_rotatingprivkey() { + // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.rotatingPrivKey) + if (!_internal_has_rotatingprivkey()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.profilekey_.Release(); + auto* p = _impl_.rotatingprivkey_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (_impl_.rotatingprivkey_.IsDefault()) { + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void MessageRequestResponse::set_allocated_profilekey(std::string* profilekey) { - if (profilekey != nullptr) { +inline void ProConfig::set_allocated_rotatingprivkey(std::string* rotatingprivkey) { + if (rotatingprivkey != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); + _impl_.rotatingprivkey_.SetAllocated(rotatingprivkey, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (_impl_.rotatingprivkey_.IsDefault()) { + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.MessageRequestResponse.profileKey) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.rotatingPrivKey) } -// optional .SessionProtos.LokiProfile profile = 3; -inline bool MessageRequestResponse::_internal_has_profile() const { +// required .SessionProtos.ProProof proof = 2; +inline bool ProConfig::_internal_has_proof() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || _impl_.profile_ != nullptr); + PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); return value; } -inline bool MessageRequestResponse::has_profile() const { - return _internal_has_profile(); +inline bool ProConfig::has_proof() const { + return _internal_has_proof(); } -inline void MessageRequestResponse::clear_profile() { - if (_impl_.profile_ != nullptr) _impl_.profile_->Clear(); +inline void ProConfig::clear_proof() { + if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const ::SessionProtos::LokiProfile& MessageRequestResponse::_internal_profile() const { - const ::SessionProtos::LokiProfile* p = _impl_.profile_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_LokiProfile_default_instance_); +inline const ::SessionProtos::ProProof& ProConfig::_internal_proof() const { + const ::SessionProtos::ProProof* p = _impl_.proof_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProProof_default_instance_); } -inline const ::SessionProtos::LokiProfile& MessageRequestResponse::profile() const { - // @@protoc_insertion_point(field_get:SessionProtos.MessageRequestResponse.profile) - return _internal_profile(); +inline const ::SessionProtos::ProProof& ProConfig::proof() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.proof) + return _internal_proof(); } -inline void MessageRequestResponse::unsafe_arena_set_allocated_profile( - ::SessionProtos::LokiProfile* profile) { +inline void ProConfig::unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.profile_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); } - _impl_.profile_ = profile; - if (profile) { + _impl_.proof_ = proof; + if (proof) { _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.MessageRequestResponse.profile) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProConfig.proof) } -inline ::SessionProtos::LokiProfile* MessageRequestResponse::release_profile() { +inline ::SessionProtos::ProProof* ProConfig::release_proof() { _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::LokiProfile* temp = _impl_.profile_; - _impl_.profile_ = nullptr; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -6702,44 +7315,166 @@ inline ::SessionProtos::LokiProfile* MessageRequestResponse::release_profile() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::LokiProfile* MessageRequestResponse::unsafe_arena_release_profile() { - // @@protoc_insertion_point(field_release:SessionProtos.MessageRequestResponse.profile) +inline ::SessionProtos::ProProof* ProConfig::unsafe_arena_release_proof() { + // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.proof) _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::LokiProfile* temp = _impl_.profile_; - _impl_.profile_ = nullptr; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; + return temp; +} +inline ::SessionProtos::ProProof* ProConfig::_internal_mutable_proof() { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.proof_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); + _impl_.proof_ = p; + } + return _impl_.proof_; +} +inline ::SessionProtos::ProProof* ProConfig::mutable_proof() { + ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.proof) + return _msg; +} +inline void ProConfig::set_allocated_proof(::SessionProtos::ProProof* proof) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.proof_; + } + if (proof) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); + if (message_arena != submessage_arena) { + proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, proof, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.proof_ = proof; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.proof) +} + +// ------------------------------------------------------------------- + +// ProMessageConfig + +// required .SessionProtos.ProProof proof = 1; +inline bool ProMessageConfig::_internal_has_proof() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); + return value; +} +inline bool ProMessageConfig::has_proof() const { + return _internal_has_proof(); +} +inline void ProMessageConfig::clear_proof() { + if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::SessionProtos::ProProof& ProMessageConfig::_internal_proof() const { + const ::SessionProtos::ProProof* p = _impl_.proof_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProProof_default_instance_); +} +inline const ::SessionProtos::ProProof& ProMessageConfig::proof() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProMessageConfig.proof) + return _internal_proof(); +} +inline void ProMessageConfig::unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); + } + _impl_.proof_ = proof; + if (proof) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProMessageConfig.proof) +} +inline ::SessionProtos::ProProof* ProMessageConfig::release_proof() { + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::LokiProfile* MessageRequestResponse::_internal_mutable_profile() { - _impl_._has_bits_[0] |= 0x00000002u; - if (_impl_.profile_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::LokiProfile>(GetArenaForAllocation()); - _impl_.profile_ = p; +inline ::SessionProtos::ProProof* ProMessageConfig::unsafe_arena_release_proof() { + // @@protoc_insertion_point(field_release:SessionProtos.ProMessageConfig.proof) + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; + return temp; +} +inline ::SessionProtos::ProProof* ProMessageConfig::_internal_mutable_proof() { + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.proof_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); + _impl_.proof_ = p; } - return _impl_.profile_; + return _impl_.proof_; } -inline ::SessionProtos::LokiProfile* MessageRequestResponse::mutable_profile() { - ::SessionProtos::LokiProfile* _msg = _internal_mutable_profile(); - // @@protoc_insertion_point(field_mutable:SessionProtos.MessageRequestResponse.profile) +inline ::SessionProtos::ProProof* ProMessageConfig::mutable_proof() { + ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProMessageConfig.proof) return _msg; } -inline void MessageRequestResponse::set_allocated_profile(::SessionProtos::LokiProfile* profile) { +inline void ProMessageConfig::set_allocated_proof(::SessionProtos::ProProof* proof) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.profile_; + delete _impl_.proof_; } - if (profile) { + if (proof) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(profile); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); if (message_arena != submessage_arena) { - profile = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, profile, submessage_arena); + proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, proof, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.profile_ = profile; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.MessageRequestResponse.profile) + _impl_.proof_ = proof; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProMessageConfig.proof) +} + +// required uint32 flags = 2; +inline bool ProMessageConfig::_internal_has_flags() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool ProMessageConfig::has_flags() const { + return _internal_has_flags(); +} +inline void ProMessageConfig::clear_flags() { + _impl_.flags_ = 0u; + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline uint32_t ProMessageConfig::_internal_flags() const { + return _impl_.flags_; +} +inline uint32_t ProMessageConfig::flags() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProMessageConfig.flags) + return _internal_flags(); +} +inline void ProMessageConfig::_internal_set_flags(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.flags_ = value; +} +inline void ProMessageConfig::set_flags(uint32_t value) { + _internal_set_flags(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProMessageConfig.flags) } // ------------------------------------------------------------------- @@ -7556,6 +8291,96 @@ inline void Content::set_allocated_sharedconfigmessage(::SessionProtos::SharedCo // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.sharedConfigMessage) } +// optional .SessionProtos.ProMessageConfig proMessageConfig = 12; +inline bool Content::_internal_has_promessageconfig() const { + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; + PROTOBUF_ASSUME(!value || _impl_.promessageconfig_ != nullptr); + return value; +} +inline bool Content::has_promessageconfig() const { + return _internal_has_promessageconfig(); +} +inline void Content::clear_promessageconfig() { + if (_impl_.promessageconfig_ != nullptr) _impl_.promessageconfig_->Clear(); + _impl_._has_bits_[0] &= ~0x00000200u; +} +inline const ::SessionProtos::ProMessageConfig& Content::_internal_promessageconfig() const { + const ::SessionProtos::ProMessageConfig* p = _impl_.promessageconfig_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProMessageConfig_default_instance_); +} +inline const ::SessionProtos::ProMessageConfig& Content::promessageconfig() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.proMessageConfig) + return _internal_promessageconfig(); +} +inline void Content::unsafe_arena_set_allocated_promessageconfig( + ::SessionProtos::ProMessageConfig* promessageconfig) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.promessageconfig_); + } + _impl_.promessageconfig_ = promessageconfig; + if (promessageconfig) { + _impl_._has_bits_[0] |= 0x00000200u; + } else { + _impl_._has_bits_[0] &= ~0x00000200u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.proMessageConfig) +} +inline ::SessionProtos::ProMessageConfig* Content::release_promessageconfig() { + _impl_._has_bits_[0] &= ~0x00000200u; + ::SessionProtos::ProMessageConfig* temp = _impl_.promessageconfig_; + _impl_.promessageconfig_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::SessionProtos::ProMessageConfig* Content::unsafe_arena_release_promessageconfig() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.proMessageConfig) + _impl_._has_bits_[0] &= ~0x00000200u; + ::SessionProtos::ProMessageConfig* temp = _impl_.promessageconfig_; + _impl_.promessageconfig_ = nullptr; + return temp; +} +inline ::SessionProtos::ProMessageConfig* Content::_internal_mutable_promessageconfig() { + _impl_._has_bits_[0] |= 0x00000200u; + if (_impl_.promessageconfig_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProMessageConfig>(GetArenaForAllocation()); + _impl_.promessageconfig_ = p; + } + return _impl_.promessageconfig_; +} +inline ::SessionProtos::ProMessageConfig* Content::mutable_promessageconfig() { + ::SessionProtos::ProMessageConfig* _msg = _internal_mutable_promessageconfig(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.proMessageConfig) + return _msg; +} +inline void Content::set_allocated_promessageconfig(::SessionProtos::ProMessageConfig* promessageconfig) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.promessageconfig_; + } + if (promessageconfig) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(promessageconfig); + if (message_arena != submessage_arena) { + promessageconfig = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, promessageconfig, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000200u; + } else { + _impl_._has_bits_[0] &= ~0x00000200u; + } + _impl_.promessageconfig_ = promessageconfig; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.proMessageConfig) +} + // ------------------------------------------------------------------- // CallMessage @@ -9838,716 +10663,316 @@ inline uint32_t DataMessage_ClosedGroupControlMessage::expirationtimer() const { } inline void DataMessage_ClosedGroupControlMessage::_internal_set_expirationtimer(uint32_t value) { _impl_._has_bits_[0] |= 0x00000008u; - _impl_.expirationtimer_ = value; -} -inline void DataMessage_ClosedGroupControlMessage::set_expirationtimer(uint32_t value) { - _internal_set_expirationtimer(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.expirationTimer) -} - -// ------------------------------------------------------------------- - -// DataMessage - -// optional string body = 1; -inline bool DataMessage::_internal_has_body() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool DataMessage::has_body() const { - return _internal_has_body(); -} -inline void DataMessage::clear_body() { - _impl_.body_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& DataMessage::body() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.body) - return _internal_body(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void DataMessage::set_body(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.body_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.body) -} -inline std::string* DataMessage::mutable_body() { - std::string* _s = _internal_mutable_body(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.body) - return _s; -} -inline const std::string& DataMessage::_internal_body() const { - return _impl_.body_.Get(); -} -inline void DataMessage::_internal_set_body(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.body_.Set(value, GetArenaForAllocation()); -} -inline std::string* DataMessage::_internal_mutable_body() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.body_.Mutable(GetArenaForAllocation()); -} -inline std::string* DataMessage::release_body() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.body) - if (!_internal_has_body()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.body_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.body_.IsDefault()) { - _impl_.body_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void DataMessage::set_allocated_body(std::string* body) { - if (body != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.body_.SetAllocated(body, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.body_.IsDefault()) { - _impl_.body_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.body) -} - -// repeated .SessionProtos.AttachmentPointer attachments = 2; -inline int DataMessage::_internal_attachments_size() const { - return _impl_.attachments_.size(); -} -inline int DataMessage::attachments_size() const { - return _internal_attachments_size(); -} -inline void DataMessage::clear_attachments() { - _impl_.attachments_.Clear(); -} -inline ::SessionProtos::AttachmentPointer* DataMessage::mutable_attachments(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.attachments) - return _impl_.attachments_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >* -DataMessage::mutable_attachments() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.attachments) - return &_impl_.attachments_; -} -inline const ::SessionProtos::AttachmentPointer& DataMessage::_internal_attachments(int index) const { - return _impl_.attachments_.Get(index); -} -inline const ::SessionProtos::AttachmentPointer& DataMessage::attachments(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.attachments) - return _internal_attachments(index); -} -inline ::SessionProtos::AttachmentPointer* DataMessage::_internal_add_attachments() { - return _impl_.attachments_.Add(); -} -inline ::SessionProtos::AttachmentPointer* DataMessage::add_attachments() { - ::SessionProtos::AttachmentPointer* _add = _internal_add_attachments(); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.attachments) - return _add; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >& -DataMessage::attachments() const { - // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.attachments) - return _impl_.attachments_; -} - -// optional uint32 flags = 4; -inline bool DataMessage::_internal_has_flags() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; - return value; -} -inline bool DataMessage::has_flags() const { - return _internal_has_flags(); -} -inline void DataMessage::clear_flags() { - _impl_.flags_ = 0u; - _impl_._has_bits_[0] &= ~0x00000100u; -} -inline uint32_t DataMessage::_internal_flags() const { - return _impl_.flags_; -} -inline uint32_t DataMessage::flags() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.flags) - return _internal_flags(); -} -inline void DataMessage::_internal_set_flags(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000100u; - _impl_.flags_ = value; -} -inline void DataMessage::set_flags(uint32_t value) { - _internal_set_flags(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.flags) -} - -// optional uint32 expireTimer = 5; -inline bool DataMessage::_internal_has_expiretimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; - return value; -} -inline bool DataMessage::has_expiretimer() const { - return _internal_has_expiretimer(); -} -inline void DataMessage::clear_expiretimer() { - _impl_.expiretimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000200u; -} -inline uint32_t DataMessage::_internal_expiretimer() const { - return _impl_.expiretimer_; -} -inline uint32_t DataMessage::expiretimer() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.expireTimer) - return _internal_expiretimer(); -} -inline void DataMessage::_internal_set_expiretimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000200u; - _impl_.expiretimer_ = value; + _impl_.expirationtimer_ = value; } -inline void DataMessage::set_expiretimer(uint32_t value) { - _internal_set_expiretimer(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.expireTimer) +inline void DataMessage_ClosedGroupControlMessage::set_expirationtimer(uint32_t value) { + _internal_set_expirationtimer(value); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.expirationTimer) } -// optional bytes profileKey = 6; -inline bool DataMessage::_internal_has_profilekey() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; +// ------------------------------------------------------------------- + +// DataMessage + +// optional string body = 1; +inline bool DataMessage::_internal_has_body() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool DataMessage::has_profilekey() const { - return _internal_has_profilekey(); +inline bool DataMessage::has_body() const { + return _internal_has_body(); } -inline void DataMessage::clear_profilekey() { - _impl_.profilekey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; +inline void DataMessage::clear_body() { + _impl_.body_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& DataMessage::profilekey() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.profileKey) - return _internal_profilekey(); +inline const std::string& DataMessage::body() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.body) + return _internal_body(); } template inline PROTOBUF_ALWAYS_INLINE -void DataMessage::set_profilekey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.profileKey) +void DataMessage::set_body(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.body_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.body) } -inline std::string* DataMessage::mutable_profilekey() { - std::string* _s = _internal_mutable_profilekey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.profileKey) +inline std::string* DataMessage::mutable_body() { + std::string* _s = _internal_mutable_body(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.body) return _s; } -inline const std::string& DataMessage::_internal_profilekey() const { - return _impl_.profilekey_.Get(); +inline const std::string& DataMessage::_internal_body() const { + return _impl_.body_.Get(); } -inline void DataMessage::_internal_set_profilekey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.profilekey_.Set(value, GetArenaForAllocation()); +inline void DataMessage::_internal_set_body(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.body_.Set(value, GetArenaForAllocation()); } -inline std::string* DataMessage::_internal_mutable_profilekey() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.profilekey_.Mutable(GetArenaForAllocation()); +inline std::string* DataMessage::_internal_mutable_body() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.body_.Mutable(GetArenaForAllocation()); } -inline std::string* DataMessage::release_profilekey() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.profileKey) - if (!_internal_has_profilekey()) { +inline std::string* DataMessage::release_body() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.body) + if (!_internal_has_body()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.profilekey_.Release(); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.body_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (_impl_.body_.IsDefault()) { + _impl_.body_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void DataMessage::set_allocated_profilekey(std::string* profilekey) { - if (profilekey != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; +inline void DataMessage::set_allocated_body(std::string* body) { + if (body != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); + _impl_.body_.SetAllocated(body, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (_impl_.body_.IsDefault()) { + _impl_.body_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.profileKey) -} - -// optional uint64 timestamp = 7; -inline bool DataMessage::_internal_has_timestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; - return value; -} -inline bool DataMessage::has_timestamp() const { - return _internal_has_timestamp(); -} -inline void DataMessage::clear_timestamp() { - _impl_.timestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000400u; -} -inline uint64_t DataMessage::_internal_timestamp() const { - return _impl_.timestamp_; -} -inline uint64_t DataMessage::timestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.timestamp) - return _internal_timestamp(); -} -inline void DataMessage::_internal_set_timestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000400u; - _impl_.timestamp_ = value; -} -inline void DataMessage::set_timestamp(uint64_t value) { - _internal_set_timestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.timestamp) -} - -// optional .SessionProtos.DataMessage.Quote quote = 8; -inline bool DataMessage::_internal_has_quote() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || _impl_.quote_ != nullptr); - return value; -} -inline bool DataMessage::has_quote() const { - return _internal_has_quote(); -} -inline void DataMessage::clear_quote() { - if (_impl_.quote_ != nullptr) _impl_.quote_->Clear(); - _impl_._has_bits_[0] &= ~0x00000008u; -} -inline const ::SessionProtos::DataMessage_Quote& DataMessage::_internal_quote() const { - const ::SessionProtos::DataMessage_Quote* p = _impl_.quote_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataMessage_Quote_default_instance_); -} -inline const ::SessionProtos::DataMessage_Quote& DataMessage::quote() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.quote) - return _internal_quote(); -} -inline void DataMessage::unsafe_arena_set_allocated_quote( - ::SessionProtos::DataMessage_Quote* quote) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.quote_); - } - _impl_.quote_ = quote; - if (quote) { - _impl_._has_bits_[0] |= 0x00000008u; - } else { - _impl_._has_bits_[0] &= ~0x00000008u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.quote) -} -inline ::SessionProtos::DataMessage_Quote* DataMessage::release_quote() { - _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::DataMessage_Quote* temp = _impl_.quote_; - _impl_.quote_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::DataMessage_Quote* DataMessage::unsafe_arena_release_quote() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.quote) - _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::DataMessage_Quote* temp = _impl_.quote_; - _impl_.quote_ = nullptr; - return temp; -} -inline ::SessionProtos::DataMessage_Quote* DataMessage::_internal_mutable_quote() { - _impl_._has_bits_[0] |= 0x00000008u; - if (_impl_.quote_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_Quote>(GetArenaForAllocation()); - _impl_.quote_ = p; - } - return _impl_.quote_; -} -inline ::SessionProtos::DataMessage_Quote* DataMessage::mutable_quote() { - ::SessionProtos::DataMessage_Quote* _msg = _internal_mutable_quote(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.quote) - return _msg; -} -inline void DataMessage::set_allocated_quote(::SessionProtos::DataMessage_Quote* quote) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.quote_; - } - if (quote) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(quote); - if (message_arena != submessage_arena) { - quote = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, quote, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000008u; - } else { - _impl_._has_bits_[0] &= ~0x00000008u; - } - _impl_.quote_ = quote; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.quote) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.body) } -// repeated .SessionProtos.DataMessage.Preview preview = 10; -inline int DataMessage::_internal_preview_size() const { - return _impl_.preview_.size(); +// repeated .SessionProtos.AttachmentPointer attachments = 2; +inline int DataMessage::_internal_attachments_size() const { + return _impl_.attachments_.size(); } -inline int DataMessage::preview_size() const { - return _internal_preview_size(); +inline int DataMessage::attachments_size() const { + return _internal_attachments_size(); } -inline void DataMessage::clear_preview() { - _impl_.preview_.Clear(); +inline void DataMessage::clear_attachments() { + _impl_.attachments_.Clear(); } -inline ::SessionProtos::DataMessage_Preview* DataMessage::mutable_preview(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.preview) - return _impl_.preview_.Mutable(index); +inline ::SessionProtos::AttachmentPointer* DataMessage::mutable_attachments(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.attachments) + return _impl_.attachments_.Mutable(index); } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >* -DataMessage::mutable_preview() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.preview) - return &_impl_.preview_; +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >* +DataMessage::mutable_attachments() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.attachments) + return &_impl_.attachments_; } -inline const ::SessionProtos::DataMessage_Preview& DataMessage::_internal_preview(int index) const { - return _impl_.preview_.Get(index); +inline const ::SessionProtos::AttachmentPointer& DataMessage::_internal_attachments(int index) const { + return _impl_.attachments_.Get(index); } -inline const ::SessionProtos::DataMessage_Preview& DataMessage::preview(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.preview) - return _internal_preview(index); +inline const ::SessionProtos::AttachmentPointer& DataMessage::attachments(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.attachments) + return _internal_attachments(index); } -inline ::SessionProtos::DataMessage_Preview* DataMessage::_internal_add_preview() { - return _impl_.preview_.Add(); +inline ::SessionProtos::AttachmentPointer* DataMessage::_internal_add_attachments() { + return _impl_.attachments_.Add(); } -inline ::SessionProtos::DataMessage_Preview* DataMessage::add_preview() { - ::SessionProtos::DataMessage_Preview* _add = _internal_add_preview(); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.preview) +inline ::SessionProtos::AttachmentPointer* DataMessage::add_attachments() { + ::SessionProtos::AttachmentPointer* _add = _internal_add_attachments(); + // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.attachments) return _add; } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >& -DataMessage::preview() const { - // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.preview) - return _impl_.preview_; +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >& +DataMessage::attachments() const { + // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.attachments) + return _impl_.attachments_; } -// optional .SessionProtos.DataMessage.Reaction reaction = 11; -inline bool DataMessage::_internal_has_reaction() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - PROTOBUF_ASSUME(!value || _impl_.reaction_ != nullptr); +// optional uint32 flags = 4; +inline bool DataMessage::_internal_has_flags() const { + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; return value; } -inline bool DataMessage::has_reaction() const { - return _internal_has_reaction(); +inline bool DataMessage::has_flags() const { + return _internal_has_flags(); } -inline void DataMessage::clear_reaction() { - if (_impl_.reaction_ != nullptr) _impl_.reaction_->Clear(); - _impl_._has_bits_[0] &= ~0x00000010u; +inline void DataMessage::clear_flags() { + _impl_.flags_ = 0u; + _impl_._has_bits_[0] &= ~0x00000100u; } -inline const ::SessionProtos::DataMessage_Reaction& DataMessage::_internal_reaction() const { - const ::SessionProtos::DataMessage_Reaction* p = _impl_.reaction_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataMessage_Reaction_default_instance_); +inline uint32_t DataMessage::_internal_flags() const { + return _impl_.flags_; } -inline const ::SessionProtos::DataMessage_Reaction& DataMessage::reaction() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.reaction) - return _internal_reaction(); +inline uint32_t DataMessage::flags() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.flags) + return _internal_flags(); } -inline void DataMessage::unsafe_arena_set_allocated_reaction( - ::SessionProtos::DataMessage_Reaction* reaction) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.reaction_); - } - _impl_.reaction_ = reaction; - if (reaction) { - _impl_._has_bits_[0] |= 0x00000010u; - } else { - _impl_._has_bits_[0] &= ~0x00000010u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.reaction) +inline void DataMessage::_internal_set_flags(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000100u; + _impl_.flags_ = value; } -inline ::SessionProtos::DataMessage_Reaction* DataMessage::release_reaction() { - _impl_._has_bits_[0] &= ~0x00000010u; - ::SessionProtos::DataMessage_Reaction* temp = _impl_.reaction_; - _impl_.reaction_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; +inline void DataMessage::set_flags(uint32_t value) { + _internal_set_flags(value); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.flags) } -inline ::SessionProtos::DataMessage_Reaction* DataMessage::unsafe_arena_release_reaction() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.reaction) - _impl_._has_bits_[0] &= ~0x00000010u; - ::SessionProtos::DataMessage_Reaction* temp = _impl_.reaction_; - _impl_.reaction_ = nullptr; - return temp; + +// optional uint32 expireTimer = 5; +inline bool DataMessage::_internal_has_expiretimer() const { + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; + return value; } -inline ::SessionProtos::DataMessage_Reaction* DataMessage::_internal_mutable_reaction() { - _impl_._has_bits_[0] |= 0x00000010u; - if (_impl_.reaction_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_Reaction>(GetArenaForAllocation()); - _impl_.reaction_ = p; - } - return _impl_.reaction_; +inline bool DataMessage::has_expiretimer() const { + return _internal_has_expiretimer(); } -inline ::SessionProtos::DataMessage_Reaction* DataMessage::mutable_reaction() { - ::SessionProtos::DataMessage_Reaction* _msg = _internal_mutable_reaction(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.reaction) - return _msg; +inline void DataMessage::clear_expiretimer() { + _impl_.expiretimer_ = 0u; + _impl_._has_bits_[0] &= ~0x00000200u; } -inline void DataMessage::set_allocated_reaction(::SessionProtos::DataMessage_Reaction* reaction) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.reaction_; - } - if (reaction) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(reaction); - if (message_arena != submessage_arena) { - reaction = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, reaction, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000010u; - } else { - _impl_._has_bits_[0] &= ~0x00000010u; - } - _impl_.reaction_ = reaction; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.reaction) +inline uint32_t DataMessage::_internal_expiretimer() const { + return _impl_.expiretimer_; +} +inline uint32_t DataMessage::expiretimer() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.expireTimer) + return _internal_expiretimer(); +} +inline void DataMessage::_internal_set_expiretimer(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000200u; + _impl_.expiretimer_ = value; +} +inline void DataMessage::set_expiretimer(uint32_t value) { + _internal_set_expiretimer(value); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.expireTimer) } -// optional .SessionProtos.LokiProfile profile = 101; -inline bool DataMessage::_internal_has_profile() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; - PROTOBUF_ASSUME(!value || _impl_.profile_ != nullptr); +// optional bytes profileKey = 6; +inline bool DataMessage::_internal_has_profilekey() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool DataMessage::has_profile() const { - return _internal_has_profile(); -} -inline void DataMessage::clear_profile() { - if (_impl_.profile_ != nullptr) _impl_.profile_->Clear(); - _impl_._has_bits_[0] &= ~0x00000020u; +inline bool DataMessage::has_profilekey() const { + return _internal_has_profilekey(); } -inline const ::SessionProtos::LokiProfile& DataMessage::_internal_profile() const { - const ::SessionProtos::LokiProfile* p = _impl_.profile_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_LokiProfile_default_instance_); +inline void DataMessage::clear_profilekey() { + _impl_.profilekey_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } -inline const ::SessionProtos::LokiProfile& DataMessage::profile() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.profile) - return _internal_profile(); +inline const std::string& DataMessage::profilekey() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.profileKey) + return _internal_profilekey(); } -inline void DataMessage::unsafe_arena_set_allocated_profile( - ::SessionProtos::LokiProfile* profile) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.profile_); - } - _impl_.profile_ = profile; - if (profile) { - _impl_._has_bits_[0] |= 0x00000020u; - } else { - _impl_._has_bits_[0] &= ~0x00000020u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.profile) +template +inline PROTOBUF_ALWAYS_INLINE +void DataMessage::set_profilekey(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.profileKey) } -inline ::SessionProtos::LokiProfile* DataMessage::release_profile() { - _impl_._has_bits_[0] &= ~0x00000020u; - ::SessionProtos::LokiProfile* temp = _impl_.profile_; - _impl_.profile_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; +inline std::string* DataMessage::mutable_profilekey() { + std::string* _s = _internal_mutable_profilekey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.profileKey) + return _s; } -inline ::SessionProtos::LokiProfile* DataMessage::unsafe_arena_release_profile() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.profile) - _impl_._has_bits_[0] &= ~0x00000020u; - ::SessionProtos::LokiProfile* temp = _impl_.profile_; - _impl_.profile_ = nullptr; - return temp; +inline const std::string& DataMessage::_internal_profilekey() const { + return _impl_.profilekey_.Get(); } -inline ::SessionProtos::LokiProfile* DataMessage::_internal_mutable_profile() { - _impl_._has_bits_[0] |= 0x00000020u; - if (_impl_.profile_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::LokiProfile>(GetArenaForAllocation()); - _impl_.profile_ = p; - } - return _impl_.profile_; +inline void DataMessage::_internal_set_profilekey(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.profilekey_.Set(value, GetArenaForAllocation()); } -inline ::SessionProtos::LokiProfile* DataMessage::mutable_profile() { - ::SessionProtos::LokiProfile* _msg = _internal_mutable_profile(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.profile) - return _msg; +inline std::string* DataMessage::_internal_mutable_profilekey() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.profilekey_.Mutable(GetArenaForAllocation()); } -inline void DataMessage::set_allocated_profile(::SessionProtos::LokiProfile* profile) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.profile_; +inline std::string* DataMessage::release_profilekey() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.profileKey) + if (!_internal_has_profilekey()) { + return nullptr; } - if (profile) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(profile); - if (message_arena != submessage_arena) { - profile = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, profile, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.profilekey_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.profilekey_.IsDefault()) { + _impl_.profilekey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void DataMessage::set_allocated_profilekey(std::string* profilekey) { + if (profilekey != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.profile_ = profile; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.profile) + _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.profilekey_.IsDefault()) { + _impl_.profilekey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.profileKey) } -// optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; -inline bool DataMessage::_internal_has_opengroupinvitation() const { - bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; - PROTOBUF_ASSUME(!value || _impl_.opengroupinvitation_ != nullptr); +// optional uint64 timestamp = 7; +inline bool DataMessage::_internal_has_timestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } -inline bool DataMessage::has_opengroupinvitation() const { - return _internal_has_opengroupinvitation(); -} -inline void DataMessage::clear_opengroupinvitation() { - if (_impl_.opengroupinvitation_ != nullptr) _impl_.opengroupinvitation_->Clear(); - _impl_._has_bits_[0] &= ~0x00000040u; -} -inline const ::SessionProtos::DataMessage_OpenGroupInvitation& DataMessage::_internal_opengroupinvitation() const { - const ::SessionProtos::DataMessage_OpenGroupInvitation* p = _impl_.opengroupinvitation_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataMessage_OpenGroupInvitation_default_instance_); -} -inline const ::SessionProtos::DataMessage_OpenGroupInvitation& DataMessage::opengroupinvitation() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.openGroupInvitation) - return _internal_opengroupinvitation(); -} -inline void DataMessage::unsafe_arena_set_allocated_opengroupinvitation( - ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.opengroupinvitation_); - } - _impl_.opengroupinvitation_ = opengroupinvitation; - if (opengroupinvitation) { - _impl_._has_bits_[0] |= 0x00000040u; - } else { - _impl_._has_bits_[0] &= ~0x00000040u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.openGroupInvitation) +inline bool DataMessage::has_timestamp() const { + return _internal_has_timestamp(); } -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::release_opengroupinvitation() { - _impl_._has_bits_[0] &= ~0x00000040u; - ::SessionProtos::DataMessage_OpenGroupInvitation* temp = _impl_.opengroupinvitation_; - _impl_.opengroupinvitation_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; +inline void DataMessage::clear_timestamp() { + _impl_.timestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000400u; } -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::unsafe_arena_release_opengroupinvitation() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.openGroupInvitation) - _impl_._has_bits_[0] &= ~0x00000040u; - ::SessionProtos::DataMessage_OpenGroupInvitation* temp = _impl_.opengroupinvitation_; - _impl_.opengroupinvitation_ = nullptr; - return temp; +inline uint64_t DataMessage::_internal_timestamp() const { + return _impl_.timestamp_; } -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::_internal_mutable_opengroupinvitation() { - _impl_._has_bits_[0] |= 0x00000040u; - if (_impl_.opengroupinvitation_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_OpenGroupInvitation>(GetArenaForAllocation()); - _impl_.opengroupinvitation_ = p; - } - return _impl_.opengroupinvitation_; +inline uint64_t DataMessage::timestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.timestamp) + return _internal_timestamp(); } -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::mutable_opengroupinvitation() { - ::SessionProtos::DataMessage_OpenGroupInvitation* _msg = _internal_mutable_opengroupinvitation(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.openGroupInvitation) - return _msg; +inline void DataMessage::_internal_set_timestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000400u; + _impl_.timestamp_ = value; } -inline void DataMessage::set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.opengroupinvitation_; - } - if (opengroupinvitation) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(opengroupinvitation); - if (message_arena != submessage_arena) { - opengroupinvitation = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, opengroupinvitation, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000040u; - } else { - _impl_._has_bits_[0] &= ~0x00000040u; - } - _impl_.opengroupinvitation_ = opengroupinvitation; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.openGroupInvitation) +inline void DataMessage::set_timestamp(uint64_t value) { + _internal_set_timestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.timestamp) } -// optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; -inline bool DataMessage::_internal_has_closedgroupcontrolmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; - PROTOBUF_ASSUME(!value || _impl_.closedgroupcontrolmessage_ != nullptr); +// optional .SessionProtos.DataMessage.Quote quote = 8; +inline bool DataMessage::_internal_has_quote() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.quote_ != nullptr); return value; } -inline bool DataMessage::has_closedgroupcontrolmessage() const { - return _internal_has_closedgroupcontrolmessage(); +inline bool DataMessage::has_quote() const { + return _internal_has_quote(); } -inline void DataMessage::clear_closedgroupcontrolmessage() { - if (_impl_.closedgroupcontrolmessage_ != nullptr) _impl_.closedgroupcontrolmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000080u; +inline void DataMessage::clear_quote() { + if (_impl_.quote_ != nullptr) _impl_.quote_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; } -inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage& DataMessage::_internal_closedgroupcontrolmessage() const { - const ::SessionProtos::DataMessage_ClosedGroupControlMessage* p = _impl_.closedgroupcontrolmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataMessage_ClosedGroupControlMessage_default_instance_); +inline const ::SessionProtos::DataMessage_Quote& DataMessage::_internal_quote() const { + const ::SessionProtos::DataMessage_Quote* p = _impl_.quote_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_DataMessage_Quote_default_instance_); } -inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage& DataMessage::closedgroupcontrolmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.closedGroupControlMessage) - return _internal_closedgroupcontrolmessage(); +inline const ::SessionProtos::DataMessage_Quote& DataMessage::quote() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.quote) + return _internal_quote(); } -inline void DataMessage::unsafe_arena_set_allocated_closedgroupcontrolmessage( - ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage) { +inline void DataMessage::unsafe_arena_set_allocated_quote( + ::SessionProtos::DataMessage_Quote* quote) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.closedgroupcontrolmessage_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.quote_); } - _impl_.closedgroupcontrolmessage_ = closedgroupcontrolmessage; - if (closedgroupcontrolmessage) { - _impl_._has_bits_[0] |= 0x00000080u; + _impl_.quote_ = quote; + if (quote) { + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000008u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.closedGroupControlMessage) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.quote) } -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::release_closedgroupcontrolmessage() { - _impl_._has_bits_[0] &= ~0x00000080u; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* temp = _impl_.closedgroupcontrolmessage_; - _impl_.closedgroupcontrolmessage_ = nullptr; +inline ::SessionProtos::DataMessage_Quote* DataMessage::release_quote() { + _impl_._has_bits_[0] &= ~0x00000008u; + ::SessionProtos::DataMessage_Quote* temp = _impl_.quote_; + _impl_.quote_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -10559,321 +10984,215 @@ inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::rele #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::unsafe_arena_release_closedgroupcontrolmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.closedGroupControlMessage) - _impl_._has_bits_[0] &= ~0x00000080u; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* temp = _impl_.closedgroupcontrolmessage_; - _impl_.closedgroupcontrolmessage_ = nullptr; +inline ::SessionProtos::DataMessage_Quote* DataMessage::unsafe_arena_release_quote() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.quote) + _impl_._has_bits_[0] &= ~0x00000008u; + ::SessionProtos::DataMessage_Quote* temp = _impl_.quote_; + _impl_.quote_ = nullptr; return temp; } -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::_internal_mutable_closedgroupcontrolmessage() { - _impl_._has_bits_[0] |= 0x00000080u; - if (_impl_.closedgroupcontrolmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_ClosedGroupControlMessage>(GetArenaForAllocation()); - _impl_.closedgroupcontrolmessage_ = p; +inline ::SessionProtos::DataMessage_Quote* DataMessage::_internal_mutable_quote() { + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.quote_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_Quote>(GetArenaForAllocation()); + _impl_.quote_ = p; } - return _impl_.closedgroupcontrolmessage_; + return _impl_.quote_; } -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::mutable_closedgroupcontrolmessage() { - ::SessionProtos::DataMessage_ClosedGroupControlMessage* _msg = _internal_mutable_closedgroupcontrolmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.closedGroupControlMessage) +inline ::SessionProtos::DataMessage_Quote* DataMessage::mutable_quote() { + ::SessionProtos::DataMessage_Quote* _msg = _internal_mutable_quote(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.quote) return _msg; } -inline void DataMessage::set_allocated_closedgroupcontrolmessage(::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage) { +inline void DataMessage::set_allocated_quote(::SessionProtos::DataMessage_Quote* quote) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.closedgroupcontrolmessage_; - } - if (closedgroupcontrolmessage) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(closedgroupcontrolmessage); - if (message_arena != submessage_arena) { - closedgroupcontrolmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, closedgroupcontrolmessage, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000080u; - } else { - _impl_._has_bits_[0] &= ~0x00000080u; - } - _impl_.closedgroupcontrolmessage_ = closedgroupcontrolmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.closedGroupControlMessage) -} - -// optional string syncTarget = 105; -inline bool DataMessage::_internal_has_synctarget() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool DataMessage::has_synctarget() const { - return _internal_has_synctarget(); -} -inline void DataMessage::clear_synctarget() { - _impl_.synctarget_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline const std::string& DataMessage::synctarget() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.syncTarget) - return _internal_synctarget(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void DataMessage::set_synctarget(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.synctarget_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.syncTarget) -} -inline std::string* DataMessage::mutable_synctarget() { - std::string* _s = _internal_mutable_synctarget(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.syncTarget) - return _s; -} -inline const std::string& DataMessage::_internal_synctarget() const { - return _impl_.synctarget_.Get(); -} -inline void DataMessage::_internal_set_synctarget(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.synctarget_.Set(value, GetArenaForAllocation()); -} -inline std::string* DataMessage::_internal_mutable_synctarget() { - _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.synctarget_.Mutable(GetArenaForAllocation()); -} -inline std::string* DataMessage::release_synctarget() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.syncTarget) - if (!_internal_has_synctarget()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.synctarget_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.synctarget_.IsDefault()) { - _impl_.synctarget_.Set("", GetArenaForAllocation()); + delete _impl_.quote_; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void DataMessage::set_allocated_synctarget(std::string* synctarget) { - if (synctarget != nullptr) { - _impl_._has_bits_[0] |= 0x00000004u; + if (quote) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(quote); + if (message_arena != submessage_arena) { + quote = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, quote, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; - } - _impl_.synctarget_.SetAllocated(synctarget, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.synctarget_.IsDefault()) { - _impl_.synctarget_.Set("", GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000008u; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.syncTarget) + _impl_.quote_ = quote; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.quote) } -// optional bool blocksCommunityMessageRequests = 106; -inline bool DataMessage::_internal_has_blockscommunitymessagerequests() const { - bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; - return value; -} -inline bool DataMessage::has_blockscommunitymessagerequests() const { - return _internal_has_blockscommunitymessagerequests(); +// repeated .SessionProtos.DataMessage.Preview preview = 10; +inline int DataMessage::_internal_preview_size() const { + return _impl_.preview_.size(); } -inline void DataMessage::clear_blockscommunitymessagerequests() { - _impl_.blockscommunitymessagerequests_ = false; - _impl_._has_bits_[0] &= ~0x00000800u; +inline int DataMessage::preview_size() const { + return _internal_preview_size(); } -inline bool DataMessage::_internal_blockscommunitymessagerequests() const { - return _impl_.blockscommunitymessagerequests_; +inline void DataMessage::clear_preview() { + _impl_.preview_.Clear(); } -inline bool DataMessage::blockscommunitymessagerequests() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.blocksCommunityMessageRequests) - return _internal_blockscommunitymessagerequests(); +inline ::SessionProtos::DataMessage_Preview* DataMessage::mutable_preview(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.preview) + return _impl_.preview_.Mutable(index); } -inline void DataMessage::_internal_set_blockscommunitymessagerequests(bool value) { - _impl_._has_bits_[0] |= 0x00000800u; - _impl_.blockscommunitymessagerequests_ = value; +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >* +DataMessage::mutable_preview() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.preview) + return &_impl_.preview_; } -inline void DataMessage::set_blockscommunitymessagerequests(bool value) { - _internal_set_blockscommunitymessagerequests(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.blocksCommunityMessageRequests) +inline const ::SessionProtos::DataMessage_Preview& DataMessage::_internal_preview(int index) const { + return _impl_.preview_.Get(index); } - -// ------------------------------------------------------------------- - -// ConfigurationMessage_ClosedGroup - -// optional bytes publicKey = 1; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_publickey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; +inline const ::SessionProtos::DataMessage_Preview& DataMessage::preview(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.preview) + return _internal_preview(index); } -inline bool ConfigurationMessage_ClosedGroup::has_publickey() const { - return _internal_has_publickey(); +inline ::SessionProtos::DataMessage_Preview* DataMessage::_internal_add_preview() { + return _impl_.preview_.Add(); } -inline void ConfigurationMessage_ClosedGroup::clear_publickey() { - _impl_.publickey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; +inline ::SessionProtos::DataMessage_Preview* DataMessage::add_preview() { + ::SessionProtos::DataMessage_Preview* _add = _internal_add_preview(); + // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.preview) + return _add; } -inline const std::string& ConfigurationMessage_ClosedGroup::publickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) - return _internal_publickey(); +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >& +DataMessage::preview() const { + // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.preview) + return _impl_.preview_; } -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ClosedGroup::set_publickey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) + +// optional .SessionProtos.DataMessage.Reaction reaction = 11; +inline bool DataMessage::_internal_has_reaction() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + PROTOBUF_ASSUME(!value || _impl_.reaction_ != nullptr); + return value; } -inline std::string* ConfigurationMessage_ClosedGroup::mutable_publickey() { - std::string* _s = _internal_mutable_publickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) - return _s; +inline bool DataMessage::has_reaction() const { + return _internal_has_reaction(); } -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_publickey() const { - return _impl_.publickey_.Get(); +inline void DataMessage::clear_reaction() { + if (_impl_.reaction_ != nullptr) _impl_.reaction_->Clear(); + _impl_._has_bits_[0] &= ~0x00000010u; } -inline void ConfigurationMessage_ClosedGroup::_internal_set_publickey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.Set(value, GetArenaForAllocation()); +inline const ::SessionProtos::DataMessage_Reaction& DataMessage::_internal_reaction() const { + const ::SessionProtos::DataMessage_Reaction* p = _impl_.reaction_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_DataMessage_Reaction_default_instance_); } -inline std::string* ConfigurationMessage_ClosedGroup::_internal_mutable_publickey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.publickey_.Mutable(GetArenaForAllocation()); +inline const ::SessionProtos::DataMessage_Reaction& DataMessage::reaction() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.reaction) + return _internal_reaction(); } -inline std::string* ConfigurationMessage_ClosedGroup::release_publickey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) - if (!_internal_has_publickey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.publickey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); +inline void DataMessage::unsafe_arena_set_allocated_reaction( + ::SessionProtos::DataMessage_Reaction* reaction) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.reaction_); } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ConfigurationMessage_ClosedGroup::set_allocated_publickey(std::string* publickey) { - if (publickey != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; + _impl_.reaction_ = reaction; + if (reaction) { + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.publickey_.SetAllocated(publickey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000010u; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) -} - -// optional string name = 2; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_name() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool ConfigurationMessage_ClosedGroup::has_name() const { - return _internal_has_name(); -} -inline void ConfigurationMessage_ClosedGroup::clear_name() { - _impl_.name_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const std::string& ConfigurationMessage_ClosedGroup::name() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.name) - return _internal_name(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ClosedGroup::set_name(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.name) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.reaction) } -inline std::string* ConfigurationMessage_ClosedGroup::mutable_name() { - std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.name) - return _s; +inline ::SessionProtos::DataMessage_Reaction* DataMessage::release_reaction() { + _impl_._has_bits_[0] &= ~0x00000010u; + ::SessionProtos::DataMessage_Reaction* temp = _impl_.reaction_; + _impl_.reaction_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_name() const { - return _impl_.name_.Get(); +inline ::SessionProtos::DataMessage_Reaction* DataMessage::unsafe_arena_release_reaction() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.reaction) + _impl_._has_bits_[0] &= ~0x00000010u; + ::SessionProtos::DataMessage_Reaction* temp = _impl_.reaction_; + _impl_.reaction_ = nullptr; + return temp; } -inline void ConfigurationMessage_ClosedGroup::_internal_set_name(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(value, GetArenaForAllocation()); +inline ::SessionProtos::DataMessage_Reaction* DataMessage::_internal_mutable_reaction() { + _impl_._has_bits_[0] |= 0x00000010u; + if (_impl_.reaction_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_Reaction>(GetArenaForAllocation()); + _impl_.reaction_ = p; + } + return _impl_.reaction_; } -inline std::string* ConfigurationMessage_ClosedGroup::_internal_mutable_name() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.name_.Mutable(GetArenaForAllocation()); +inline ::SessionProtos::DataMessage_Reaction* DataMessage::mutable_reaction() { + ::SessionProtos::DataMessage_Reaction* _msg = _internal_mutable_reaction(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.reaction) + return _msg; } -inline std::string* ConfigurationMessage_ClosedGroup::release_name() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.name) - if (!_internal_has_name()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.name_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); +inline void DataMessage::set_allocated_reaction(::SessionProtos::DataMessage_Reaction* reaction) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.reaction_; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ConfigurationMessage_ClosedGroup::set_allocated_name(std::string* name) { - if (name != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; + if (reaction) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(reaction); + if (message_arena != submessage_arena) { + reaction = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, reaction, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.name_.SetAllocated(name, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000010u; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.name) + _impl_.reaction_ = reaction; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.reaction) } -// optional .SessionProtos.KeyPair encryptionKeyPair = 3; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_encryptionkeypair() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - PROTOBUF_ASSUME(!value || _impl_.encryptionkeypair_ != nullptr); +// optional .SessionProtos.LokiProfile profile = 101; +inline bool DataMessage::_internal_has_profile() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + PROTOBUF_ASSUME(!value || _impl_.profile_ != nullptr); return value; } -inline bool ConfigurationMessage_ClosedGroup::has_encryptionkeypair() const { - return _internal_has_encryptionkeypair(); +inline bool DataMessage::has_profile() const { + return _internal_has_profile(); } -inline void ConfigurationMessage_ClosedGroup::clear_encryptionkeypair() { - if (_impl_.encryptionkeypair_ != nullptr) _impl_.encryptionkeypair_->Clear(); - _impl_._has_bits_[0] &= ~0x00000004u; +inline void DataMessage::clear_profile() { + if (_impl_.profile_ != nullptr) _impl_.profile_->Clear(); + _impl_._has_bits_[0] &= ~0x00000020u; } -inline const ::SessionProtos::KeyPair& ConfigurationMessage_ClosedGroup::_internal_encryptionkeypair() const { - const ::SessionProtos::KeyPair* p = _impl_.encryptionkeypair_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_KeyPair_default_instance_); +inline const ::SessionProtos::LokiProfile& DataMessage::_internal_profile() const { + const ::SessionProtos::LokiProfile* p = _impl_.profile_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_LokiProfile_default_instance_); } -inline const ::SessionProtos::KeyPair& ConfigurationMessage_ClosedGroup::encryptionkeypair() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) - return _internal_encryptionkeypair(); +inline const ::SessionProtos::LokiProfile& DataMessage::profile() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.profile) + return _internal_profile(); } -inline void ConfigurationMessage_ClosedGroup::unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair) { +inline void DataMessage::unsafe_arena_set_allocated_profile( + ::SessionProtos::LokiProfile* profile) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.encryptionkeypair_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.profile_); } - _impl_.encryptionkeypair_ = encryptionkeypair; - if (encryptionkeypair) { - _impl_._has_bits_[0] |= 0x00000004u; + _impl_.profile_ = profile; + if (profile) { + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000020u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.profile) } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::release_encryptionkeypair() { - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; - _impl_.encryptionkeypair_ = nullptr; +inline ::SessionProtos::LokiProfile* DataMessage::release_profile() { + _impl_._has_bits_[0] &= ~0x00000020u; + ::SessionProtos::LokiProfile* temp = _impl_.profile_; + _impl_.profile_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -10885,269 +11204,367 @@ inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::release_encry #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::unsafe_arena_release_encryptionkeypair() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; - _impl_.encryptionkeypair_ = nullptr; +inline ::SessionProtos::LokiProfile* DataMessage::unsafe_arena_release_profile() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.profile) + _impl_._has_bits_[0] &= ~0x00000020u; + ::SessionProtos::LokiProfile* temp = _impl_.profile_; + _impl_.profile_ = nullptr; return temp; } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::_internal_mutable_encryptionkeypair() { - _impl_._has_bits_[0] |= 0x00000004u; - if (_impl_.encryptionkeypair_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::KeyPair>(GetArenaForAllocation()); - _impl_.encryptionkeypair_ = p; +inline ::SessionProtos::LokiProfile* DataMessage::_internal_mutable_profile() { + _impl_._has_bits_[0] |= 0x00000020u; + if (_impl_.profile_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::LokiProfile>(GetArenaForAllocation()); + _impl_.profile_ = p; } - return _impl_.encryptionkeypair_; + return _impl_.profile_; } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::mutable_encryptionkeypair() { - ::SessionProtos::KeyPair* _msg = _internal_mutable_encryptionkeypair(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) +inline ::SessionProtos::LokiProfile* DataMessage::mutable_profile() { + ::SessionProtos::LokiProfile* _msg = _internal_mutable_profile(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.profile) return _msg; } -inline void ConfigurationMessage_ClosedGroup::set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair) { +inline void DataMessage::set_allocated_profile(::SessionProtos::LokiProfile* profile) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.encryptionkeypair_; + delete _impl_.profile_; } - if (encryptionkeypair) { + if (profile) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(encryptionkeypair); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(profile); if (message_arena != submessage_arena) { - encryptionkeypair = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, encryptionkeypair, submessage_arena); + profile = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, profile, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000020u; } - _impl_.encryptionkeypair_ = encryptionkeypair; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + _impl_.profile_ = profile; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.profile) } -// repeated bytes members = 4; -inline int ConfigurationMessage_ClosedGroup::_internal_members_size() const { - return _impl_.members_.size(); -} -inline int ConfigurationMessage_ClosedGroup::members_size() const { - return _internal_members_size(); -} -inline void ConfigurationMessage_ClosedGroup::clear_members() { - _impl_.members_.Clear(); -} -inline std::string* ConfigurationMessage_ClosedGroup::add_members() { - std::string* _s = _internal_add_members(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _s; -} -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_members(int index) const { - return _impl_.members_.Get(index); +// optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; +inline bool DataMessage::_internal_has_opengroupinvitation() const { + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + PROTOBUF_ASSUME(!value || _impl_.opengroupinvitation_ != nullptr); + return value; } -inline const std::string& ConfigurationMessage_ClosedGroup::members(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _internal_members(index); +inline bool DataMessage::has_opengroupinvitation() const { + return _internal_has_opengroupinvitation(); } -inline std::string* ConfigurationMessage_ClosedGroup::mutable_members(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _impl_.members_.Mutable(index); +inline void DataMessage::clear_opengroupinvitation() { + if (_impl_.opengroupinvitation_ != nullptr) _impl_.opengroupinvitation_->Clear(); + _impl_._has_bits_[0] &= ~0x00000040u; } -inline void ConfigurationMessage_ClosedGroup::set_members(int index, const std::string& value) { - _impl_.members_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline const ::SessionProtos::DataMessage_OpenGroupInvitation& DataMessage::_internal_opengroupinvitation() const { + const ::SessionProtos::DataMessage_OpenGroupInvitation* p = _impl_.opengroupinvitation_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_DataMessage_OpenGroupInvitation_default_instance_); } -inline void ConfigurationMessage_ClosedGroup::set_members(int index, std::string&& value) { - _impl_.members_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline const ::SessionProtos::DataMessage_OpenGroupInvitation& DataMessage::opengroupinvitation() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.openGroupInvitation) + return _internal_opengroupinvitation(); } -inline void ConfigurationMessage_ClosedGroup::set_members(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.members_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline void DataMessage::unsafe_arena_set_allocated_opengroupinvitation( + ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.opengroupinvitation_); + } + _impl_.opengroupinvitation_ = opengroupinvitation; + if (opengroupinvitation) { + _impl_._has_bits_[0] |= 0x00000040u; + } else { + _impl_._has_bits_[0] &= ~0x00000040u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.openGroupInvitation) } -inline void ConfigurationMessage_ClosedGroup::set_members(int index, const void* value, size_t size) { - _impl_.members_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::release_opengroupinvitation() { + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::DataMessage_OpenGroupInvitation* temp = _impl_.opengroupinvitation_; + _impl_.opengroupinvitation_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline std::string* ConfigurationMessage_ClosedGroup::_internal_add_members() { - return _impl_.members_.Add(); +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::unsafe_arena_release_opengroupinvitation() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.openGroupInvitation) + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::DataMessage_OpenGroupInvitation* temp = _impl_.opengroupinvitation_; + _impl_.opengroupinvitation_ = nullptr; + return temp; } -inline void ConfigurationMessage_ClosedGroup::add_members(const std::string& value) { - _impl_.members_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::_internal_mutable_opengroupinvitation() { + _impl_._has_bits_[0] |= 0x00000040u; + if (_impl_.opengroupinvitation_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_OpenGroupInvitation>(GetArenaForAllocation()); + _impl_.opengroupinvitation_ = p; + } + return _impl_.opengroupinvitation_; } -inline void ConfigurationMessage_ClosedGroup::add_members(std::string&& value) { - _impl_.members_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::mutable_opengroupinvitation() { + ::SessionProtos::DataMessage_OpenGroupInvitation* _msg = _internal_mutable_opengroupinvitation(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.openGroupInvitation) + return _msg; } -inline void ConfigurationMessage_ClosedGroup::add_members(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.members_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline void DataMessage::set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.opengroupinvitation_; + } + if (opengroupinvitation) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(opengroupinvitation); + if (message_arena != submessage_arena) { + opengroupinvitation = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, opengroupinvitation, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000040u; + } else { + _impl_._has_bits_[0] &= ~0x00000040u; + } + _impl_.opengroupinvitation_ = opengroupinvitation; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.openGroupInvitation) } -inline void ConfigurationMessage_ClosedGroup::add_members(const void* value, size_t size) { - _impl_.members_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.members) + +// optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; +inline bool DataMessage::_internal_has_closedgroupcontrolmessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + PROTOBUF_ASSUME(!value || _impl_.closedgroupcontrolmessage_ != nullptr); + return value; } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -ConfigurationMessage_ClosedGroup::members() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _impl_.members_; +inline bool DataMessage::has_closedgroupcontrolmessage() const { + return _internal_has_closedgroupcontrolmessage(); } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -ConfigurationMessage_ClosedGroup::mutable_members() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return &_impl_.members_; +inline void DataMessage::clear_closedgroupcontrolmessage() { + if (_impl_.closedgroupcontrolmessage_ != nullptr) _impl_.closedgroupcontrolmessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000080u; } - -// repeated bytes admins = 5; -inline int ConfigurationMessage_ClosedGroup::_internal_admins_size() const { - return _impl_.admins_.size(); +inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage& DataMessage::_internal_closedgroupcontrolmessage() const { + const ::SessionProtos::DataMessage_ClosedGroupControlMessage* p = _impl_.closedgroupcontrolmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_DataMessage_ClosedGroupControlMessage_default_instance_); } -inline int ConfigurationMessage_ClosedGroup::admins_size() const { - return _internal_admins_size(); +inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage& DataMessage::closedgroupcontrolmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.closedGroupControlMessage) + return _internal_closedgroupcontrolmessage(); } -inline void ConfigurationMessage_ClosedGroup::clear_admins() { - _impl_.admins_.Clear(); +inline void DataMessage::unsafe_arena_set_allocated_closedgroupcontrolmessage( + ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.closedgroupcontrolmessage_); + } + _impl_.closedgroupcontrolmessage_ = closedgroupcontrolmessage; + if (closedgroupcontrolmessage) { + _impl_._has_bits_[0] |= 0x00000080u; + } else { + _impl_._has_bits_[0] &= ~0x00000080u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.closedGroupControlMessage) } -inline std::string* ConfigurationMessage_ClosedGroup::add_admins() { - std::string* _s = _internal_add_admins(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _s; +inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::release_closedgroupcontrolmessage() { + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::DataMessage_ClosedGroupControlMessage* temp = _impl_.closedgroupcontrolmessage_; + _impl_.closedgroupcontrolmessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_admins(int index) const { - return _impl_.admins_.Get(index); +inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::unsafe_arena_release_closedgroupcontrolmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.closedGroupControlMessage) + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::DataMessage_ClosedGroupControlMessage* temp = _impl_.closedgroupcontrolmessage_; + _impl_.closedgroupcontrolmessage_ = nullptr; + return temp; } -inline const std::string& ConfigurationMessage_ClosedGroup::admins(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _internal_admins(index); +inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::_internal_mutable_closedgroupcontrolmessage() { + _impl_._has_bits_[0] |= 0x00000080u; + if (_impl_.closedgroupcontrolmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_ClosedGroupControlMessage>(GetArenaForAllocation()); + _impl_.closedgroupcontrolmessage_ = p; + } + return _impl_.closedgroupcontrolmessage_; } -inline std::string* ConfigurationMessage_ClosedGroup::mutable_admins(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _impl_.admins_.Mutable(index); +inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::mutable_closedgroupcontrolmessage() { + ::SessionProtos::DataMessage_ClosedGroupControlMessage* _msg = _internal_mutable_closedgroupcontrolmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.closedGroupControlMessage) + return _msg; } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const std::string& value) { - _impl_.admins_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline void DataMessage::set_allocated_closedgroupcontrolmessage(::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.closedgroupcontrolmessage_; + } + if (closedgroupcontrolmessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(closedgroupcontrolmessage); + if (message_arena != submessage_arena) { + closedgroupcontrolmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, closedgroupcontrolmessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000080u; + } else { + _impl_._has_bits_[0] &= ~0x00000080u; + } + _impl_.closedgroupcontrolmessage_ = closedgroupcontrolmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.closedGroupControlMessage) } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, std::string&& value) { - _impl_.admins_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.admins) + +// optional string syncTarget = 105; +inline bool DataMessage::_internal_has_synctarget() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.admins_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline bool DataMessage::has_synctarget() const { + return _internal_has_synctarget(); } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const void* value, size_t size) { - _impl_.admins_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline void DataMessage::clear_synctarget() { + _impl_.synctarget_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } -inline std::string* ConfigurationMessage_ClosedGroup::_internal_add_admins() { - return _impl_.admins_.Add(); +inline const std::string& DataMessage::synctarget() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.syncTarget) + return _internal_synctarget(); } -inline void ConfigurationMessage_ClosedGroup::add_admins(const std::string& value) { - _impl_.admins_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +template +inline PROTOBUF_ALWAYS_INLINE +void DataMessage::set_synctarget(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.synctarget_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.syncTarget) } -inline void ConfigurationMessage_ClosedGroup::add_admins(std::string&& value) { - _impl_.admins_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline std::string* DataMessage::mutable_synctarget() { + std::string* _s = _internal_mutable_synctarget(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.syncTarget) + return _s; } -inline void ConfigurationMessage_ClosedGroup::add_admins(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.admins_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline const std::string& DataMessage::_internal_synctarget() const { + return _impl_.synctarget_.Get(); } -inline void ConfigurationMessage_ClosedGroup::add_admins(const void* value, size_t size) { - _impl_.admins_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline void DataMessage::_internal_set_synctarget(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.synctarget_.Set(value, GetArenaForAllocation()); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -ConfigurationMessage_ClosedGroup::admins() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _impl_.admins_; +inline std::string* DataMessage::_internal_mutable_synctarget() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.synctarget_.Mutable(GetArenaForAllocation()); } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -ConfigurationMessage_ClosedGroup::mutable_admins() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return &_impl_.admins_; +inline std::string* DataMessage::release_synctarget() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.syncTarget) + if (!_internal_has_synctarget()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.synctarget_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.synctarget_.IsDefault()) { + _impl_.synctarget_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void DataMessage::set_allocated_synctarget(std::string* synctarget) { + if (synctarget != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.synctarget_.SetAllocated(synctarget, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.synctarget_.IsDefault()) { + _impl_.synctarget_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.syncTarget) } -// optional uint32 expirationTimer = 6; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_expirationtimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; +// optional bool blocksCommunityMessageRequests = 106; +inline bool DataMessage::_internal_has_blockscommunitymessagerequests() const { + bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; return value; } -inline bool ConfigurationMessage_ClosedGroup::has_expirationtimer() const { - return _internal_has_expirationtimer(); +inline bool DataMessage::has_blockscommunitymessagerequests() const { + return _internal_has_blockscommunitymessagerequests(); } -inline void ConfigurationMessage_ClosedGroup::clear_expirationtimer() { - _impl_.expirationtimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000008u; +inline void DataMessage::clear_blockscommunitymessagerequests() { + _impl_.blockscommunitymessagerequests_ = false; + _impl_._has_bits_[0] &= ~0x00000800u; } -inline uint32_t ConfigurationMessage_ClosedGroup::_internal_expirationtimer() const { - return _impl_.expirationtimer_; +inline bool DataMessage::_internal_blockscommunitymessagerequests() const { + return _impl_.blockscommunitymessagerequests_; } -inline uint32_t ConfigurationMessage_ClosedGroup::expirationtimer() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.expirationTimer) - return _internal_expirationtimer(); +inline bool DataMessage::blockscommunitymessagerequests() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.blocksCommunityMessageRequests) + return _internal_blockscommunitymessagerequests(); } -inline void ConfigurationMessage_ClosedGroup::_internal_set_expirationtimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.expirationtimer_ = value; +inline void DataMessage::_internal_set_blockscommunitymessagerequests(bool value) { + _impl_._has_bits_[0] |= 0x00000800u; + _impl_.blockscommunitymessagerequests_ = value; } -inline void ConfigurationMessage_ClosedGroup::set_expirationtimer(uint32_t value) { - _internal_set_expirationtimer(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.expirationTimer) +inline void DataMessage::set_blockscommunitymessagerequests(bool value) { + _internal_set_blockscommunitymessagerequests(value); + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.blocksCommunityMessageRequests) } // ------------------------------------------------------------------- -// ConfigurationMessage_Contact +// ConfigurationMessage_ClosedGroup -// required bytes publicKey = 1; -inline bool ConfigurationMessage_Contact::_internal_has_publickey() const { +// optional bytes publicKey = 1; +inline bool ConfigurationMessage_ClosedGroup::_internal_has_publickey() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_publickey() const { +inline bool ConfigurationMessage_ClosedGroup::has_publickey() const { return _internal_has_publickey(); } -inline void ConfigurationMessage_Contact::clear_publickey() { +inline void ConfigurationMessage_ClosedGroup::clear_publickey() { _impl_.publickey_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& ConfigurationMessage_Contact::publickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.publicKey) +inline const std::string& ConfigurationMessage_ClosedGroup::publickey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) return _internal_publickey(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_publickey(ArgT0&& arg0, ArgT... args) { +void ConfigurationMessage_ClosedGroup::set_publickey(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.publicKey) + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) } -inline std::string* ConfigurationMessage_Contact::mutable_publickey() { +inline std::string* ConfigurationMessage_ClosedGroup::mutable_publickey() { std::string* _s = _internal_mutable_publickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.publicKey) + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_publickey() const { +inline const std::string& ConfigurationMessage_ClosedGroup::_internal_publickey() const { return _impl_.publickey_.Get(); } -inline void ConfigurationMessage_Contact::_internal_set_publickey(const std::string& value) { +inline void ConfigurationMessage_ClosedGroup::_internal_set_publickey(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; _impl_.publickey_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_publickey() { +inline std::string* ConfigurationMessage_ClosedGroup::_internal_mutable_publickey() { _impl_._has_bits_[0] |= 0x00000001u; return _impl_.publickey_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::release_publickey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.publicKey) +inline std::string* ConfigurationMessage_ClosedGroup::release_publickey() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) if (!_internal_has_publickey()) { return nullptr; } @@ -11160,7 +11577,7 @@ inline std::string* ConfigurationMessage_Contact::release_publickey() { #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Contact::set_allocated_publickey(std::string* publickey) { +inline void ConfigurationMessage_ClosedGroup::set_allocated_publickey(std::string* publickey) { if (publickey != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { @@ -11172,50 +11589,50 @@ inline void ConfigurationMessage_Contact::set_allocated_publickey(std::string* p _impl_.publickey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.publicKey) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) } -// required string name = 2; -inline bool ConfigurationMessage_Contact::_internal_has_name() const { +// optional string name = 2; +inline bool ConfigurationMessage_ClosedGroup::_internal_has_name() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_name() const { +inline bool ConfigurationMessage_ClosedGroup::has_name() const { return _internal_has_name(); } -inline void ConfigurationMessage_Contact::clear_name() { +inline void ConfigurationMessage_ClosedGroup::clear_name() { _impl_.name_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const std::string& ConfigurationMessage_Contact::name() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.name) +inline const std::string& ConfigurationMessage_ClosedGroup::name() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.name) return _internal_name(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_name(ArgT0&& arg0, ArgT... args) { +void ConfigurationMessage_ClosedGroup::set_name(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000002u; _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.name) + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.name) } -inline std::string* ConfigurationMessage_Contact::mutable_name() { +inline std::string* ConfigurationMessage_ClosedGroup::mutable_name() { std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.name) + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.name) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_name() const { +inline const std::string& ConfigurationMessage_ClosedGroup::_internal_name() const { return _impl_.name_.Get(); } -inline void ConfigurationMessage_Contact::_internal_set_name(const std::string& value) { +inline void ConfigurationMessage_ClosedGroup::_internal_set_name(const std::string& value) { _impl_._has_bits_[0] |= 0x00000002u; _impl_.name_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_name() { +inline std::string* ConfigurationMessage_ClosedGroup::_internal_mutable_name() { _impl_._has_bits_[0] |= 0x00000002u; return _impl_.name_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::release_name() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.name) +inline std::string* ConfigurationMessage_ClosedGroup::release_name() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.name) if (!_internal_has_name()) { return nullptr; } @@ -11228,7 +11645,7 @@ inline std::string* ConfigurationMessage_Contact::release_name() { #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Contact::set_allocated_name(std::string* name) { +inline void ConfigurationMessage_ClosedGroup::set_allocated_name(std::string* name) { if (name != nullptr) { _impl_._has_bits_[0] |= 0x00000002u; } else { @@ -11240,631 +11657,635 @@ inline void ConfigurationMessage_Contact::set_allocated_name(std::string* name) _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.name) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.name) } -// optional string profilePicture = 3; -inline bool ConfigurationMessage_Contact::_internal_has_profilepicture() const { +// optional .SessionProtos.KeyPair encryptionKeyPair = 3; +inline bool ConfigurationMessage_ClosedGroup::_internal_has_encryptionkeypair() const { bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + PROTOBUF_ASSUME(!value || _impl_.encryptionkeypair_ != nullptr); return value; } -inline bool ConfigurationMessage_Contact::has_profilepicture() const { - return _internal_has_profilepicture(); +inline bool ConfigurationMessage_ClosedGroup::has_encryptionkeypair() const { + return _internal_has_encryptionkeypair(); } -inline void ConfigurationMessage_Contact::clear_profilepicture() { - _impl_.profilepicture_.ClearToEmpty(); +inline void ConfigurationMessage_ClosedGroup::clear_encryptionkeypair() { + if (_impl_.encryptionkeypair_ != nullptr) _impl_.encryptionkeypair_->Clear(); _impl_._has_bits_[0] &= ~0x00000004u; } -inline const std::string& ConfigurationMessage_Contact::profilepicture() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.profilePicture) - return _internal_profilepicture(); +inline const ::SessionProtos::KeyPair& ConfigurationMessage_ClosedGroup::_internal_encryptionkeypair() const { + const ::SessionProtos::KeyPair* p = _impl_.encryptionkeypair_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_KeyPair_default_instance_); } -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_profilepicture(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.profilepicture_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.profilePicture) +inline const ::SessionProtos::KeyPair& ConfigurationMessage_ClosedGroup::encryptionkeypair() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + return _internal_encryptionkeypair(); } -inline std::string* ConfigurationMessage_Contact::mutable_profilepicture() { - std::string* _s = _internal_mutable_profilepicture(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.profilePicture) - return _s; +inline void ConfigurationMessage_ClosedGroup::unsafe_arena_set_allocated_encryptionkeypair( + ::SessionProtos::KeyPair* encryptionkeypair) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.encryptionkeypair_); + } + _impl_.encryptionkeypair_ = encryptionkeypair; + if (encryptionkeypair) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) } -inline const std::string& ConfigurationMessage_Contact::_internal_profilepicture() const { - return _impl_.profilepicture_.Get(); +inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::release_encryptionkeypair() { + _impl_._has_bits_[0] &= ~0x00000004u; + ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; + _impl_.encryptionkeypair_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline void ConfigurationMessage_Contact::_internal_set_profilepicture(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.profilepicture_.Set(value, GetArenaForAllocation()); +inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::unsafe_arena_release_encryptionkeypair() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + _impl_._has_bits_[0] &= ~0x00000004u; + ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; + _impl_.encryptionkeypair_ = nullptr; + return temp; } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_profilepicture() { +inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::_internal_mutable_encryptionkeypair() { _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.profilepicture_.Mutable(GetArenaForAllocation()); -} -inline std::string* ConfigurationMessage_Contact::release_profilepicture() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.profilePicture) - if (!_internal_has_profilepicture()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.profilepicture_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilepicture_.IsDefault()) { - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + if (_impl_.encryptionkeypair_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::KeyPair>(GetArenaForAllocation()); + _impl_.encryptionkeypair_ = p; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; + return _impl_.encryptionkeypair_; } -inline void ConfigurationMessage_Contact::set_allocated_profilepicture(std::string* profilepicture) { - if (profilepicture != nullptr) { +inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::mutable_encryptionkeypair() { + ::SessionProtos::KeyPair* _msg = _internal_mutable_encryptionkeypair(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + return _msg; +} +inline void ConfigurationMessage_ClosedGroup::set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.encryptionkeypair_; + } + if (encryptionkeypair) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(encryptionkeypair); + if (message_arena != submessage_arena) { + encryptionkeypair = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, encryptionkeypair, submessage_arena); + } _impl_._has_bits_[0] |= 0x00000004u; } else { _impl_._has_bits_[0] &= ~0x00000004u; } - _impl_.profilepicture_.SetAllocated(profilepicture, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilepicture_.IsDefault()) { - _impl_.profilepicture_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.profilePicture) + _impl_.encryptionkeypair_ = encryptionkeypair; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) } -// optional bytes profileKey = 4; -inline bool ConfigurationMessage_Contact::_internal_has_profilekey() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool ConfigurationMessage_Contact::has_profilekey() const { - return _internal_has_profilekey(); -} -inline void ConfigurationMessage_Contact::clear_profilekey() { - _impl_.profilekey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000008u; +// repeated bytes members = 4; +inline int ConfigurationMessage_ClosedGroup::_internal_members_size() const { + return _impl_.members_.size(); } -inline const std::string& ConfigurationMessage_Contact::profilekey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.profileKey) - return _internal_profilekey(); +inline int ConfigurationMessage_ClosedGroup::members_size() const { + return _internal_members_size(); } -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_profilekey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.profileKey) +inline void ConfigurationMessage_ClosedGroup::clear_members() { + _impl_.members_.Clear(); } -inline std::string* ConfigurationMessage_Contact::mutable_profilekey() { - std::string* _s = _internal_mutable_profilekey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.profileKey) +inline std::string* ConfigurationMessage_ClosedGroup::add_members() { + std::string* _s = _internal_add_members(); + // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.members) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_profilekey() const { - return _impl_.profilekey_.Get(); +inline const std::string& ConfigurationMessage_ClosedGroup::_internal_members(int index) const { + return _impl_.members_.Get(index); } -inline void ConfigurationMessage_Contact::_internal_set_profilekey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.profilekey_.Set(value, GetArenaForAllocation()); +inline const std::string& ConfigurationMessage_ClosedGroup::members(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.members) + return _internal_members(index); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_profilekey() { - _impl_._has_bits_[0] |= 0x00000008u; - return _impl_.profilekey_.Mutable(GetArenaForAllocation()); +inline std::string* ConfigurationMessage_ClosedGroup::mutable_members(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.members) + return _impl_.members_.Mutable(index); } -inline std::string* ConfigurationMessage_Contact::release_profilekey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.profileKey) - if (!_internal_has_profilekey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000008u; - auto* p = _impl_.profilekey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; +inline void ConfigurationMessage_ClosedGroup::set_members(int index, const std::string& value) { + _impl_.members_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.members) } -inline void ConfigurationMessage_Contact::set_allocated_profilekey(std::string* profilekey) { - if (profilekey != nullptr) { - _impl_._has_bits_[0] |= 0x00000008u; - } else { - _impl_._has_bits_[0] &= ~0x00000008u; - } - _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.profileKey) +inline void ConfigurationMessage_ClosedGroup::set_members(int index, std::string&& value) { + _impl_.members_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.members) } - -// optional bool isApproved = 5; -inline bool ConfigurationMessage_Contact::_internal_has_isapproved() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - return value; +inline void ConfigurationMessage_ClosedGroup::set_members(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.members_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.ClosedGroup.members) +} +inline void ConfigurationMessage_ClosedGroup::set_members(int index, const void* value, size_t size) { + _impl_.members_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.members) } -inline bool ConfigurationMessage_Contact::has_isapproved() const { - return _internal_has_isapproved(); +inline std::string* ConfigurationMessage_ClosedGroup::_internal_add_members() { + return _impl_.members_.Add(); } -inline void ConfigurationMessage_Contact::clear_isapproved() { - _impl_.isapproved_ = false; - _impl_._has_bits_[0] &= ~0x00000010u; +inline void ConfigurationMessage_ClosedGroup::add_members(const std::string& value) { + _impl_.members_.Add()->assign(value); + // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.members) } -inline bool ConfigurationMessage_Contact::_internal_isapproved() const { - return _impl_.isapproved_; +inline void ConfigurationMessage_ClosedGroup::add_members(std::string&& value) { + _impl_.members_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.members) } -inline bool ConfigurationMessage_Contact::isapproved() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.isApproved) - return _internal_isapproved(); +inline void ConfigurationMessage_ClosedGroup::add_members(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.members_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.ClosedGroup.members) } -inline void ConfigurationMessage_Contact::_internal_set_isapproved(bool value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.isapproved_ = value; +inline void ConfigurationMessage_ClosedGroup::add_members(const void* value, size_t size) { + _impl_.members_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.members) } -inline void ConfigurationMessage_Contact::set_isapproved(bool value) { - _internal_set_isapproved(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.isApproved) +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +ConfigurationMessage_ClosedGroup::members() const { + // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.ClosedGroup.members) + return _impl_.members_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +ConfigurationMessage_ClosedGroup::mutable_members() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.ClosedGroup.members) + return &_impl_.members_; } -// optional bool isBlocked = 6; -inline bool ConfigurationMessage_Contact::_internal_has_isblocked() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; - return value; +// repeated bytes admins = 5; +inline int ConfigurationMessage_ClosedGroup::_internal_admins_size() const { + return _impl_.admins_.size(); } -inline bool ConfigurationMessage_Contact::has_isblocked() const { - return _internal_has_isblocked(); +inline int ConfigurationMessage_ClosedGroup::admins_size() const { + return _internal_admins_size(); } -inline void ConfigurationMessage_Contact::clear_isblocked() { - _impl_.isblocked_ = false; - _impl_._has_bits_[0] &= ~0x00000020u; +inline void ConfigurationMessage_ClosedGroup::clear_admins() { + _impl_.admins_.Clear(); } -inline bool ConfigurationMessage_Contact::_internal_isblocked() const { - return _impl_.isblocked_; +inline std::string* ConfigurationMessage_ClosedGroup::add_admins() { + std::string* _s = _internal_add_admins(); + // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.admins) + return _s; } -inline bool ConfigurationMessage_Contact::isblocked() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.isBlocked) - return _internal_isblocked(); +inline const std::string& ConfigurationMessage_ClosedGroup::_internal_admins(int index) const { + return _impl_.admins_.Get(index); } -inline void ConfigurationMessage_Contact::_internal_set_isblocked(bool value) { - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.isblocked_ = value; +inline const std::string& ConfigurationMessage_ClosedGroup::admins(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.admins) + return _internal_admins(index); } -inline void ConfigurationMessage_Contact::set_isblocked(bool value) { - _internal_set_isblocked(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.isBlocked) +inline std::string* ConfigurationMessage_ClosedGroup::mutable_admins(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.admins) + return _impl_.admins_.Mutable(index); } - -// optional bool didApproveMe = 7; -inline bool ConfigurationMessage_Contact::_internal_has_didapproveme() const { - bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; - return value; +inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const std::string& value) { + _impl_.admins_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.admins) } -inline bool ConfigurationMessage_Contact::has_didapproveme() const { - return _internal_has_didapproveme(); +inline void ConfigurationMessage_ClosedGroup::set_admins(int index, std::string&& value) { + _impl_.admins_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.admins) } -inline void ConfigurationMessage_Contact::clear_didapproveme() { - _impl_.didapproveme_ = false; - _impl_._has_bits_[0] &= ~0x00000040u; +inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.admins_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.ClosedGroup.admins) } -inline bool ConfigurationMessage_Contact::_internal_didapproveme() const { - return _impl_.didapproveme_; +inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const void* value, size_t size) { + _impl_.admins_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.admins) } -inline bool ConfigurationMessage_Contact::didapproveme() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.didApproveMe) - return _internal_didapproveme(); +inline std::string* ConfigurationMessage_ClosedGroup::_internal_add_admins() { + return _impl_.admins_.Add(); } -inline void ConfigurationMessage_Contact::_internal_set_didapproveme(bool value) { - _impl_._has_bits_[0] |= 0x00000040u; - _impl_.didapproveme_ = value; +inline void ConfigurationMessage_ClosedGroup::add_admins(const std::string& value) { + _impl_.admins_.Add()->assign(value); + // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.admins) } -inline void ConfigurationMessage_Contact::set_didapproveme(bool value) { - _internal_set_didapproveme(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.didApproveMe) +inline void ConfigurationMessage_ClosedGroup::add_admins(std::string&& value) { + _impl_.admins_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +} +inline void ConfigurationMessage_ClosedGroup::add_admins(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.admins_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +} +inline void ConfigurationMessage_ClosedGroup::add_admins(const void* value, size_t size) { + _impl_.admins_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +ConfigurationMessage_ClosedGroup::admins() const { + // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.ClosedGroup.admins) + return _impl_.admins_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +ConfigurationMessage_ClosedGroup::mutable_admins() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.ClosedGroup.admins) + return &_impl_.admins_; } -// ------------------------------------------------------------------- - -// ConfigurationMessage_ProProof - -// required uint32 version = 1; -inline bool ConfigurationMessage_ProProof::_internal_has_version() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; +// optional uint32 expirationTimer = 6; +inline bool ConfigurationMessage_ClosedGroup::_internal_has_expirationtimer() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } -inline bool ConfigurationMessage_ProProof::has_version() const { - return _internal_has_version(); +inline bool ConfigurationMessage_ClosedGroup::has_expirationtimer() const { + return _internal_has_expirationtimer(); } -inline void ConfigurationMessage_ProProof::clear_version() { - _impl_.version_ = 0u; - _impl_._has_bits_[0] &= ~0x00000010u; +inline void ConfigurationMessage_ClosedGroup::clear_expirationtimer() { + _impl_.expirationtimer_ = 0u; + _impl_._has_bits_[0] &= ~0x00000008u; } -inline uint32_t ConfigurationMessage_ProProof::_internal_version() const { - return _impl_.version_; +inline uint32_t ConfigurationMessage_ClosedGroup::_internal_expirationtimer() const { + return _impl_.expirationtimer_; } -inline uint32_t ConfigurationMessage_ProProof::version() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.version) - return _internal_version(); +inline uint32_t ConfigurationMessage_ClosedGroup::expirationtimer() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.expirationTimer) + return _internal_expirationtimer(); } -inline void ConfigurationMessage_ProProof::_internal_set_version(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.version_ = value; +inline void ConfigurationMessage_ClosedGroup::_internal_set_expirationtimer(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.expirationtimer_ = value; } -inline void ConfigurationMessage_ProProof::set_version(uint32_t value) { - _internal_set_version(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.version) +inline void ConfigurationMessage_ClosedGroup::set_expirationtimer(uint32_t value) { + _internal_set_expirationtimer(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.expirationTimer) } -// required bytes genIndexHash = 2; -inline bool ConfigurationMessage_ProProof::_internal_has_genindexhash() const { +// ------------------------------------------------------------------- + +// ConfigurationMessage_Contact + +// required bytes publicKey = 1; +inline bool ConfigurationMessage_Contact::_internal_has_publickey() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool ConfigurationMessage_ProProof::has_genindexhash() const { - return _internal_has_genindexhash(); +inline bool ConfigurationMessage_Contact::has_publickey() const { + return _internal_has_publickey(); } -inline void ConfigurationMessage_ProProof::clear_genindexhash() { - _impl_.genindexhash_.ClearToEmpty(); +inline void ConfigurationMessage_Contact::clear_publickey() { + _impl_.publickey_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& ConfigurationMessage_ProProof::genindexhash() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) - return _internal_genindexhash(); +inline const std::string& ConfigurationMessage_Contact::publickey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.publicKey) + return _internal_publickey(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ProProof::set_genindexhash(ArgT0&& arg0, ArgT... args) { +void ConfigurationMessage_Contact::set_publickey(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.genindexhash_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) + _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.publicKey) } -inline std::string* ConfigurationMessage_ProProof::mutable_genindexhash() { - std::string* _s = _internal_mutable_genindexhash(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) +inline std::string* ConfigurationMessage_Contact::mutable_publickey() { + std::string* _s = _internal_mutable_publickey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.publicKey) return _s; } -inline const std::string& ConfigurationMessage_ProProof::_internal_genindexhash() const { - return _impl_.genindexhash_.Get(); +inline const std::string& ConfigurationMessage_Contact::_internal_publickey() const { + return _impl_.publickey_.Get(); } -inline void ConfigurationMessage_ProProof::_internal_set_genindexhash(const std::string& value) { +inline void ConfigurationMessage_Contact::_internal_set_publickey(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.genindexhash_.Set(value, GetArenaForAllocation()); + _impl_.publickey_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_ProProof::_internal_mutable_genindexhash() { +inline std::string* ConfigurationMessage_Contact::_internal_mutable_publickey() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.genindexhash_.Mutable(GetArenaForAllocation()); + return _impl_.publickey_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_ProProof::release_genindexhash() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) - if (!_internal_has_genindexhash()) { +inline std::string* ConfigurationMessage_Contact::release_publickey() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.publicKey) + if (!_internal_has_publickey()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.genindexhash_.Release(); + auto* p = _impl_.publickey_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.genindexhash_.IsDefault()) { - _impl_.genindexhash_.Set("", GetArenaForAllocation()); + if (_impl_.publickey_.IsDefault()) { + _impl_.publickey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_ProProof::set_allocated_genindexhash(std::string* genindexhash) { - if (genindexhash != nullptr) { +inline void ConfigurationMessage_Contact::set_allocated_publickey(std::string* publickey) { + if (publickey != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.genindexhash_.SetAllocated(genindexhash, GetArenaForAllocation()); + _impl_.publickey_.SetAllocated(publickey, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.genindexhash_.IsDefault()) { - _impl_.genindexhash_.Set("", GetArenaForAllocation()); + if (_impl_.publickey_.IsDefault()) { + _impl_.publickey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ProProof.genIndexHash) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.publicKey) } -// required bytes rotatingPublicKey = 3; -inline bool ConfigurationMessage_ProProof::_internal_has_rotatingpublickey() const { +// required string name = 2; +inline bool ConfigurationMessage_Contact::_internal_has_name() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool ConfigurationMessage_ProProof::has_rotatingpublickey() const { - return _internal_has_rotatingpublickey(); +inline bool ConfigurationMessage_Contact::has_name() const { + return _internal_has_name(); } -inline void ConfigurationMessage_ProProof::clear_rotatingpublickey() { - _impl_.rotatingpublickey_.ClearToEmpty(); +inline void ConfigurationMessage_Contact::clear_name() { + _impl_.name_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const std::string& ConfigurationMessage_ProProof::rotatingpublickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) - return _internal_rotatingpublickey(); +inline const std::string& ConfigurationMessage_Contact::name() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.name) + return _internal_name(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ProProof::set_rotatingpublickey(ArgT0&& arg0, ArgT... args) { +void ConfigurationMessage_Contact::set_name(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.rotatingpublickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) + _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.name) } -inline std::string* ConfigurationMessage_ProProof::mutable_rotatingpublickey() { - std::string* _s = _internal_mutable_rotatingpublickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) +inline std::string* ConfigurationMessage_Contact::mutable_name() { + std::string* _s = _internal_mutable_name(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.name) return _s; } -inline const std::string& ConfigurationMessage_ProProof::_internal_rotatingpublickey() const { - return _impl_.rotatingpublickey_.Get(); +inline const std::string& ConfigurationMessage_Contact::_internal_name() const { + return _impl_.name_.Get(); } -inline void ConfigurationMessage_ProProof::_internal_set_rotatingpublickey(const std::string& value) { +inline void ConfigurationMessage_Contact::_internal_set_name(const std::string& value) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.rotatingpublickey_.Set(value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_ProProof::_internal_mutable_rotatingpublickey() { +inline std::string* ConfigurationMessage_Contact::_internal_mutable_name() { _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.rotatingpublickey_.Mutable(GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_ProProof::release_rotatingpublickey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) - if (!_internal_has_rotatingpublickey()) { +inline std::string* ConfigurationMessage_Contact::release_name() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.name) + if (!_internal_has_name()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.rotatingpublickey_.Release(); + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingpublickey_.IsDefault()) { - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_ProProof::set_allocated_rotatingpublickey(std::string* rotatingpublickey) { - if (rotatingpublickey != nullptr) { +inline void ConfigurationMessage_Contact::set_allocated_name(std::string* name) { + if (name != nullptr) { _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.rotatingpublickey_.SetAllocated(rotatingpublickey, GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingpublickey_.IsDefault()) { - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ProProof.rotatingPublicKey) -} - -// required uint64 expiryUnixTs = 4; -inline bool ConfigurationMessage_ProProof::_internal_has_expiryunixts() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool ConfigurationMessage_ProProof::has_expiryunixts() const { - return _internal_has_expiryunixts(); -} -inline void ConfigurationMessage_ProProof::clear_expiryunixts() { - _impl_.expiryunixts_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000008u; -} -inline uint64_t ConfigurationMessage_ProProof::_internal_expiryunixts() const { - return _impl_.expiryunixts_; -} -inline uint64_t ConfigurationMessage_ProProof::expiryunixts() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.expiryUnixTs) - return _internal_expiryunixts(); -} -inline void ConfigurationMessage_ProProof::_internal_set_expiryunixts(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.expiryunixts_ = value; -} -inline void ConfigurationMessage_ProProof::set_expiryunixts(uint64_t value) { - _internal_set_expiryunixts(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.expiryUnixTs) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.name) } -// required bytes sig = 5; -inline bool ConfigurationMessage_ProProof::_internal_has_sig() const { +// optional string profilePicture = 3; +inline bool ConfigurationMessage_Contact::_internal_has_profilepicture() const { bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool ConfigurationMessage_ProProof::has_sig() const { - return _internal_has_sig(); +inline bool ConfigurationMessage_Contact::has_profilepicture() const { + return _internal_has_profilepicture(); } -inline void ConfigurationMessage_ProProof::clear_sig() { - _impl_.sig_.ClearToEmpty(); +inline void ConfigurationMessage_Contact::clear_profilepicture() { + _impl_.profilepicture_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000004u; } -inline const std::string& ConfigurationMessage_ProProof::sig() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ProProof.sig) - return _internal_sig(); +inline const std::string& ConfigurationMessage_Contact::profilepicture() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.profilePicture) + return _internal_profilepicture(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ProProof::set_sig(ArgT0&& arg0, ArgT... args) { +void ConfigurationMessage_Contact::set_profilepicture(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000004u; - _impl_.sig_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ProProof.sig) + _impl_.profilepicture_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.profilePicture) } -inline std::string* ConfigurationMessage_ProProof::mutable_sig() { - std::string* _s = _internal_mutable_sig(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ProProof.sig) +inline std::string* ConfigurationMessage_Contact::mutable_profilepicture() { + std::string* _s = _internal_mutable_profilepicture(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.profilePicture) return _s; } -inline const std::string& ConfigurationMessage_ProProof::_internal_sig() const { - return _impl_.sig_.Get(); +inline const std::string& ConfigurationMessage_Contact::_internal_profilepicture() const { + return _impl_.profilepicture_.Get(); } -inline void ConfigurationMessage_ProProof::_internal_set_sig(const std::string& value) { +inline void ConfigurationMessage_Contact::_internal_set_profilepicture(const std::string& value) { _impl_._has_bits_[0] |= 0x00000004u; - _impl_.sig_.Set(value, GetArenaForAllocation()); + _impl_.profilepicture_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_ProProof::_internal_mutable_sig() { +inline std::string* ConfigurationMessage_Contact::_internal_mutable_profilepicture() { _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.sig_.Mutable(GetArenaForAllocation()); + return _impl_.profilepicture_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_ProProof::release_sig() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ProProof.sig) - if (!_internal_has_sig()) { +inline std::string* ConfigurationMessage_Contact::release_profilepicture() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.profilePicture) + if (!_internal_has_profilepicture()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.sig_.Release(); + auto* p = _impl_.profilepicture_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.sig_.IsDefault()) { - _impl_.sig_.Set("", GetArenaForAllocation()); + if (_impl_.profilepicture_.IsDefault()) { + _impl_.profilepicture_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_ProProof::set_allocated_sig(std::string* sig) { - if (sig != nullptr) { +inline void ConfigurationMessage_Contact::set_allocated_profilepicture(std::string* profilepicture) { + if (profilepicture != nullptr) { _impl_._has_bits_[0] |= 0x00000004u; } else { _impl_._has_bits_[0] &= ~0x00000004u; } - _impl_.sig_.SetAllocated(sig, GetArenaForAllocation()); + _impl_.profilepicture_.SetAllocated(profilepicture, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.sig_.IsDefault()) { - _impl_.sig_.Set("", GetArenaForAllocation()); + if (_impl_.profilepicture_.IsDefault()) { + _impl_.profilepicture_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ProProof.sig) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.profilePicture) } -// ------------------------------------------------------------------- - -// ConfigurationMessage_Pro - -// required bytes rotatingPrivKey = 1; -inline bool ConfigurationMessage_Pro::_internal_has_rotatingprivkey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; +// optional bytes profileKey = 4; +inline bool ConfigurationMessage_Contact::_internal_has_profilekey() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } -inline bool ConfigurationMessage_Pro::has_rotatingprivkey() const { - return _internal_has_rotatingprivkey(); +inline bool ConfigurationMessage_Contact::has_profilekey() const { + return _internal_has_profilekey(); } -inline void ConfigurationMessage_Pro::clear_rotatingprivkey() { - _impl_.rotatingprivkey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; +inline void ConfigurationMessage_Contact::clear_profilekey() { + _impl_.profilekey_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000008u; } -inline const std::string& ConfigurationMessage_Pro::rotatingprivkey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) - return _internal_rotatingprivkey(); +inline const std::string& ConfigurationMessage_Contact::profilekey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.profileKey) + return _internal_profilekey(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Pro::set_rotatingprivkey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.rotatingprivkey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) +void ConfigurationMessage_Contact::set_profilekey(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.profileKey) } -inline std::string* ConfigurationMessage_Pro::mutable_rotatingprivkey() { - std::string* _s = _internal_mutable_rotatingprivkey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) +inline std::string* ConfigurationMessage_Contact::mutable_profilekey() { + std::string* _s = _internal_mutable_profilekey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.profileKey) return _s; } -inline const std::string& ConfigurationMessage_Pro::_internal_rotatingprivkey() const { - return _impl_.rotatingprivkey_.Get(); +inline const std::string& ConfigurationMessage_Contact::_internal_profilekey() const { + return _impl_.profilekey_.Get(); } -inline void ConfigurationMessage_Pro::_internal_set_rotatingprivkey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.rotatingprivkey_.Set(value, GetArenaForAllocation()); +inline void ConfigurationMessage_Contact::_internal_set_profilekey(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.profilekey_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Pro::_internal_mutable_rotatingprivkey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.rotatingprivkey_.Mutable(GetArenaForAllocation()); +inline std::string* ConfigurationMessage_Contact::_internal_mutable_profilekey() { + _impl_._has_bits_[0] |= 0x00000008u; + return _impl_.profilekey_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Pro::release_rotatingprivkey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) - if (!_internal_has_rotatingprivkey()) { +inline std::string* ConfigurationMessage_Contact::release_profilekey() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.profileKey) + if (!_internal_has_profilekey()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.rotatingprivkey_.Release(); + _impl_._has_bits_[0] &= ~0x00000008u; + auto* p = _impl_.profilekey_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingprivkey_.IsDefault()) { - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + if (_impl_.profilekey_.IsDefault()) { + _impl_.profilekey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Pro::set_allocated_rotatingprivkey(std::string* rotatingprivkey) { - if (rotatingprivkey != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; +inline void ConfigurationMessage_Contact::set_allocated_profilekey(std::string* profilekey) { + if (profilekey != nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000008u; } - _impl_.rotatingprivkey_.SetAllocated(rotatingprivkey, GetArenaForAllocation()); + _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingprivkey_.IsDefault()) { - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + if (_impl_.profilekey_.IsDefault()) { + _impl_.profilekey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Pro.rotatingPrivKey) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.profileKey) } -// required bytes proof = 2; -inline bool ConfigurationMessage_Pro::_internal_has_proof() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; +// optional bool isApproved = 5; +inline bool ConfigurationMessage_Contact::_internal_has_isapproved() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } -inline bool ConfigurationMessage_Pro::has_proof() const { - return _internal_has_proof(); +inline bool ConfigurationMessage_Contact::has_isapproved() const { + return _internal_has_isapproved(); } -inline void ConfigurationMessage_Pro::clear_proof() { - _impl_.proof_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; +inline void ConfigurationMessage_Contact::clear_isapproved() { + _impl_.isapproved_ = false; + _impl_._has_bits_[0] &= ~0x00000010u; } -inline const std::string& ConfigurationMessage_Pro::proof() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Pro.proof) - return _internal_proof(); +inline bool ConfigurationMessage_Contact::_internal_isapproved() const { + return _impl_.isapproved_; } -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Pro::set_proof(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.proof_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Pro.proof) +inline bool ConfigurationMessage_Contact::isapproved() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.isApproved) + return _internal_isapproved(); } -inline std::string* ConfigurationMessage_Pro::mutable_proof() { - std::string* _s = _internal_mutable_proof(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Pro.proof) - return _s; +inline void ConfigurationMessage_Contact::_internal_set_isapproved(bool value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.isapproved_ = value; } -inline const std::string& ConfigurationMessage_Pro::_internal_proof() const { - return _impl_.proof_.Get(); +inline void ConfigurationMessage_Contact::set_isapproved(bool value) { + _internal_set_isapproved(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.isApproved) } -inline void ConfigurationMessage_Pro::_internal_set_proof(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.proof_.Set(value, GetArenaForAllocation()); + +// optional bool isBlocked = 6; +inline bool ConfigurationMessage_Contact::_internal_has_isblocked() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + return value; } -inline std::string* ConfigurationMessage_Pro::_internal_mutable_proof() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.proof_.Mutable(GetArenaForAllocation()); +inline bool ConfigurationMessage_Contact::has_isblocked() const { + return _internal_has_isblocked(); } -inline std::string* ConfigurationMessage_Pro::release_proof() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Pro.proof) - if (!_internal_has_proof()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.proof_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.proof_.IsDefault()) { - _impl_.proof_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; +inline void ConfigurationMessage_Contact::clear_isblocked() { + _impl_.isblocked_ = false; + _impl_._has_bits_[0] &= ~0x00000020u; } -inline void ConfigurationMessage_Pro::set_allocated_proof(std::string* proof) { - if (proof != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.proof_.SetAllocated(proof, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.proof_.IsDefault()) { - _impl_.proof_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Pro.proof) +inline bool ConfigurationMessage_Contact::_internal_isblocked() const { + return _impl_.isblocked_; +} +inline bool ConfigurationMessage_Contact::isblocked() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.isBlocked) + return _internal_isblocked(); +} +inline void ConfigurationMessage_Contact::_internal_set_isblocked(bool value) { + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.isblocked_ = value; +} +inline void ConfigurationMessage_Contact::set_isblocked(bool value) { + _internal_set_isblocked(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.isBlocked) +} + +// optional bool didApproveMe = 7; +inline bool ConfigurationMessage_Contact::_internal_has_didapproveme() const { + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + return value; +} +inline bool ConfigurationMessage_Contact::has_didapproveme() const { + return _internal_has_didapproveme(); +} +inline void ConfigurationMessage_Contact::clear_didapproveme() { + _impl_.didapproveme_ = false; + _impl_._has_bits_[0] &= ~0x00000040u; +} +inline bool ConfigurationMessage_Contact::_internal_didapproveme() const { + return _impl_.didapproveme_; +} +inline bool ConfigurationMessage_Contact::didapproveme() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.didApproveMe) + return _internal_didapproveme(); +} +inline void ConfigurationMessage_Contact::_internal_set_didapproveme(bool value) { + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.didapproveme_ = value; +} +inline void ConfigurationMessage_Contact::set_didapproveme(bool value) { + _internal_set_didapproveme(value); + // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.didApproveMe) } // ------------------------------------------------------------------- @@ -12230,45 +12651,45 @@ ConfigurationMessage::contacts() const { return _impl_.contacts_; } -// optional .SessionProtos.ConfigurationMessage.Pro pro = 7; -inline bool ConfigurationMessage::_internal_has_pro() const { +// optional .SessionProtos.ProConfig proConfig = 7; +inline bool ConfigurationMessage::_internal_has_proconfig() const { bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || _impl_.pro_ != nullptr); + PROTOBUF_ASSUME(!value || _impl_.proconfig_ != nullptr); return value; } -inline bool ConfigurationMessage::has_pro() const { - return _internal_has_pro(); +inline bool ConfigurationMessage::has_proconfig() const { + return _internal_has_proconfig(); } -inline void ConfigurationMessage::clear_pro() { - if (_impl_.pro_ != nullptr) _impl_.pro_->Clear(); +inline void ConfigurationMessage::clear_proconfig() { + if (_impl_.proconfig_ != nullptr) _impl_.proconfig_->Clear(); _impl_._has_bits_[0] &= ~0x00000008u; } -inline const ::SessionProtos::ConfigurationMessage_Pro& ConfigurationMessage::_internal_pro() const { - const ::SessionProtos::ConfigurationMessage_Pro* p = _impl_.pro_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ConfigurationMessage_Pro_default_instance_); +inline const ::SessionProtos::ProConfig& ConfigurationMessage::_internal_proconfig() const { + const ::SessionProtos::ProConfig* p = _impl_.proconfig_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProConfig_default_instance_); } -inline const ::SessionProtos::ConfigurationMessage_Pro& ConfigurationMessage::pro() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.pro) - return _internal_pro(); +inline const ::SessionProtos::ProConfig& ConfigurationMessage::proconfig() const { + // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.proConfig) + return _internal_proconfig(); } -inline void ConfigurationMessage::unsafe_arena_set_allocated_pro( - ::SessionProtos::ConfigurationMessage_Pro* pro) { +inline void ConfigurationMessage::unsafe_arena_set_allocated_proconfig( + ::SessionProtos::ProConfig* proconfig) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.pro_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proconfig_); } - _impl_.pro_ = pro; - if (pro) { + _impl_.proconfig_ = proconfig; + if (proconfig) { _impl_._has_bits_[0] |= 0x00000008u; } else { _impl_._has_bits_[0] &= ~0x00000008u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.pro) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.proConfig) } -inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::release_pro() { +inline ::SessionProtos::ProConfig* ConfigurationMessage::release_proconfig() { _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::ConfigurationMessage_Pro* temp = _impl_.pro_; - _impl_.pro_ = nullptr; + ::SessionProtos::ProConfig* temp = _impl_.proconfig_; + _impl_.proconfig_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -12280,44 +12701,44 @@ inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::release_ #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::unsafe_arena_release_pro() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.pro) +inline ::SessionProtos::ProConfig* ConfigurationMessage::unsafe_arena_release_proconfig() { + // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.proConfig) _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::ConfigurationMessage_Pro* temp = _impl_.pro_; - _impl_.pro_ = nullptr; + ::SessionProtos::ProConfig* temp = _impl_.proconfig_; + _impl_.proconfig_ = nullptr; return temp; } -inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::_internal_mutable_pro() { +inline ::SessionProtos::ProConfig* ConfigurationMessage::_internal_mutable_proconfig() { _impl_._has_bits_[0] |= 0x00000008u; - if (_impl_.pro_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Pro>(GetArenaForAllocation()); - _impl_.pro_ = p; + if (_impl_.proconfig_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProConfig>(GetArenaForAllocation()); + _impl_.proconfig_ = p; } - return _impl_.pro_; + return _impl_.proconfig_; } -inline ::SessionProtos::ConfigurationMessage_Pro* ConfigurationMessage::mutable_pro() { - ::SessionProtos::ConfigurationMessage_Pro* _msg = _internal_mutable_pro(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.pro) +inline ::SessionProtos::ProConfig* ConfigurationMessage::mutable_proconfig() { + ::SessionProtos::ProConfig* _msg = _internal_mutable_proconfig(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.proConfig) return _msg; } -inline void ConfigurationMessage::set_allocated_pro(::SessionProtos::ConfigurationMessage_Pro* pro) { +inline void ConfigurationMessage::set_allocated_proconfig(::SessionProtos::ProConfig* proconfig) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.pro_; + delete _impl_.proconfig_; } - if (pro) { + if (proconfig) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(pro); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proconfig); if (message_arena != submessage_arena) { - pro = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, pro, submessage_arena); + proconfig = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, proconfig, submessage_arena); } _impl_._has_bits_[0] |= 0x00000008u; } else { _impl_._has_bits_[0] &= ~0x00000008u; } - _impl_.pro_ = pro; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.pro) + _impl_.proconfig_ = proconfig; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.proConfig) } // ------------------------------------------------------------------- @@ -13200,6 +13621,8 @@ inline void SharedConfigMessage::set_allocated_data(std::string* data) { // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index cdac33c4..f1ab2da7 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -50,6 +50,23 @@ message MessageRequestResponse { optional LokiProfile profile = 3; } +message ProProof { + required uint32 version = 1; + required bytes genIndexHash = 2; + required bytes rotatingPublicKey = 3; + required uint64 expiryUnixTs = 4; + required bytes sig = 5; +} + +message ProConfig { + required bytes rotatingPrivKey = 1; + required ProProof proof = 2; +} +message ProMessageConfig { + required ProProof proof = 1; + required uint32 flags = 2; +} + message Content { optional DataMessage dataMessage = 1; optional CallMessage callMessage = 3; @@ -60,6 +77,7 @@ message Content { optional UnsendRequest unsendRequest = 9; optional MessageRequestResponse messageRequestResponse = 10; optional SharedConfigMessage sharedConfigMessage = 11; + optional ProMessageConfig proMessageConfig = 12; } message CallMessage { @@ -234,26 +252,13 @@ message ConfigurationMessage { optional bool didApproveMe = 7; // added for msg requests } - message ProProof { - required uint32 version = 1; - required bytes genIndexHash = 2; - required bytes rotatingPublicKey = 3; - required uint64 expiryUnixTs = 4; - required bytes sig = 5; - } - - message Pro { - required bytes rotatingPrivKey = 1; - required bytes proof = 2; - } - repeated ClosedGroup closedGroups = 1; repeated string openGroups = 2; optional string displayName = 3; optional string profilePicture = 4; optional bytes profileKey = 5; repeated Contact contacts = 6; - optional Pro pro = 7; + optional ProConfig proConfig = 7; } message ReceiptMessage { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f0a406de..2886d836 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,6 +90,7 @@ target_link_libraries(crypto util PRIVATE libsodium::sodium-internal + libsession::protos ) target_link_libraries(config diff --git a/src/config/pro.cpp b/src/config/pro.cpp index d090f217..72a064ec 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -69,24 +69,24 @@ bool pro_verify_internal( namespace session::config { -static_assert(sizeof(((Pro*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); -static_assert(sizeof(((Proof*)0)->gen_index_hash) == 32); -static_assert(sizeof(((Proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); -static_assert(sizeof(((Proof*)0)->sig) == crypto_sign_ed25519_BYTES); +static_assert(sizeof(((ProConfig*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); +static_assert(sizeof(((ProProof*)0)->gen_index_hash) == 32); +static_assert(sizeof(((ProProof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert(sizeof(((ProProof*)0)->sig) == crypto_sign_ed25519_BYTES); -bool Proof::verify(const array_uc32& verify_pubkey) const { +bool ProProof::verify(const array_uc32& verify_pubkey) const { array_uc32 hash_to_sign = hash(); bool result = proof_verify_internal(hash_to_sign, sig, verify_pubkey); return result; } -array_uc32 Proof::hash() const { +array_uc32 ProProof::hash() const { array_uc32 result = proof_hash_internal( version, gen_index_hash, rotating_pubkey, expiry_unix_ts.time_since_epoch().count()); return result; } -bool Proof::load(const dict& root) { +bool ProProof::load(const dict& root) { std::optional version = maybe_int(root, "v"); std::optional> maybe_gen_index_hash = maybe_vector(root, "g"); std::optional> maybe_rotating_pubkey = maybe_vector(root, "r"); @@ -111,7 +111,7 @@ bool Proof::load(const dict& root) { return true; } -bool Pro::verify(const array_uc32& verify_pubkey) const { +bool ProConfig::verify(const array_uc32& verify_pubkey) const { uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); bool result = pro_verify_internal( rotating_privkey, @@ -124,7 +124,7 @@ bool Pro::verify(const array_uc32& verify_pubkey) const { return result; } -bool Pro::load(const dict& root) { +bool ProConfig::load(const dict& root) { // Get proof fields sitting in 'p' dictionary auto p_it = root.find("p"); if (p_it == root.end()) diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 3e7ffc24..5b3d1486 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -147,21 +147,21 @@ std::chrono::sys_seconds UserProfile::get_profile_updated() const { return std::chrono::sys_seconds{}; } -std::optional UserProfile::get_pro_data() const { - std::optional result = {}; +std::optional UserProfile::get_pro_data() const { + std::optional result = {}; if (const config::dict* s = data["s"].dict(); s) { - Pro pro = {}; + ProConfig pro = {}; if (pro.load(*s)) result = std::move(pro); } return result; } -void UserProfile::set_pro_data(Pro const &pro) { +void UserProfile::set_pro_data(ProConfig const &pro) { auto root = data["s"]; root["r"] = pro.rotating_privkey; - const Proof& pro_proof = pro.proof; + const ProProof& pro_proof = pro.proof; auto proof_dict = root["p"]; proof_dict["v"] = pro_proof.version; proof_dict["g"] = pro_proof.gen_index_hash; diff --git a/src/pro.cpp b/src/pro.cpp index 37ae59b5..f629dc21 100644 --- a/src/pro.cpp +++ b/src/pro.cpp @@ -4,51 +4,14 @@ #include #include -#include +#include #include +#include +#include "SessionProtos.pb.h" namespace session::pro { -constexpr array_uc32 BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static_assert(BACKEND_PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); - -struct add_payment_request { - std::uint8_t version; - array_uc32 master_pkey; - array_uc32 rotating_pkey; - array_uc32 payment_token; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; - -struct get_proof_request { - std::uint8_t version; - array_uc32 master_pkey; - array_uc32 rotating_pkey; - std::chrono::seconds unix_ts_s; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; - -struct master_rotating_sigs { - array_uc64 master_sig; - array_uc64 rotating_sig; -}; - -struct revocation_item { - array_uc32 gen_index_hash; - std::chrono::seconds expiry_unix_ts; -}; - -master_rotating_sigs build_get_proof_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts); -master_rotating_sigs build_add_payment_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); - master_rotating_sigs build_get_proof_sigs( const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts) { // Derive the public keys @@ -144,4 +107,69 @@ std::string add_payment_request::to_json() const { oxenc::to_hex(rotating_sig)); return result; } + +DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( + std::span ed25519_privkey, + std::span ciphertext, + std::chrono::sys_seconds unix_ts) { + DecryptIncomingWithPro result = {}; + std::tie(result.plaintext, result.ed25519_pubkey) = session::decrypt_incoming(ed25519_privkey, ciphertext); + + SessionProtos::Content content = {}; + if (!content.ParseFromArray(result.plaintext.data(), result.plaintext.size())) + throw std::runtime_error{"Parse decrypted message for pro metadata failed"}; + + if (content.has_promessageconfig()) { + const SessionProtos::ProMessageConfig& config = content.promessageconfig(); + if (!config.has_proof()) + throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); + if (!config.has_flags()) + throw std::runtime_error("Parse decrypted message failed, pro config missing flags"); + + const SessionProtos::ProProof& proto_proof = config.proof(); + std::uint32_t proto_flags = config.flags(); + + if ((proto_flags & ~session::pro::FeatureFlag_All) > 0) + throw std::runtime_error("Parse decrypted message failed, pro config specified invalid flags"); + + // Parse the proof from protobufs + session::config::ProProof& proof = result.pro_proof; + // clang-format off + size_t proof_errors = 0; + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); + proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); + proof_errors += !proto_proof.has_expiryunixts(); + proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); + // clang-format on + + if (proof_errors == 0) + throw std::runtime_error("Parse decrypted message failed, pro metadata was malformed"); + + // Fill out result, we have parsed successfully + result.pro_flags = proto_flags; + + std::memcpy( + proof.gen_index_hash.data(), + proto_proof.genindexhash().data(), + proto_proof.genindexhash().size()); + std::memcpy( + proof.rotating_pubkey.data(), + proto_proof.rotatingpublickey().data(), + proto_proof.rotatingpublickey().size()); + proof.expiry_unix_ts = + std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); + std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); + + if (proof.verify(session::pro::BACKEND_PUBKEY)) + result.pro_status = Status::Valid; + + if (result.pro_status == Status::Valid) { + if (unix_ts >= result.pro_proof.expiry_unix_ts) + result.pro_status = Status::Expired; + } + } + return result; +} + } // namespace session::pro diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index bc803974..75d02941 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -16,7 +16,7 @@ TEST_CASE("Pro", "[config][pro]") { } // Setup the Pro data structure - session::config::Pro pro = {}; + session::config::ProConfig pro = {}; { pro.rotating_privkey = rotating_sk; pro.proof.version = 0; @@ -52,7 +52,7 @@ TEST_CASE("Pro", "[config][pro]") { session::config::dict good_dict; { // clang-format off - const session::config::Proof& proof = pro.proof; + const session::config::ProProof& proof = pro.proof; good_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ @@ -65,7 +65,7 @@ TEST_CASE("Pro", "[config][pro]") { }; // clang-format on - session::config::Pro loaded_pro = {}; + session::config::ProConfig loaded_pro = {}; CHECK(loaded_pro.load(good_dict)); CHECK(loaded_pro.rotating_privkey == pro.rotating_privkey); CHECK(loaded_pro.proof.version == pro.proof.version); @@ -83,7 +83,7 @@ TEST_CASE("Pro", "[config][pro]") { broken_sig[0] = ~broken_sig[0]; // Break the sig // clang-format off - const session::config::Proof& proof = pro.proof; + const session::config::ProProof& proof = pro.proof; bad_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ @@ -96,7 +96,7 @@ TEST_CASE("Pro", "[config][pro]") { }; // clang-format on - session::config::Pro loaded_pro = {}; + session::config::ProConfig loaded_pro = {}; CHECK(loaded_pro.load(bad_dict)); CHECK_FALSE(loaded_pro.verify(signing_pk)); } From a0bb38860e4498259bc62bfae4e60c93ef132a4e Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 8 Aug 2025 10:56:48 +1000 Subject: [PATCH 013/171] Update Session protobuf files to session-ios at 084e58f --- proto/SessionProtos.pb.cc | 11562 ++++++++++++++++----------------- proto/SessionProtos.pb.h | 12294 ++++++++++++++++++------------------ proto/SessionProtos.proto | 209 +- 3 files changed, 11795 insertions(+), 12270 deletions(-) diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index c65c09b5..7d80eabf 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -8,7 +8,10 @@ #include #include #include -#include +#include +#include +#include +#include // @@protoc_insertion_point(includes) #include @@ -83,54 +86,6 @@ struct MessageRequestResponseDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageRequestResponseDefaultTypeInternal _MessageRequestResponse_default_instance_; -PROTOBUF_CONSTEXPR ProProof::ProProof( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.genindexhash_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.rotatingpublickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.sig_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.expiryunixts_)*/uint64_t{0u} - , /*decltype(_impl_.version_)*/0u} {} -struct ProProofDefaultTypeInternal { - PROTOBUF_CONSTEXPR ProProofDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ProProofDefaultTypeInternal() {} - union { - ProProof _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProProofDefaultTypeInternal _ProProof_default_instance_; -PROTOBUF_CONSTEXPR ProConfig::ProConfig( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.rotatingprivkey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.proof_)*/nullptr} {} -struct ProConfigDefaultTypeInternal { - PROTOBUF_CONSTEXPR ProConfigDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ProConfigDefaultTypeInternal() {} - union { - ProConfig _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProConfigDefaultTypeInternal _ProConfig_default_instance_; -PROTOBUF_CONSTEXPR ProMessageConfig::ProMessageConfig( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.proof_)*/nullptr - , /*decltype(_impl_.flags_)*/0u} {} -struct ProMessageConfigDefaultTypeInternal { - PROTOBUF_CONSTEXPR ProMessageConfigDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ProMessageConfigDefaultTypeInternal() {} - union { - ProMessageConfig _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProMessageConfigDefaultTypeInternal _ProMessageConfig_default_instance_; PROTOBUF_CONSTEXPR Content::Content( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -139,12 +94,13 @@ PROTOBUF_CONSTEXPR Content::Content( , /*decltype(_impl_.callmessage_)*/nullptr , /*decltype(_impl_.receiptmessage_)*/nullptr , /*decltype(_impl_.typingmessage_)*/nullptr - , /*decltype(_impl_.configurationmessage_)*/nullptr , /*decltype(_impl_.dataextractionnotification_)*/nullptr , /*decltype(_impl_.unsendrequest_)*/nullptr , /*decltype(_impl_.messagerequestresponse_)*/nullptr , /*decltype(_impl_.sharedconfigmessage_)*/nullptr - , /*decltype(_impl_.promessageconfig_)*/nullptr} {} + , /*decltype(_impl_.expirationtype_)*/0 + , /*decltype(_impl_.expirationtimer_)*/0u + , /*decltype(_impl_.sigtimestamp_)*/uint64_t{0u}} {} struct ContentDefaultTypeInternal { PROTOBUF_CONSTEXPR ContentDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -299,42 +255,6 @@ struct DataMessage_OpenGroupInvitationDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DataMessage_OpenGroupInvitationDefaultTypeInternal _DataMessage_OpenGroupInvitation_default_instance_; -PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.publickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.encryptedkeypair_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} -struct DataMessage_ClosedGroupControlMessage_KeyPairWrapperDefaultTypeInternal { - PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage_KeyPairWrapperDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~DataMessage_ClosedGroupControlMessage_KeyPairWrapperDefaultTypeInternal() {} - union { - DataMessage_ClosedGroupControlMessage_KeyPairWrapper _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DataMessage_ClosedGroupControlMessage_KeyPairWrapperDefaultTypeInternal _DataMessage_ClosedGroupControlMessage_KeyPairWrapper_default_instance_; -PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.members_)*/{} - , /*decltype(_impl_.admins_)*/{} - , /*decltype(_impl_.wrappers_)*/{} - , /*decltype(_impl_.publickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.encryptionkeypair_)*/nullptr - , /*decltype(_impl_.expirationtimer_)*/0u - , /*decltype(_impl_.type_)*/1} {} -struct DataMessage_ClosedGroupControlMessageDefaultTypeInternal { - PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessageDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~DataMessage_ClosedGroupControlMessageDefaultTypeInternal() {} - union { - DataMessage_ClosedGroupControlMessage _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DataMessage_ClosedGroupControlMessageDefaultTypeInternal _DataMessage_ClosedGroupControlMessage_default_instance_; PROTOBUF_CONSTEXPR DataMessage::DataMessage( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -348,10 +268,9 @@ PROTOBUF_CONSTEXPR DataMessage::DataMessage( , /*decltype(_impl_.reaction_)*/nullptr , /*decltype(_impl_.profile_)*/nullptr , /*decltype(_impl_.opengroupinvitation_)*/nullptr - , /*decltype(_impl_.closedgroupcontrolmessage_)*/nullptr - , /*decltype(_impl_.flags_)*/0u - , /*decltype(_impl_.expiretimer_)*/0u + , /*decltype(_impl_.groupupdatemessage_)*/nullptr , /*decltype(_impl_.timestamp_)*/uint64_t{0u} + , /*decltype(_impl_.flags_)*/0u , /*decltype(_impl_.blockscommunitymessagerequests_)*/false} {} struct DataMessageDefaultTypeInternal { PROTOBUF_CONSTEXPR DataMessageDefaultTypeInternal() @@ -362,65 +281,6 @@ struct DataMessageDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DataMessageDefaultTypeInternal _DataMessage_default_instance_; -PROTOBUF_CONSTEXPR ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.members_)*/{} - , /*decltype(_impl_.admins_)*/{} - , /*decltype(_impl_.publickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.encryptionkeypair_)*/nullptr - , /*decltype(_impl_.expirationtimer_)*/0u} {} -struct ConfigurationMessage_ClosedGroupDefaultTypeInternal { - PROTOBUF_CONSTEXPR ConfigurationMessage_ClosedGroupDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ConfigurationMessage_ClosedGroupDefaultTypeInternal() {} - union { - ConfigurationMessage_ClosedGroup _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ClosedGroupDefaultTypeInternal _ConfigurationMessage_ClosedGroup_default_instance_; -PROTOBUF_CONSTEXPR ConfigurationMessage_Contact::ConfigurationMessage_Contact( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.publickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.profilepicture_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.profilekey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.isapproved_)*/false - , /*decltype(_impl_.isblocked_)*/false - , /*decltype(_impl_.didapproveme_)*/false} {} -struct ConfigurationMessage_ContactDefaultTypeInternal { - PROTOBUF_CONSTEXPR ConfigurationMessage_ContactDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ConfigurationMessage_ContactDefaultTypeInternal() {} - union { - ConfigurationMessage_Contact _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessage_ContactDefaultTypeInternal _ConfigurationMessage_Contact_default_instance_; -PROTOBUF_CONSTEXPR ConfigurationMessage::ConfigurationMessage( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.closedgroups_)*/{} - , /*decltype(_impl_.opengroups_)*/{} - , /*decltype(_impl_.contacts_)*/{} - , /*decltype(_impl_.displayname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.profilepicture_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.profilekey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.proconfig_)*/nullptr} {} -struct ConfigurationMessageDefaultTypeInternal { - PROTOBUF_CONSTEXPR ConfigurationMessageDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ConfigurationMessageDefaultTypeInternal() {} - union { - ConfigurationMessage _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConfigurationMessageDefaultTypeInternal _ConfigurationMessage_default_instance_; PROTOBUF_CONSTEXPR ReceiptMessage::ReceiptMessage( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -477,8 +337,735 @@ struct SharedConfigMessageDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SharedConfigMessageDefaultTypeInternal _SharedConfigMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateMessage::GroupUpdateMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.invitemessage_)*/nullptr + , /*decltype(_impl_.infochangemessage_)*/nullptr + , /*decltype(_impl_.memberchangemessage_)*/nullptr + , /*decltype(_impl_.promotemessage_)*/nullptr + , /*decltype(_impl_.memberleftmessage_)*/nullptr + , /*decltype(_impl_.inviteresponse_)*/nullptr + , /*decltype(_impl_.deletemembercontent_)*/nullptr + , /*decltype(_impl_.memberleftnotificationmessage_)*/nullptr} {} +struct GroupUpdateMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateMessageDefaultTypeInternal() {} + union { + GroupUpdateMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateMessageDefaultTypeInternal _GroupUpdateMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateInviteMessage::GroupUpdateInviteMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.groupsessionid_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.memberauthdata_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.adminsignature_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} +struct GroupUpdateInviteMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateInviteMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateInviteMessageDefaultTypeInternal() {} + union { + GroupUpdateInviteMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateInviteMessageDefaultTypeInternal _GroupUpdateInviteMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdatePromoteMessage::GroupUpdatePromoteMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.groupidentityseed_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} +struct GroupUpdatePromoteMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdatePromoteMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdatePromoteMessageDefaultTypeInternal() {} + union { + GroupUpdatePromoteMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdatePromoteMessageDefaultTypeInternal _GroupUpdatePromoteMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateInfoChangeMessage::GroupUpdateInfoChangeMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.updatedname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.adminsignature_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.updatedexpiration_)*/0u + , /*decltype(_impl_.type_)*/1} {} +struct GroupUpdateInfoChangeMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateInfoChangeMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateInfoChangeMessageDefaultTypeInternal() {} + union { + GroupUpdateInfoChangeMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateInfoChangeMessageDefaultTypeInternal _GroupUpdateInfoChangeMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateMemberChangeMessage::GroupUpdateMemberChangeMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.membersessionids_)*/{} + , /*decltype(_impl_.adminsignature_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.historyshared_)*/false + , /*decltype(_impl_.type_)*/1} {} +struct GroupUpdateMemberChangeMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateMemberChangeMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateMemberChangeMessageDefaultTypeInternal() {} + union { + GroupUpdateMemberChangeMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateMemberChangeMessageDefaultTypeInternal _GroupUpdateMemberChangeMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateMemberLeftMessage::GroupUpdateMemberLeftMessage( + ::_pbi::ConstantInitialized) {} +struct GroupUpdateMemberLeftMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateMemberLeftMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateMemberLeftMessageDefaultTypeInternal() {} + union { + GroupUpdateMemberLeftMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateMemberLeftMessageDefaultTypeInternal _GroupUpdateMemberLeftMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateMemberLeftNotificationMessage::GroupUpdateMemberLeftNotificationMessage( + ::_pbi::ConstantInitialized) {} +struct GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal() {} + union { + GroupUpdateMemberLeftNotificationMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal _GroupUpdateMemberLeftNotificationMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateInviteResponseMessage::GroupUpdateInviteResponseMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.isapproved_)*/false} {} +struct GroupUpdateInviteResponseMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateInviteResponseMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateInviteResponseMessageDefaultTypeInternal() {} + union { + GroupUpdateInviteResponseMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateInviteResponseMessageDefaultTypeInternal _GroupUpdateInviteResponseMessage_default_instance_; +PROTOBUF_CONSTEXPR GroupUpdateDeleteMemberContentMessage::GroupUpdateDeleteMemberContentMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.membersessionids_)*/{} + , /*decltype(_impl_.messagehashes_)*/{} + , /*decltype(_impl_.adminsignature_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} +struct GroupUpdateDeleteMemberContentMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR GroupUpdateDeleteMemberContentMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~GroupUpdateDeleteMemberContentMessageDefaultTypeInternal() {} + union { + GroupUpdateDeleteMemberContentMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateDeleteMemberContentMessageDefaultTypeInternal _GroupUpdateDeleteMemberContentMessage_default_instance_; } // namespace SessionProtos +static ::_pb::Metadata file_level_metadata_SessionProtos_2eproto[27]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_SessionProtos_2eproto[13]; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_SessionProtos_2eproto = nullptr; + +const uint32_t TableStruct_SessionProtos_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.source_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.sourcedevice_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.timestamp_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.content_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.servertimestamp_), + 5, + 0, + 4, + 2, + 1, + 3, + PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_.timestamp_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_.action_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _impl_.timestamp_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _impl_.author_), + 1, + 0, + PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_.isapproved_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_.profilekey_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_.profile_), + 2, + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.datamessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.callmessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.receiptmessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.typingmessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.dataextractionnotification_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.unsendrequest_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.messagerequestresponse_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.sharedconfigmessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.expirationtype_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.expirationtimer_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.sigtimestamp_), + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.sdps_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.sdpmlineindexes_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.sdpmids_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.uuid_), + 1, + ~0u, + ~0u, + ~0u, + 0, + PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _impl_.publickey_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _impl_.privatekey_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _impl_.timestamp_), + 1, + 0, + PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _impl_.displayname_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _impl_.profilepicture_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.contenttype_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.filename_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.thumbnail_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.flags_), + 0, + 1, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.id_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.author_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.text_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.attachments_), + 2, + 0, + 1, + ~0u, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_.url_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_.title_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_.image_), + 0, + 1, + 2, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.id_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.author_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.emoji_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.action_), + 2, + 0, + 1, + 3, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _impl_.url_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _impl_.name_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.body_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.attachments_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.flags_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.profilekey_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.timestamp_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.quote_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.preview_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.reaction_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.profile_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.opengroupinvitation_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.synctarget_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.blockscommunitymessagerequests_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.groupupdatemessage_), + 0, + ~0u, + 9, + 1, + 8, + 3, + ~0u, + 4, + 5, + 6, + 2, + 10, + 7, + PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _impl_.timestamp_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.id_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.contenttype_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.key_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.size_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.thumbnail_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.digest_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.filename_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.flags_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.width_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.height_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.caption_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.url_), + 7, + 0, + 1, + 8, + 2, + 3, + 4, + 9, + 10, + 11, + 5, + 6, + PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_.kind_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_.seqno_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_.data_), + 2, + 1, + 0, + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.invitemessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.infochangemessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.memberchangemessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.promotemessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.memberleftmessage_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.inviteresponse_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.deletemembercontent_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.memberleftnotificationmessage_), + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.groupsessionid_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.memberauthdata_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.adminsignature_), + 0, + 1, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _impl_.groupidentityseed_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _impl_.name_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.updatedname_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.updatedexpiration_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.adminsignature_), + 3, + 0, + 2, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.membersessionids_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.historyshared_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.adminsignature_), + 2, + ~0u, + 1, + 0, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberLeftMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberLeftNotificationMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteResponseMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteResponseMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteResponseMessage, _impl_.isapproved_), + 0, + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_.membersessionids_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_.messagehashes_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_.adminsignature_), + ~0u, + ~0u, + 0, +}; +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 12, -1, sizeof(::SessionProtos::Envelope)}, + { 18, 26, -1, sizeof(::SessionProtos::TypingMessage)}, + { 28, 36, -1, sizeof(::SessionProtos::UnsendRequest)}, + { 38, 47, -1, sizeof(::SessionProtos::MessageRequestResponse)}, + { 50, 67, -1, sizeof(::SessionProtos::Content)}, + { 78, 89, -1, sizeof(::SessionProtos::CallMessage)}, + { 94, 102, -1, sizeof(::SessionProtos::KeyPair)}, + { 104, 112, -1, sizeof(::SessionProtos::DataExtractionNotification)}, + { 114, 122, -1, sizeof(::SessionProtos::LokiProfile)}, + { 124, 134, -1, sizeof(::SessionProtos::DataMessage_Quote_QuotedAttachment)}, + { 138, 148, -1, sizeof(::SessionProtos::DataMessage_Quote)}, + { 152, 161, -1, sizeof(::SessionProtos::DataMessage_Preview)}, + { 164, 174, -1, sizeof(::SessionProtos::DataMessage_Reaction)}, + { 178, 186, -1, sizeof(::SessionProtos::DataMessage_OpenGroupInvitation)}, + { 188, 207, -1, sizeof(::SessionProtos::DataMessage)}, + { 220, 228, -1, sizeof(::SessionProtos::ReceiptMessage)}, + { 230, 248, -1, sizeof(::SessionProtos::AttachmentPointer)}, + { 260, 269, -1, sizeof(::SessionProtos::SharedConfigMessage)}, + { 272, 286, -1, sizeof(::SessionProtos::GroupUpdateMessage)}, + { 294, 304, -1, sizeof(::SessionProtos::GroupUpdateInviteMessage)}, + { 308, 316, -1, sizeof(::SessionProtos::GroupUpdatePromoteMessage)}, + { 318, 328, -1, sizeof(::SessionProtos::GroupUpdateInfoChangeMessage)}, + { 332, 342, -1, sizeof(::SessionProtos::GroupUpdateMemberChangeMessage)}, + { 346, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftMessage)}, + { 352, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftNotificationMessage)}, + { 358, 365, -1, sizeof(::SessionProtos::GroupUpdateInviteResponseMessage)}, + { 366, 375, -1, sizeof(::SessionProtos::GroupUpdateDeleteMemberContentMessage)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::SessionProtos::_Envelope_default_instance_._instance, + &::SessionProtos::_TypingMessage_default_instance_._instance, + &::SessionProtos::_UnsendRequest_default_instance_._instance, + &::SessionProtos::_MessageRequestResponse_default_instance_._instance, + &::SessionProtos::_Content_default_instance_._instance, + &::SessionProtos::_CallMessage_default_instance_._instance, + &::SessionProtos::_KeyPair_default_instance_._instance, + &::SessionProtos::_DataExtractionNotification_default_instance_._instance, + &::SessionProtos::_LokiProfile_default_instance_._instance, + &::SessionProtos::_DataMessage_Quote_QuotedAttachment_default_instance_._instance, + &::SessionProtos::_DataMessage_Quote_default_instance_._instance, + &::SessionProtos::_DataMessage_Preview_default_instance_._instance, + &::SessionProtos::_DataMessage_Reaction_default_instance_._instance, + &::SessionProtos::_DataMessage_OpenGroupInvitation_default_instance_._instance, + &::SessionProtos::_DataMessage_default_instance_._instance, + &::SessionProtos::_ReceiptMessage_default_instance_._instance, + &::SessionProtos::_AttachmentPointer_default_instance_._instance, + &::SessionProtos::_SharedConfigMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateInviteMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdatePromoteMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateInfoChangeMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateMemberChangeMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateMemberLeftMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateMemberLeftNotificationMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateInviteResponseMessage_default_instance_._instance, + &::SessionProtos::_GroupUpdateDeleteMemberContentMessage_default_instance_._instance, +}; + +const char descriptor_table_protodef_SessionProtos_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\023SessionProtos.proto\022\rSessionProtos\"\320\001\n" + "\010Envelope\022*\n\004type\030\001 \002(\0162\034.SessionProtos." + "Envelope.Type\022\016\n\006source\030\002 \001(\t\022\024\n\014sourceD" + "evice\030\007 \001(\r\022\021\n\ttimestamp\030\005 \002(\004\022\017\n\007conten" + "t\030\010 \001(\014\022\027\n\017serverTimestamp\030\n \001(\004\"5\n\004Type" + "\022\023\n\017SESSION_MESSAGE\020\006\022\030\n\024CLOSED_GROUP_ME" + "SSAGE\020\007\"{\n\rTypingMessage\022\021\n\ttimestamp\030\001 " + "\002(\004\0223\n\006action\030\002 \002(\0162#.SessionProtos.Typi" + "ngMessage.Action\"\"\n\006Action\022\013\n\007STARTED\020\000\022" + "\013\n\007STOPPED\020\001\"2\n\rUnsendRequest\022\021\n\ttimesta" + "mp\030\001 \002(\004\022\016\n\006author\030\002 \002(\t\"m\n\026MessageReque" + "stResponse\022\022\n\nisApproved\030\001 \002(\010\022\022\n\nprofil" + "eKey\030\002 \001(\014\022+\n\007profile\030\003 \001(\0132\032.SessionPro" + "tos.LokiProfile\"\236\005\n\007Content\022/\n\013dataMessa" + "ge\030\001 \001(\0132\032.SessionProtos.DataMessage\022/\n\013" + "callMessage\030\003 \001(\0132\032.SessionProtos.CallMe" + "ssage\0225\n\016receiptMessage\030\005 \001(\0132\035.SessionP" + "rotos.ReceiptMessage\0223\n\rtypingMessage\030\006 " + "\001(\0132\034.SessionProtos.TypingMessage\022M\n\032dat" + "aExtractionNotification\030\010 \001(\0132).SessionP" + "rotos.DataExtractionNotification\0223\n\runse" + "ndRequest\030\t \001(\0132\034.SessionProtos.UnsendRe" + "quest\022E\n\026messageRequestResponse\030\n \001(\0132%." + "SessionProtos.MessageRequestResponse\022\?\n\023" + "sharedConfigMessage\030\013 \001(\0132\".SessionProto" + "s.SharedConfigMessage\022=\n\016expirationType\030" + "\014 \001(\0162%.SessionProtos.Content.Expiration" + "Type\022\027\n\017expirationTimer\030\r \001(\r\022\024\n\014sigTime" + "stamp\030\017 \001(\004\"K\n\016ExpirationType\022\013\n\007UNKNOWN" + "\020\000\022\025\n\021DELETE_AFTER_READ\020\001\022\025\n\021DELETE_AFTE" + "R_SEND\020\002\"\352\001\n\013CallMessage\022-\n\004type\030\001 \002(\0162\037" + ".SessionProtos.CallMessage.Type\022\014\n\004sdps\030" + "\002 \003(\t\022\027\n\017sdpMLineIndexes\030\003 \003(\r\022\017\n\007sdpMid" + "s\030\004 \003(\t\022\014\n\004uuid\030\005 \002(\t\"f\n\004Type\022\r\n\tPRE_OFF" + "ER\020\006\022\t\n\005OFFER\020\001\022\n\n\006ANSWER\020\002\022\026\n\022PROVISION" + "AL_ANSWER\020\003\022\022\n\016ICE_CANDIDATES\020\004\022\014\n\010END_C" + "ALL\020\005\"0\n\007KeyPair\022\021\n\tpublicKey\030\001 \002(\014\022\022\n\np" + "rivateKey\030\002 \002(\014\"\226\001\n\032DataExtractionNotifi" + "cation\022<\n\004type\030\001 \002(\0162..SessionProtos.Dat" + "aExtractionNotification.Type\022\021\n\ttimestam" + "p\030\002 \001(\004\"\'\n\004Type\022\016\n\nSCREENSHOT\020\001\022\017\n\013MEDIA" + "_SAVED\020\002\":\n\013LokiProfile\022\023\n\013displayName\030\001" + " \001(\t\022\026\n\016profilePicture\030\002 \001(\t\"\367\010\n\013DataMes" + "sage\022\014\n\004body\030\001 \001(\t\0225\n\013attachments\030\002 \003(\0132" + " .SessionProtos.AttachmentPointer\022\r\n\005fla" + "gs\030\004 \001(\r\022\022\n\nprofileKey\030\006 \001(\014\022\021\n\ttimestam" + "p\030\007 \001(\004\022/\n\005quote\030\010 \001(\0132 .SessionProtos.D" + "ataMessage.Quote\0223\n\007preview\030\n \003(\0132\".Sess" + "ionProtos.DataMessage.Preview\0225\n\010reactio" + "n\030\013 \001(\0132#.SessionProtos.DataMessage.Reac" + "tion\022+\n\007profile\030e \001(\0132\032.SessionProtos.Lo" + "kiProfile\022K\n\023openGroupInvitation\030f \001(\0132." + ".SessionProtos.DataMessage.OpenGroupInvi" + "tation\022\022\n\nsyncTarget\030i \001(\t\022&\n\036blocksComm" + "unityMessageRequests\030j \001(\010\022=\n\022groupUpdat" + "eMessage\030x \001(\0132!.SessionProtos.GroupUpda" + "teMessage\032\225\002\n\005Quote\022\n\n\002id\030\001 \002(\004\022\016\n\006autho" + "r\030\002 \002(\t\022\014\n\004text\030\003 \001(\t\022F\n\013attachments\030\004 \003" + "(\01321.SessionProtos.DataMessage.Quote.Quo" + "tedAttachment\032\231\001\n\020QuotedAttachment\022\023\n\013co" + "ntentType\030\001 \001(\t\022\020\n\010fileName\030\002 \001(\t\0223\n\tthu" + "mbnail\030\003 \001(\0132 .SessionProtos.AttachmentP" + "ointer\022\r\n\005flags\030\004 \001(\r\"\032\n\005Flags\022\021\n\rVOICE_" + "MESSAGE\020\001\032V\n\007Preview\022\013\n\003url\030\001 \002(\t\022\r\n\005tit" + "le\030\002 \001(\t\022/\n\005image\030\003 \001(\0132 .SessionProtos." + "AttachmentPointer\032\222\001\n\010Reaction\022\n\n\002id\030\001 \002" + "(\004\022\016\n\006author\030\002 \002(\t\022\r\n\005emoji\030\003 \001(\t\022:\n\006act" + "ion\030\004 \002(\0162*.SessionProtos.DataMessage.Re" + "action.Action\"\037\n\006Action\022\t\n\005REACT\020\000\022\n\n\006RE" + "MOVE\020\001\0320\n\023OpenGroupInvitation\022\013\n\003url\030\001 \002" + "(\t\022\014\n\004name\030\003 \002(\t\"$\n\005Flags\022\033\n\027EXPIRATION_" + "TIMER_UPDATE\020\002\"u\n\016ReceiptMessage\0220\n\004type" + "\030\001 \002(\0162\".SessionProtos.ReceiptMessage.Ty" + "pe\022\021\n\ttimestamp\030\002 \003(\004\"\036\n\004Type\022\014\n\010DELIVER" + "Y\020\000\022\010\n\004READ\020\001\"\354\001\n\021AttachmentPointer\022\n\n\002i" + "d\030\001 \002(\006\022\023\n\013contentType\030\002 \001(\t\022\013\n\003key\030\003 \001(" + "\014\022\014\n\004size\030\004 \001(\r\022\021\n\tthumbnail\030\005 \001(\014\022\016\n\006di" + "gest\030\006 \001(\014\022\020\n\010fileName\030\007 \001(\t\022\r\n\005flags\030\010 " + "\001(\r\022\r\n\005width\030\t \001(\r\022\016\n\006height\030\n \001(\r\022\017\n\007ca" + "ption\030\013 \001(\t\022\013\n\003url\030e \001(\t\"\032\n\005Flags\022\021\n\rVOI" + "CE_MESSAGE\020\001\"\273\001\n\023SharedConfigMessage\0225\n\004" + "kind\030\001 \002(\0162\'.SessionProtos.SharedConfigM" + "essage.Kind\022\r\n\005seqno\030\002 \002(\003\022\014\n\004data\030\003 \002(\014" + "\"P\n\004Kind\022\020\n\014USER_PROFILE\020\001\022\014\n\010CONTACTS\020\002" + "\022\027\n\023CONVO_INFO_VOLATILE\020\003\022\017\n\013USER_GROUPS" + "\020\004\"\356\004\n\022GroupUpdateMessage\022>\n\rinviteMessa" + "ge\030\001 \001(\0132\'.SessionProtos.GroupUpdateInvi" + "teMessage\022F\n\021infoChangeMessage\030\002 \001(\0132+.S" + "essionProtos.GroupUpdateInfoChangeMessag" + "e\022J\n\023memberChangeMessage\030\003 \001(\0132-.Session" + "Protos.GroupUpdateMemberChangeMessage\022@\n" + "\016promoteMessage\030\004 \001(\0132(.SessionProtos.Gr" + "oupUpdatePromoteMessage\022F\n\021memberLeftMes" + "sage\030\005 \001(\0132+.SessionProtos.GroupUpdateMe" + "mberLeftMessage\022G\n\016inviteResponse\030\006 \001(\0132" + "/.SessionProtos.GroupUpdateInviteRespons" + "eMessage\022Q\n\023deleteMemberContent\030\007 \001(\01324." + "SessionProtos.GroupUpdateDeleteMemberCon" + "tentMessage\022^\n\035memberLeftNotificationMes" + "sage\030\010 \001(\01327.SessionProtos.GroupUpdateMe" + "mberLeftNotificationMessage\"p\n\030GroupUpda" + "teInviteMessage\022\026\n\016groupSessionId\030\001 \002(\t\022" + "\014\n\004name\030\002 \002(\t\022\026\n\016memberAuthData\030\003 \002(\014\022\026\n" + "\016adminSignature\030\004 \002(\014\"D\n\031GroupUpdateProm" + "oteMessage\022\031\n\021groupIdentitySeed\030\001 \002(\014\022\014\n" + "\004name\030\002 \002(\t\"\337\001\n\034GroupUpdateInfoChangeMes" + "sage\022>\n\004type\030\001 \002(\01620.SessionProtos.Group" + "UpdateInfoChangeMessage.Type\022\023\n\013updatedN" + "ame\030\002 \001(\t\022\031\n\021updatedExpiration\030\003 \001(\r\022\026\n\016" + "adminSignature\030\004 \002(\014\"7\n\004Type\022\010\n\004NAME\020\001\022\n" + "\n\006AVATAR\020\002\022\031\n\025DISAPPEARING_MESSAGES\020\003\"\331\001" + "\n\036GroupUpdateMemberChangeMessage\022@\n\004type" + "\030\001 \002(\01622.SessionProtos.GroupUpdateMember" + "ChangeMessage.Type\022\030\n\020memberSessionIds\030\002" + " \003(\t\022\025\n\rhistoryShared\030\003 \001(\010\022\026\n\016adminSign" + "ature\030\004 \002(\014\",\n\004Type\022\t\n\005ADDED\020\001\022\013\n\007REMOVE" + "D\020\002\022\014\n\010PROMOTED\020\003\"\036\n\034GroupUpdateMemberLe" + "ftMessage\"*\n(GroupUpdateMemberLeftNotifi" + "cationMessage\"6\n GroupUpdateInviteRespon" + "seMessage\022\022\n\nisApproved\030\001 \002(\010\"p\n%GroupUp" + "dateDeleteMemberContentMessage\022\030\n\020member" + "SessionIds\030\001 \003(\t\022\025\n\rmessageHashes\030\002 \003(\t\022" + "\026\n\016adminSignature\030\003 \001(\014" + ; +static ::_pbi::once_flag descriptor_table_SessionProtos_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_SessionProtos_2eproto = { + false, false, 4903, descriptor_table_protodef_SessionProtos_2eproto, + "SessionProtos.proto", + &descriptor_table_SessionProtos_2eproto_once, nullptr, 0, 27, + schemas, file_default_instances, TableStruct_SessionProtos_2eproto::offsets, + file_level_metadata_SessionProtos_2eproto, file_level_enum_descriptors_SessionProtos_2eproto, + file_level_service_descriptors_SessionProtos_2eproto, +}; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_SessionProtos_2eproto_getter() { + return &descriptor_table_SessionProtos_2eproto; +} + +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_SessionProtos_2eproto(&descriptor_table_SessionProtos_2eproto); namespace SessionProtos { +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Envelope_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[0]; +} bool Envelope_Type_IsValid(int value) { switch (value) { case 6: @@ -489,47 +1076,6 @@ bool Envelope_Type_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed Envelope_Type_strings[2] = {}; - -static const char Envelope_Type_names[] = - "CLOSED_GROUP_MESSAGE" - "SESSION_MESSAGE"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry Envelope_Type_entries[] = { - { {Envelope_Type_names + 0, 20}, 7 }, - { {Envelope_Type_names + 20, 15}, 6 }, -}; - -static const int Envelope_Type_entries_by_number[] = { - 1, // 6 -> SESSION_MESSAGE - 0, // 7 -> CLOSED_GROUP_MESSAGE -}; - -const std::string& Envelope_Type_Name( - Envelope_Type value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - Envelope_Type_entries, - Envelope_Type_entries_by_number, - 2, Envelope_Type_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - Envelope_Type_entries, - Envelope_Type_entries_by_number, - 2, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - Envelope_Type_strings[idx].get(); -} -bool Envelope_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Envelope_Type* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - Envelope_Type_entries, 2, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr Envelope_Type Envelope::SESSION_MESSAGE; constexpr Envelope_Type Envelope::CLOSED_GROUP_MESSAGE; @@ -537,6 +1083,10 @@ constexpr Envelope_Type Envelope::Type_MIN; constexpr Envelope_Type Envelope::Type_MAX; constexpr int Envelope::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* TypingMessage_Action_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[1]; +} bool TypingMessage_Action_IsValid(int value) { switch (value) { case 0: @@ -547,47 +1097,6 @@ bool TypingMessage_Action_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed TypingMessage_Action_strings[2] = {}; - -static const char TypingMessage_Action_names[] = - "STARTED" - "STOPPED"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry TypingMessage_Action_entries[] = { - { {TypingMessage_Action_names + 0, 7}, 0 }, - { {TypingMessage_Action_names + 7, 7}, 1 }, -}; - -static const int TypingMessage_Action_entries_by_number[] = { - 0, // 0 -> STARTED - 1, // 1 -> STOPPED -}; - -const std::string& TypingMessage_Action_Name( - TypingMessage_Action value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - TypingMessage_Action_entries, - TypingMessage_Action_entries_by_number, - 2, TypingMessage_Action_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - TypingMessage_Action_entries, - TypingMessage_Action_entries_by_number, - 2, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - TypingMessage_Action_strings[idx].get(); -} -bool TypingMessage_Action_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, TypingMessage_Action* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - TypingMessage_Action_entries, 2, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr TypingMessage_Action TypingMessage::STARTED; constexpr TypingMessage_Action TypingMessage::STOPPED; @@ -595,6 +1104,33 @@ constexpr TypingMessage_Action TypingMessage::Action_MIN; constexpr TypingMessage_Action TypingMessage::Action_MAX; constexpr int TypingMessage::Action_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Content_ExpirationType_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[2]; +} +bool Content_ExpirationType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} + +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +constexpr Content_ExpirationType Content::UNKNOWN; +constexpr Content_ExpirationType Content::DELETE_AFTER_READ; +constexpr Content_ExpirationType Content::DELETE_AFTER_SEND; +constexpr Content_ExpirationType Content::ExpirationType_MIN; +constexpr Content_ExpirationType Content::ExpirationType_MAX; +constexpr int Content::ExpirationType_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CallMessage_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[3]; +} bool CallMessage_Type_IsValid(int value) { switch (value) { case 1: @@ -609,59 +1145,6 @@ bool CallMessage_Type_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed CallMessage_Type_strings[6] = {}; - -static const char CallMessage_Type_names[] = - "ANSWER" - "END_CALL" - "ICE_CANDIDATES" - "OFFER" - "PRE_OFFER" - "PROVISIONAL_ANSWER"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry CallMessage_Type_entries[] = { - { {CallMessage_Type_names + 0, 6}, 2 }, - { {CallMessage_Type_names + 6, 8}, 5 }, - { {CallMessage_Type_names + 14, 14}, 4 }, - { {CallMessage_Type_names + 28, 5}, 1 }, - { {CallMessage_Type_names + 33, 9}, 6 }, - { {CallMessage_Type_names + 42, 18}, 3 }, -}; - -static const int CallMessage_Type_entries_by_number[] = { - 3, // 1 -> OFFER - 0, // 2 -> ANSWER - 5, // 3 -> PROVISIONAL_ANSWER - 2, // 4 -> ICE_CANDIDATES - 1, // 5 -> END_CALL - 4, // 6 -> PRE_OFFER -}; - -const std::string& CallMessage_Type_Name( - CallMessage_Type value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - CallMessage_Type_entries, - CallMessage_Type_entries_by_number, - 6, CallMessage_Type_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - CallMessage_Type_entries, - CallMessage_Type_entries_by_number, - 6, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - CallMessage_Type_strings[idx].get(); -} -bool CallMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CallMessage_Type* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - CallMessage_Type_entries, 6, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr CallMessage_Type CallMessage::PRE_OFFER; constexpr CallMessage_Type CallMessage::OFFER; @@ -673,6 +1156,10 @@ constexpr CallMessage_Type CallMessage::Type_MIN; constexpr CallMessage_Type CallMessage::Type_MAX; constexpr int CallMessage::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataExtractionNotification_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[4]; +} bool DataExtractionNotification_Type_IsValid(int value) { switch (value) { case 1: @@ -683,47 +1170,6 @@ bool DataExtractionNotification_Type_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataExtractionNotification_Type_strings[2] = {}; - -static const char DataExtractionNotification_Type_names[] = - "MEDIA_SAVED" - "SCREENSHOT"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataExtractionNotification_Type_entries[] = { - { {DataExtractionNotification_Type_names + 0, 11}, 2 }, - { {DataExtractionNotification_Type_names + 11, 10}, 1 }, -}; - -static const int DataExtractionNotification_Type_entries_by_number[] = { - 1, // 1 -> SCREENSHOT - 0, // 2 -> MEDIA_SAVED -}; - -const std::string& DataExtractionNotification_Type_Name( - DataExtractionNotification_Type value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - DataExtractionNotification_Type_entries, - DataExtractionNotification_Type_entries_by_number, - 2, DataExtractionNotification_Type_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - DataExtractionNotification_Type_entries, - DataExtractionNotification_Type_entries_by_number, - 2, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - DataExtractionNotification_Type_strings[idx].get(); -} -bool DataExtractionNotification_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataExtractionNotification_Type* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - DataExtractionNotification_Type_entries, 2, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataExtractionNotification_Type DataExtractionNotification::SCREENSHOT; constexpr DataExtractionNotification_Type DataExtractionNotification::MEDIA_SAVED; @@ -731,6 +1177,10 @@ constexpr DataExtractionNotification_Type DataExtractionNotification::Type_MIN; constexpr DataExtractionNotification_Type DataExtractionNotification::Type_MAX; constexpr int DataExtractionNotification::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Quote_QuotedAttachment_Flags_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[5]; +} bool DataMessage_Quote_QuotedAttachment_Flags_IsValid(int value) { switch (value) { case 1: @@ -740,50 +1190,16 @@ bool DataMessage_Quote_QuotedAttachment_Flags_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_Quote_QuotedAttachment_Flags_strings[1] = {}; - -static const char DataMessage_Quote_QuotedAttachment_Flags_names[] = - "VOICE_MESSAGE"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_Quote_QuotedAttachment_Flags_entries[] = { - { {DataMessage_Quote_QuotedAttachment_Flags_names + 0, 13}, 1 }, -}; - -static const int DataMessage_Quote_QuotedAttachment_Flags_entries_by_number[] = { - 0, // 1 -> VOICE_MESSAGE -}; - -const std::string& DataMessage_Quote_QuotedAttachment_Flags_Name( - DataMessage_Quote_QuotedAttachment_Flags value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - DataMessage_Quote_QuotedAttachment_Flags_entries, - DataMessage_Quote_QuotedAttachment_Flags_entries_by_number, - 1, DataMessage_Quote_QuotedAttachment_Flags_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - DataMessage_Quote_QuotedAttachment_Flags_entries, - DataMessage_Quote_QuotedAttachment_Flags_entries_by_number, - 1, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - DataMessage_Quote_QuotedAttachment_Flags_strings[idx].get(); -} -bool DataMessage_Quote_QuotedAttachment_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Quote_QuotedAttachment_Flags* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - DataMessage_Quote_QuotedAttachment_Flags_entries, 1, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment::VOICE_MESSAGE; constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment::Flags_MIN; constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment::Flags_MAX; constexpr int DataMessage_Quote_QuotedAttachment::Flags_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Reaction_Action_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[6]; +} bool DataMessage_Reaction_Action_IsValid(int value) { switch (value) { case 0: @@ -794,47 +1210,6 @@ bool DataMessage_Reaction_Action_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_Reaction_Action_strings[2] = {}; - -static const char DataMessage_Reaction_Action_names[] = - "REACT" - "REMOVE"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_Reaction_Action_entries[] = { - { {DataMessage_Reaction_Action_names + 0, 5}, 0 }, - { {DataMessage_Reaction_Action_names + 5, 6}, 1 }, -}; - -static const int DataMessage_Reaction_Action_entries_by_number[] = { - 0, // 0 -> REACT - 1, // 1 -> REMOVE -}; - -const std::string& DataMessage_Reaction_Action_Name( - DataMessage_Reaction_Action value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - DataMessage_Reaction_Action_entries, - DataMessage_Reaction_Action_entries_by_number, - 2, DataMessage_Reaction_Action_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - DataMessage_Reaction_Action_entries, - DataMessage_Reaction_Action_entries_by_number, - 2, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - DataMessage_Reaction_Action_strings[idx].get(); -} -bool DataMessage_Reaction_Action_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Reaction_Action* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - DataMessage_Reaction_Action_entries, 2, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataMessage_Reaction_Action DataMessage_Reaction::REACT; constexpr DataMessage_Reaction_Action DataMessage_Reaction::REMOVE; @@ -842,89 +1217,10 @@ constexpr DataMessage_Reaction_Action DataMessage_Reaction::Action_MIN; constexpr DataMessage_Reaction_Action DataMessage_Reaction::Action_MAX; constexpr int DataMessage_Reaction::Action_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -bool DataMessage_ClosedGroupControlMessage_Type_IsValid(int value) { - switch (value) { - case 1: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - return true; - default: - return false; - } -} - -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_ClosedGroupControlMessage_Type_strings[7] = {}; - -static const char DataMessage_ClosedGroupControlMessage_Type_names[] = - "ENCRYPTION_KEY_PAIR" - "ENCRYPTION_KEY_PAIR_REQUEST" - "MEMBERS_ADDED" - "MEMBERS_REMOVED" - "MEMBER_LEFT" - "NAME_CHANGE" - "NEW"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_ClosedGroupControlMessage_Type_entries[] = { - { {DataMessage_ClosedGroupControlMessage_Type_names + 0, 19}, 3 }, - { {DataMessage_ClosedGroupControlMessage_Type_names + 19, 27}, 8 }, - { {DataMessage_ClosedGroupControlMessage_Type_names + 46, 13}, 5 }, - { {DataMessage_ClosedGroupControlMessage_Type_names + 59, 15}, 6 }, - { {DataMessage_ClosedGroupControlMessage_Type_names + 74, 11}, 7 }, - { {DataMessage_ClosedGroupControlMessage_Type_names + 85, 11}, 4 }, - { {DataMessage_ClosedGroupControlMessage_Type_names + 96, 3}, 1 }, -}; - -static const int DataMessage_ClosedGroupControlMessage_Type_entries_by_number[] = { - 6, // 1 -> NEW - 0, // 3 -> ENCRYPTION_KEY_PAIR - 5, // 4 -> NAME_CHANGE - 2, // 5 -> MEMBERS_ADDED - 3, // 6 -> MEMBERS_REMOVED - 4, // 7 -> MEMBER_LEFT - 1, // 8 -> ENCRYPTION_KEY_PAIR_REQUEST -}; - -const std::string& DataMessage_ClosedGroupControlMessage_Type_Name( - DataMessage_ClosedGroupControlMessage_Type value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - DataMessage_ClosedGroupControlMessage_Type_entries, - DataMessage_ClosedGroupControlMessage_Type_entries_by_number, - 7, DataMessage_ClosedGroupControlMessage_Type_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - DataMessage_ClosedGroupControlMessage_Type_entries, - DataMessage_ClosedGroupControlMessage_Type_entries_by_number, - 7, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - DataMessage_ClosedGroupControlMessage_Type_strings[idx].get(); -} -bool DataMessage_ClosedGroupControlMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_ClosedGroupControlMessage_Type* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - DataMessage_ClosedGroupControlMessage_Type_entries, 7, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Flags_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[7]; } -#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::NEW; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::ENCRYPTION_KEY_PAIR; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::NAME_CHANGE; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::MEMBERS_ADDED; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::MEMBERS_REMOVED; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::MEMBER_LEFT; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::ENCRYPTION_KEY_PAIR_REQUEST; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::Type_MIN; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::Type_MAX; -constexpr int DataMessage_ClosedGroupControlMessage::Type_ARRAYSIZE; -#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) bool DataMessage_Flags_IsValid(int value) { switch (value) { case 2: @@ -934,50 +1230,16 @@ bool DataMessage_Flags_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_Flags_strings[1] = {}; - -static const char DataMessage_Flags_names[] = - "EXPIRATION_TIMER_UPDATE"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_Flags_entries[] = { - { {DataMessage_Flags_names + 0, 23}, 2 }, -}; - -static const int DataMessage_Flags_entries_by_number[] = { - 0, // 2 -> EXPIRATION_TIMER_UPDATE -}; - -const std::string& DataMessage_Flags_Name( - DataMessage_Flags value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - DataMessage_Flags_entries, - DataMessage_Flags_entries_by_number, - 1, DataMessage_Flags_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - DataMessage_Flags_entries, - DataMessage_Flags_entries_by_number, - 1, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - DataMessage_Flags_strings[idx].get(); -} -bool DataMessage_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Flags* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - DataMessage_Flags_entries, 1, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataMessage_Flags DataMessage::EXPIRATION_TIMER_UPDATE; constexpr DataMessage_Flags DataMessage::Flags_MIN; constexpr DataMessage_Flags DataMessage::Flags_MAX; constexpr int DataMessage::Flags_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ReceiptMessage_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[8]; +} bool ReceiptMessage_Type_IsValid(int value) { switch (value) { case 0: @@ -988,47 +1250,6 @@ bool ReceiptMessage_Type_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed ReceiptMessage_Type_strings[2] = {}; - -static const char ReceiptMessage_Type_names[] = - "DELIVERY" - "READ"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry ReceiptMessage_Type_entries[] = { - { {ReceiptMessage_Type_names + 0, 8}, 0 }, - { {ReceiptMessage_Type_names + 8, 4}, 1 }, -}; - -static const int ReceiptMessage_Type_entries_by_number[] = { - 0, // 0 -> DELIVERY - 1, // 1 -> READ -}; - -const std::string& ReceiptMessage_Type_Name( - ReceiptMessage_Type value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - ReceiptMessage_Type_entries, - ReceiptMessage_Type_entries_by_number, - 2, ReceiptMessage_Type_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - ReceiptMessage_Type_entries, - ReceiptMessage_Type_entries_by_number, - 2, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - ReceiptMessage_Type_strings[idx].get(); -} -bool ReceiptMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceiptMessage_Type* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - ReceiptMessage_Type_entries, 2, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr ReceiptMessage_Type ReceiptMessage::DELIVERY; constexpr ReceiptMessage_Type ReceiptMessage::READ; @@ -1036,6 +1257,10 @@ constexpr ReceiptMessage_Type ReceiptMessage::Type_MIN; constexpr ReceiptMessage_Type ReceiptMessage::Type_MAX; constexpr int ReceiptMessage::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttachmentPointer_Flags_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[9]; +} bool AttachmentPointer_Flags_IsValid(int value) { switch (value) { case 1: @@ -1045,50 +1270,16 @@ bool AttachmentPointer_Flags_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed AttachmentPointer_Flags_strings[1] = {}; - -static const char AttachmentPointer_Flags_names[] = - "VOICE_MESSAGE"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry AttachmentPointer_Flags_entries[] = { - { {AttachmentPointer_Flags_names + 0, 13}, 1 }, -}; - -static const int AttachmentPointer_Flags_entries_by_number[] = { - 0, // 1 -> VOICE_MESSAGE -}; - -const std::string& AttachmentPointer_Flags_Name( - AttachmentPointer_Flags value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - AttachmentPointer_Flags_entries, - AttachmentPointer_Flags_entries_by_number, - 1, AttachmentPointer_Flags_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - AttachmentPointer_Flags_entries, - AttachmentPointer_Flags_entries_by_number, - 1, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - AttachmentPointer_Flags_strings[idx].get(); -} -bool AttachmentPointer_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttachmentPointer_Flags* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - AttachmentPointer_Flags_entries, 1, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr AttachmentPointer_Flags AttachmentPointer::VOICE_MESSAGE; constexpr AttachmentPointer_Flags AttachmentPointer::Flags_MIN; constexpr AttachmentPointer_Flags AttachmentPointer::Flags_MAX; constexpr int AttachmentPointer::Flags_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* SharedConfigMessage_Kind_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[10]; +} bool SharedConfigMessage_Kind_IsValid(int value) { switch (value) { case 1: @@ -1101,53 +1292,6 @@ bool SharedConfigMessage_Kind_IsValid(int value) { } } -static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed SharedConfigMessage_Kind_strings[4] = {}; - -static const char SharedConfigMessage_Kind_names[] = - "CONTACTS" - "CONVO_INFO_VOLATILE" - "USER_GROUPS" - "USER_PROFILE"; - -static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry SharedConfigMessage_Kind_entries[] = { - { {SharedConfigMessage_Kind_names + 0, 8}, 2 }, - { {SharedConfigMessage_Kind_names + 8, 19}, 3 }, - { {SharedConfigMessage_Kind_names + 27, 11}, 4 }, - { {SharedConfigMessage_Kind_names + 38, 12}, 1 }, -}; - -static const int SharedConfigMessage_Kind_entries_by_number[] = { - 3, // 1 -> USER_PROFILE - 0, // 2 -> CONTACTS - 1, // 3 -> CONVO_INFO_VOLATILE - 2, // 4 -> USER_GROUPS -}; - -const std::string& SharedConfigMessage_Kind_Name( - SharedConfigMessage_Kind value) { - static const bool dummy = - ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( - SharedConfigMessage_Kind_entries, - SharedConfigMessage_Kind_entries_by_number, - 4, SharedConfigMessage_Kind_strings); - (void) dummy; - int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( - SharedConfigMessage_Kind_entries, - SharedConfigMessage_Kind_entries_by_number, - 4, value); - return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : - SharedConfigMessage_Kind_strings[idx].get(); -} -bool SharedConfigMessage_Kind_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SharedConfigMessage_Kind* value) { - int int_value; - bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( - SharedConfigMessage_Kind_entries, 4, name, &int_value); - if (success) { - *value = static_cast(int_value); - } - return success; -} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr SharedConfigMessage_Kind SharedConfigMessage::USER_PROFILE; constexpr SharedConfigMessage_Kind SharedConfigMessage::CONTACTS; @@ -1157,7 +1301,53 @@ constexpr SharedConfigMessage_Kind SharedConfigMessage::Kind_MIN; constexpr SharedConfigMessage_Kind SharedConfigMessage::Kind_MAX; constexpr int SharedConfigMessage::Kind_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) - +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateInfoChangeMessage_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[11]; +} +bool GroupUpdateInfoChangeMessage_Type_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + return true; + default: + return false; + } +} + +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::NAME; +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::AVATAR; +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::DISAPPEARING_MESSAGES; +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::Type_MIN; +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::Type_MAX; +constexpr int GroupUpdateInfoChangeMessage::Type_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateMemberChangeMessage_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); + return file_level_enum_descriptors_SessionProtos_2eproto[12]; +} +bool GroupUpdateMemberChangeMessage_Type_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + return true; + default: + return false; + } +} + +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::ADDED; +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::REMOVED; +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::PROMOTED; +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::Type_MIN; +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::Type_MAX; +constexpr int GroupUpdateMemberChangeMessage::Type_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) + // =================================================================== class Envelope::_Internal { @@ -1188,12 +1378,12 @@ class Envelope::_Internal { Envelope::Envelope(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.Envelope) } Envelope::Envelope(const Envelope& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + : ::PROTOBUF_NAMESPACE_ID::Message() { Envelope* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -1205,7 +1395,7 @@ Envelope::Envelope(const Envelope& from) , decltype(_impl_.sourcedevice_){} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _impl_.source_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.source_.Set("", GetArenaForAllocation()); @@ -1254,7 +1444,7 @@ inline void Envelope::SharedCtor( Envelope::~Envelope() { // @@protoc_insertion_point(destructor:SessionProtos.Envelope) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } @@ -1293,7 +1483,7 @@ void Envelope::Clear() { _impl_.type_ = 6; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -1322,6 +1512,9 @@ const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) auto str = _internal_mutable_source(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.Envelope.source"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1372,7 +1565,7 @@ const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -1401,6 +1594,10 @@ uint8_t* Envelope::_InternalSerialize( // optional string source = 2; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_source().data(), static_cast(this->_internal_source().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.Envelope.source"); target = stream->WriteStringMaybeAliased( 2, this->_internal_source(), target); } @@ -1430,8 +1627,8 @@ uint8_t* Envelope::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Envelope) return target; @@ -1502,22 +1699,19 @@ size_t Envelope::ByteSizeLong() const { } } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void Envelope::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Envelope::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Envelope::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Envelope::GetClassData() const { return &_class_data_; } -void Envelope::MergeFrom(const Envelope& from) { - Envelope* const _this = this; + +void Envelope::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Envelope) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -1545,7 +1739,7 @@ void Envelope::MergeFrom(const Envelope& from) { } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Envelope::CopyFrom(const Envelope& from) { @@ -1583,11 +1777,12 @@ void Envelope::InternalSwap(Envelope* other) { swap(_impl_.type_, other->_impl_.type_); } -std::string Envelope::GetTypeName() const { - return "SessionProtos.Envelope"; +::PROTOBUF_NAMESPACE_ID::Metadata Envelope::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[0]); } - // =================================================================== class TypingMessage::_Internal { @@ -1606,12 +1801,12 @@ class TypingMessage::_Internal { TypingMessage::TypingMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.TypingMessage) } TypingMessage::TypingMessage(const TypingMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + : ::PROTOBUF_NAMESPACE_ID::Message() { TypingMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -1619,7 +1814,7 @@ TypingMessage::TypingMessage(const TypingMessage& from) , decltype(_impl_.timestamp_){} , decltype(_impl_.action_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, static_cast(reinterpret_cast(&_impl_.action_) - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.action_)); @@ -1640,7 +1835,7 @@ inline void TypingMessage::SharedCtor( TypingMessage::~TypingMessage() { // @@protoc_insertion_point(destructor:SessionProtos.TypingMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } @@ -1668,7 +1863,7 @@ void TypingMessage::Clear() { reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.action_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* TypingMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -1711,7 +1906,7 @@ const char* TypingMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -1745,8 +1940,8 @@ uint8_t* TypingMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.TypingMessage) return target; @@ -1788,22 +1983,19 @@ size_t TypingMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void TypingMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData TypingMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + TypingMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*TypingMessage::GetClassData() const { return &_class_data_; } + -void TypingMessage::MergeFrom(const TypingMessage& from) { - TypingMessage* const _this = this; +void TypingMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.TypingMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -1819,7 +2011,7 @@ void TypingMessage::MergeFrom(const TypingMessage& from) { } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void TypingMessage::CopyFrom(const TypingMessage& from) { @@ -1846,11 +2038,12 @@ void TypingMessage::InternalSwap(TypingMessage* other) { reinterpret_cast(&other->_impl_.timestamp_)); } -std::string TypingMessage::GetTypeName() const { - return "SessionProtos.TypingMessage"; +::PROTOBUF_NAMESPACE_ID::Metadata TypingMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[1]); } - // =================================================================== class UnsendRequest::_Internal { @@ -1869,12 +2062,12 @@ class UnsendRequest::_Internal { UnsendRequest::UnsendRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.UnsendRequest) } UnsendRequest::UnsendRequest(const UnsendRequest& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + : ::PROTOBUF_NAMESPACE_ID::Message() { UnsendRequest* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -1882,7 +2075,7 @@ UnsendRequest::UnsendRequest(const UnsendRequest& from) , decltype(_impl_.author_){} , decltype(_impl_.timestamp_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.author_.Set("", GetArenaForAllocation()); @@ -1913,7 +2106,7 @@ inline void UnsendRequest::SharedCtor( UnsendRequest::~UnsendRequest() { // @@protoc_insertion_point(destructor:SessionProtos.UnsendRequest) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } @@ -1941,7 +2134,7 @@ void UnsendRequest::Clear() { } _impl_.timestamp_ = uint64_t{0u}; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* UnsendRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -1966,6 +2159,9 @@ const char* UnsendRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.UnsendRequest.author"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1980,7 +2176,7 @@ const char* UnsendRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -2008,13 +2204,17 @@ uint8_t* UnsendRequest::_InternalSerialize( // required string author = 2; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_author().data(), static_cast(this->_internal_author().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.UnsendRequest.author"); target = stream->WriteStringMaybeAliased( 2, this->_internal_author(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.UnsendRequest) return target; @@ -2058,22 +2258,19 @@ size_t UnsendRequest::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void UnsendRequest::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData UnsendRequest::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + UnsendRequest::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UnsendRequest::GetClassData() const { return &_class_data_; } -void UnsendRequest::MergeFrom(const UnsendRequest& from) { - UnsendRequest* const _this = this; + +void UnsendRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.UnsendRequest) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -2089,7 +2286,7 @@ void UnsendRequest::MergeFrom(const UnsendRequest& from) { } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void UnsendRequest::CopyFrom(const UnsendRequest& from) { @@ -2117,11 +2314,12 @@ void UnsendRequest::InternalSwap(UnsendRequest* other) { swap(_impl_.timestamp_, other->_impl_.timestamp_); } -std::string UnsendRequest::GetTypeName() const { - return "SessionProtos.UnsendRequest"; +::PROTOBUF_NAMESPACE_ID::Metadata UnsendRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[2]); } - // =================================================================== class MessageRequestResponse::_Internal { @@ -2148,12 +2346,12 @@ MessageRequestResponse::_Internal::profile(const MessageRequestResponse* msg) { } MessageRequestResponse::MessageRequestResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.MessageRequestResponse) } MessageRequestResponse::MessageRequestResponse(const MessageRequestResponse& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + : ::PROTOBUF_NAMESPACE_ID::Message() { MessageRequestResponse* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -2162,7 +2360,7 @@ MessageRequestResponse::MessageRequestResponse(const MessageRequestResponse& fro , decltype(_impl_.profile_){nullptr} , decltype(_impl_.isapproved_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _impl_.profilekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.profilekey_.Set("", GetArenaForAllocation()); @@ -2197,7 +2395,7 @@ inline void MessageRequestResponse::SharedCtor( MessageRequestResponse::~MessageRequestResponse() { // @@protoc_insertion_point(destructor:SessionProtos.MessageRequestResponse) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } @@ -2232,7 +2430,7 @@ void MessageRequestResponse::Clear() { } _impl_.isapproved_ = false; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* MessageRequestResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -2279,7 +2477,7 @@ const char* MessageRequestResponse::_InternalParse(const char* ptr, ::_pbi::Pars } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -2319,8 +2517,8 @@ uint8_t* MessageRequestResponse::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.MessageRequestResponse) return target; @@ -2355,22 +2553,19 @@ size_t MessageRequestResponse::ByteSizeLong() const { } } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void MessageRequestResponse::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData MessageRequestResponse::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + MessageRequestResponse::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MessageRequestResponse::GetClassData() const { return &_class_data_; } + -void MessageRequestResponse::MergeFrom(const MessageRequestResponse& from) { - MessageRequestResponse* const _this = this; +void MessageRequestResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.MessageRequestResponse) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -2390,7 +2585,7 @@ void MessageRequestResponse::MergeFrom(const MessageRequestResponse& from) { } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void MessageRequestResponse::CopyFrom(const MessageRequestResponse& from) { @@ -2423,207 +2618,341 @@ void MessageRequestResponse::InternalSwap(MessageRequestResponse* other) { reinterpret_cast(&other->_impl_.profile_)); } -std::string MessageRequestResponse::GetTypeName() const { - return "SessionProtos.MessageRequestResponse"; +::PROTOBUF_NAMESPACE_ID::Metadata MessageRequestResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[3]); } - // =================================================================== -class ProProof::_Internal { +class Content::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_version(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static void set_has_genindexhash(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static const ::SessionProtos::DataMessage& datamessage(const Content* msg); + static void set_has_datamessage(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_rotatingpublickey(HasBits* has_bits) { + static const ::SessionProtos::CallMessage& callmessage(const Content* msg); + static void set_has_callmessage(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_expiryunixts(HasBits* has_bits) { + static const ::SessionProtos::ReceiptMessage& receiptmessage(const Content* msg); + static void set_has_receiptmessage(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static const ::SessionProtos::TypingMessage& typingmessage(const Content* msg); + static void set_has_typingmessage(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static void set_has_sig(HasBits* has_bits) { - (*has_bits)[0] |= 4u; + static const ::SessionProtos::DataExtractionNotification& dataextractionnotification(const Content* msg); + static void set_has_dataextractionnotification(HasBits* has_bits) { + (*has_bits)[0] |= 16u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x0000001f) ^ 0x0000001f) != 0; + static const ::SessionProtos::UnsendRequest& unsendrequest(const Content* msg); + static void set_has_unsendrequest(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static const ::SessionProtos::MessageRequestResponse& messagerequestresponse(const Content* msg); + static void set_has_messagerequestresponse(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } + static const ::SessionProtos::SharedConfigMessage& sharedconfigmessage(const Content* msg); + static void set_has_sharedconfigmessage(HasBits* has_bits) { + (*has_bits)[0] |= 128u; + } + static void set_has_expirationtype(HasBits* has_bits) { + (*has_bits)[0] |= 256u; + } + static void set_has_expirationtimer(HasBits* has_bits) { + (*has_bits)[0] |= 512u; + } + static void set_has_sigtimestamp(HasBits* has_bits) { + (*has_bits)[0] |= 1024u; } }; -ProProof::ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::DataMessage& +Content::_Internal::datamessage(const Content* msg) { + return *msg->_impl_.datamessage_; +} +const ::SessionProtos::CallMessage& +Content::_Internal::callmessage(const Content* msg) { + return *msg->_impl_.callmessage_; +} +const ::SessionProtos::ReceiptMessage& +Content::_Internal::receiptmessage(const Content* msg) { + return *msg->_impl_.receiptmessage_; +} +const ::SessionProtos::TypingMessage& +Content::_Internal::typingmessage(const Content* msg) { + return *msg->_impl_.typingmessage_; +} +const ::SessionProtos::DataExtractionNotification& +Content::_Internal::dataextractionnotification(const Content* msg) { + return *msg->_impl_.dataextractionnotification_; +} +const ::SessionProtos::UnsendRequest& +Content::_Internal::unsendrequest(const Content* msg) { + return *msg->_impl_.unsendrequest_; +} +const ::SessionProtos::MessageRequestResponse& +Content::_Internal::messagerequestresponse(const Content* msg) { + return *msg->_impl_.messagerequestresponse_; +} +const ::SessionProtos::SharedConfigMessage& +Content::_Internal::sharedconfigmessage(const Content* msg) { + return *msg->_impl_.sharedconfigmessage_; +} +Content::Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ProProof) + // @@protoc_insertion_point(arena_constructor:SessionProtos.Content) } -ProProof::ProProof(const ProProof& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ProProof* const _this = this; (void)_this; +Content::Content(const Content& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Content* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.genindexhash_){} - , decltype(_impl_.rotatingpublickey_){} - , decltype(_impl_.sig_){} - , decltype(_impl_.expiryunixts_){} - , decltype(_impl_.version_){}}; - - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.genindexhash_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.genindexhash_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_genindexhash()) { - _this->_impl_.genindexhash_.Set(from._internal_genindexhash(), - _this->GetArenaForAllocation()); + , decltype(_impl_.datamessage_){nullptr} + , decltype(_impl_.callmessage_){nullptr} + , decltype(_impl_.receiptmessage_){nullptr} + , decltype(_impl_.typingmessage_){nullptr} + , decltype(_impl_.dataextractionnotification_){nullptr} + , decltype(_impl_.unsendrequest_){nullptr} + , decltype(_impl_.messagerequestresponse_){nullptr} + , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.expirationtype_){} + , decltype(_impl_.expirationtimer_){} + , decltype(_impl_.sigtimestamp_){}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_datamessage()) { + _this->_impl_.datamessage_ = new ::SessionProtos::DataMessage(*from._impl_.datamessage_); } - _impl_.rotatingpublickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_rotatingpublickey()) { - _this->_impl_.rotatingpublickey_.Set(from._internal_rotatingpublickey(), - _this->GetArenaForAllocation()); + if (from._internal_has_callmessage()) { + _this->_impl_.callmessage_ = new ::SessionProtos::CallMessage(*from._impl_.callmessage_); } - _impl_.sig_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.sig_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_sig()) { - _this->_impl_.sig_.Set(from._internal_sig(), - _this->GetArenaForAllocation()); + if (from._internal_has_receiptmessage()) { + _this->_impl_.receiptmessage_ = new ::SessionProtos::ReceiptMessage(*from._impl_.receiptmessage_); + } + if (from._internal_has_typingmessage()) { + _this->_impl_.typingmessage_ = new ::SessionProtos::TypingMessage(*from._impl_.typingmessage_); + } + if (from._internal_has_dataextractionnotification()) { + _this->_impl_.dataextractionnotification_ = new ::SessionProtos::DataExtractionNotification(*from._impl_.dataextractionnotification_); + } + if (from._internal_has_unsendrequest()) { + _this->_impl_.unsendrequest_ = new ::SessionProtos::UnsendRequest(*from._impl_.unsendrequest_); + } + if (from._internal_has_messagerequestresponse()) { + _this->_impl_.messagerequestresponse_ = new ::SessionProtos::MessageRequestResponse(*from._impl_.messagerequestresponse_); + } + if (from._internal_has_sharedconfigmessage()) { + _this->_impl_.sharedconfigmessage_ = new ::SessionProtos::SharedConfigMessage(*from._impl_.sharedconfigmessage_); } - ::memcpy(&_impl_.expiryunixts_, &from._impl_.expiryunixts_, - static_cast(reinterpret_cast(&_impl_.version_) - - reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.ProProof) + ::memcpy(&_impl_.expirationtype_, &from._impl_.expirationtype_, + static_cast(reinterpret_cast(&_impl_.sigtimestamp_) - + reinterpret_cast(&_impl_.expirationtype_)) + sizeof(_impl_.sigtimestamp_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.Content) } -inline void ProProof::SharedCtor( +inline void Content::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.genindexhash_){} - , decltype(_impl_.rotatingpublickey_){} - , decltype(_impl_.sig_){} - , decltype(_impl_.expiryunixts_){uint64_t{0u}} - , decltype(_impl_.version_){0u} + , decltype(_impl_.datamessage_){nullptr} + , decltype(_impl_.callmessage_){nullptr} + , decltype(_impl_.receiptmessage_){nullptr} + , decltype(_impl_.typingmessage_){nullptr} + , decltype(_impl_.dataextractionnotification_){nullptr} + , decltype(_impl_.unsendrequest_){nullptr} + , decltype(_impl_.messagerequestresponse_){nullptr} + , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.expirationtype_){0} + , decltype(_impl_.expirationtimer_){0u} + , decltype(_impl_.sigtimestamp_){uint64_t{0u}} }; - _impl_.genindexhash_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.genindexhash_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingpublickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.sig_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.sig_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ProProof::~ProProof() { - // @@protoc_insertion_point(destructor:SessionProtos.ProProof) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +Content::~Content() { + // @@protoc_insertion_point(destructor:SessionProtos.Content) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void ProProof::SharedDtor() { +inline void Content::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.genindexhash_.Destroy(); - _impl_.rotatingpublickey_.Destroy(); - _impl_.sig_.Destroy(); + if (this != internal_default_instance()) delete _impl_.datamessage_; + if (this != internal_default_instance()) delete _impl_.callmessage_; + if (this != internal_default_instance()) delete _impl_.receiptmessage_; + if (this != internal_default_instance()) delete _impl_.typingmessage_; + if (this != internal_default_instance()) delete _impl_.dataextractionnotification_; + if (this != internal_default_instance()) delete _impl_.unsendrequest_; + if (this != internal_default_instance()) delete _impl_.messagerequestresponse_; + if (this != internal_default_instance()) delete _impl_.sharedconfigmessage_; } -void ProProof::SetCachedSize(int size) const { +void Content::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ProProof::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ProProof) +void Content::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.Content) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _impl_.genindexhash_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.datamessage_ != nullptr); + _impl_.datamessage_->Clear(); } if (cached_has_bits & 0x00000002u) { - _impl_.rotatingpublickey_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.callmessage_ != nullptr); + _impl_.callmessage_->Clear(); } if (cached_has_bits & 0x00000004u) { - _impl_.sig_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.receiptmessage_ != nullptr); + _impl_.receiptmessage_->Clear(); + } + if (cached_has_bits & 0x00000008u) { + GOOGLE_DCHECK(_impl_.typingmessage_ != nullptr); + _impl_.typingmessage_->Clear(); + } + if (cached_has_bits & 0x00000010u) { + GOOGLE_DCHECK(_impl_.dataextractionnotification_ != nullptr); + _impl_.dataextractionnotification_->Clear(); + } + if (cached_has_bits & 0x00000020u) { + GOOGLE_DCHECK(_impl_.unsendrequest_ != nullptr); + _impl_.unsendrequest_->Clear(); + } + if (cached_has_bits & 0x00000040u) { + GOOGLE_DCHECK(_impl_.messagerequestresponse_ != nullptr); + _impl_.messagerequestresponse_->Clear(); + } + if (cached_has_bits & 0x00000080u) { + GOOGLE_DCHECK(_impl_.sharedconfigmessage_ != nullptr); + _impl_.sharedconfigmessage_->Clear(); } } - if (cached_has_bits & 0x00000018u) { - ::memset(&_impl_.expiryunixts_, 0, static_cast( - reinterpret_cast(&_impl_.version_) - - reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); + if (cached_has_bits & 0x00000700u) { + ::memset(&_impl_.expirationtype_, 0, static_cast( + reinterpret_cast(&_impl_.sigtimestamp_) - + reinterpret_cast(&_impl_.expirationtype_)) + sizeof(_impl_.sigtimestamp_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint32 version = 1; + // optional .SessionProtos.DataMessage dataMessage = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_version(&has_bits); - _impl_.version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // required bytes genIndexHash = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_genindexhash(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_datamessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes rotatingPublicKey = 3; + // optional .SessionProtos.CallMessage callMessage = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_rotatingpublickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_callmessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // required uint64 expiryUnixTs = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_expiryunixts(&has_bits); - _impl_.expiryunixts_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + ptr = ctx->ParseMessage(_internal_mutable_receiptmessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // required bytes sig = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_sig(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + // optional .SessionProtos.TypingMessage typingMessage = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + ptr = ctx->ParseMessage(_internal_mutable_typingmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { + ptr = ctx->ParseMessage(_internal_mutable_dataextractionnotification(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + case 9: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { + ptr = ctx->ParseMessage(_internal_mutable_unsendrequest(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + case 10: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { + ptr = ctx->ParseMessage(_internal_mutable_messagerequestresponse(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { + ptr = ctx->ParseMessage(_internal_mutable_sharedconfigmessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.Content.ExpirationType expirationType = 12; + case 12: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 96)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::Content_ExpirationType_IsValid(val))) { + _internal_set_expirationtype(static_cast<::SessionProtos::Content_ExpirationType>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(12, val, mutable_unknown_fields()); + } + } else + goto handle_unusual; + continue; + // optional uint32 expirationTimer = 13; + case 13: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 104)) { + _Internal::set_has_expirationtimer(&has_bits); + _impl_.expirationtimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional uint64 sigTimestamp = 15; + case 15: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 120)) { + _Internal::set_has_sigtimestamp(&has_bits); + _impl_.sigtimestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2639,7 +2968,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -2652,334 +2981,488 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) #undef CHK_ } -uint8_t* ProProof::_InternalSerialize( +uint8_t* Content::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProProof) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.Content) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint32 version = 1; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_version(), target); - } - - // required bytes genIndexHash = 2; + // optional .SessionProtos.DataMessage dataMessage = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 2, this->_internal_genindexhash(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::datamessage(this), + _Internal::datamessage(this).GetCachedSize(), target, stream); } - // required bytes rotatingPublicKey = 3; + // optional .SessionProtos.CallMessage callMessage = 3; if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 3, this->_internal_rotatingpublickey(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::callmessage(this), + _Internal::callmessage(this).GetCachedSize(), target, stream); } - // required uint64 expiryUnixTs = 4; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_expiryunixts(), target); + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(5, _Internal::receiptmessage(this), + _Internal::receiptmessage(this).GetCachedSize(), target, stream); } - // required bytes sig = 5; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteBytesMaybeAliased( - 5, this->_internal_sig(), target); + // optional .SessionProtos.TypingMessage typingMessage = 6; + if (cached_has_bits & 0x00000008u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(6, _Internal::typingmessage(this), + _Internal::typingmessage(this).GetCachedSize(), target, stream); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + if (cached_has_bits & 0x00000010u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(8, _Internal::dataextractionnotification(this), + _Internal::dataextractionnotification(this).GetCachedSize(), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProProof) - return target; -} -size_t ProProof::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProProof) - size_t total_size = 0; + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + if (cached_has_bits & 0x00000020u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(9, _Internal::unsendrequest(this), + _Internal::unsendrequest(this).GetCachedSize(), target, stream); + } - if (_internal_has_genindexhash()) { - // required bytes genIndexHash = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_genindexhash()); + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + if (cached_has_bits & 0x00000040u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(10, _Internal::messagerequestresponse(this), + _Internal::messagerequestresponse(this).GetCachedSize(), target, stream); } - if (_internal_has_rotatingpublickey()) { - // required bytes rotatingPublicKey = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingpublickey()); + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + if (cached_has_bits & 0x00000080u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(11, _Internal::sharedconfigmessage(this), + _Internal::sharedconfigmessage(this).GetCachedSize(), target, stream); } - if (_internal_has_sig()) { - // required bytes sig = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_sig()); + // optional .SessionProtos.Content.ExpirationType expirationType = 12; + if (cached_has_bits & 0x00000100u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 12, this->_internal_expirationtype(), target); } - if (_internal_has_expiryunixts()) { - // required uint64 expiryUnixTs = 4; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + // optional uint32 expirationTimer = 13; + if (cached_has_bits & 0x00000200u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(13, this->_internal_expirationtimer(), target); } - if (_internal_has_version()) { - // required uint32 version = 1; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + // optional uint64 sigTimestamp = 15; + if (cached_has_bits & 0x00000400u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(15, this->_internal_sigtimestamp(), target); } - return total_size; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Content) + return target; } -size_t ProProof::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProProof) + +size_t Content::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.Content) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x0000001f) ^ 0x0000001f) == 0) { // All required fields are present. - // required bytes genIndexHash = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_genindexhash()); + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - // required bytes rotatingPublicKey = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingpublickey()); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x000000ffu) { + // optional .SessionProtos.DataMessage dataMessage = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.datamessage_); + } - // required bytes sig = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_sig()); + // optional .SessionProtos.CallMessage callMessage = 3; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.callmessage_); + } + + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.receiptmessage_); + } + + // optional .SessionProtos.TypingMessage typingMessage = 6; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.typingmessage_); + } - // required uint64 expiryUnixTs = 4; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.dataextractionnotification_); + } - // required uint32 version = 1; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + if (cached_has_bits & 0x00000020u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.unsendrequest_); + } + + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + if (cached_has_bits & 0x00000040u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.messagerequestresponse_); + } + + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + if (cached_has_bits & 0x00000080u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.sharedconfigmessage_); + } - } else { - total_size += RequiredFieldsByteSizeFallback(); } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + if (cached_has_bits & 0x00000700u) { + // optional .SessionProtos.Content.ExpirationType expirationType = 12; + if (cached_has_bits & 0x00000100u) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_expirationtype()); + } + + // optional uint32 expirationTimer = 13; + if (cached_has_bits & 0x00000200u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); + } + + // optional uint64 sigTimestamp = 15; + if (cached_has_bits & 0x00000400u) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_sigtimestamp()); + } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void ProProof::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Content::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Content::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Content::GetClassData() const { return &_class_data_; } -void ProProof::MergeFrom(const ProProof& from) { - ProProof* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProProof) + +void Content::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Content) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_genindexhash(from._internal_genindexhash()); + _this->_internal_mutable_datamessage()->::SessionProtos::DataMessage::MergeFrom( + from._internal_datamessage()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_rotatingpublickey(from._internal_rotatingpublickey()); + _this->_internal_mutable_callmessage()->::SessionProtos::CallMessage::MergeFrom( + from._internal_callmessage()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_set_sig(from._internal_sig()); + _this->_internal_mutable_receiptmessage()->::SessionProtos::ReceiptMessage::MergeFrom( + from._internal_receiptmessage()); } if (cached_has_bits & 0x00000008u) { - _this->_impl_.expiryunixts_ = from._impl_.expiryunixts_; + _this->_internal_mutable_typingmessage()->::SessionProtos::TypingMessage::MergeFrom( + from._internal_typingmessage()); } if (cached_has_bits & 0x00000010u) { - _this->_impl_.version_ = from._impl_.version_; + _this->_internal_mutable_dataextractionnotification()->::SessionProtos::DataExtractionNotification::MergeFrom( + from._internal_dataextractionnotification()); + } + if (cached_has_bits & 0x00000020u) { + _this->_internal_mutable_unsendrequest()->::SessionProtos::UnsendRequest::MergeFrom( + from._internal_unsendrequest()); + } + if (cached_has_bits & 0x00000040u) { + _this->_internal_mutable_messagerequestresponse()->::SessionProtos::MessageRequestResponse::MergeFrom( + from._internal_messagerequestresponse()); + } + if (cached_has_bits & 0x00000080u) { + _this->_internal_mutable_sharedconfigmessage()->::SessionProtos::SharedConfigMessage::MergeFrom( + from._internal_sharedconfigmessage()); + } + } + if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000100u) { + _this->_impl_.expirationtype_ = from._impl_.expirationtype_; + } + if (cached_has_bits & 0x00000200u) { + _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; + } + if (cached_has_bits & 0x00000400u) { + _this->_impl_.sigtimestamp_ = from._impl_.sigtimestamp_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void ProProof::CopyFrom(const ProProof& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProProof) +void Content::CopyFrom(const Content& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.Content) if (&from == this) return; Clear(); MergeFrom(from); } -bool ProProof::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - return true; -} - -void ProProof::InternalSwap(ProProof* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.genindexhash_, lhs_arena, - &other->_impl_.genindexhash_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.rotatingpublickey_, lhs_arena, - &other->_impl_.rotatingpublickey_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.sig_, lhs_arena, - &other->_impl_.sig_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ProProof, _impl_.version_) - + sizeof(ProProof::_impl_.version_) - - PROTOBUF_FIELD_OFFSET(ProProof, _impl_.expiryunixts_)>( - reinterpret_cast(&_impl_.expiryunixts_), - reinterpret_cast(&other->_impl_.expiryunixts_)); +bool Content::IsInitialized() const { + if (_internal_has_datamessage()) { + if (!_impl_.datamessage_->IsInitialized()) return false; + } + if (_internal_has_callmessage()) { + if (!_impl_.callmessage_->IsInitialized()) return false; + } + if (_internal_has_receiptmessage()) { + if (!_impl_.receiptmessage_->IsInitialized()) return false; + } + if (_internal_has_typingmessage()) { + if (!_impl_.typingmessage_->IsInitialized()) return false; + } + if (_internal_has_dataextractionnotification()) { + if (!_impl_.dataextractionnotification_->IsInitialized()) return false; + } + if (_internal_has_unsendrequest()) { + if (!_impl_.unsendrequest_->IsInitialized()) return false; + } + if (_internal_has_messagerequestresponse()) { + if (!_impl_.messagerequestresponse_->IsInitialized()) return false; + } + if (_internal_has_sharedconfigmessage()) { + if (!_impl_.sharedconfigmessage_->IsInitialized()) return false; + } + return true; } -std::string ProProof::GetTypeName() const { - return "SessionProtos.ProProof"; +void Content::InternalSwap(Content* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Content, _impl_.sigtimestamp_) + + sizeof(Content::_impl_.sigtimestamp_) + - PROTOBUF_FIELD_OFFSET(Content, _impl_.datamessage_)>( + reinterpret_cast(&_impl_.datamessage_), + reinterpret_cast(&other->_impl_.datamessage_)); } +::PROTOBUF_NAMESPACE_ID::Metadata Content::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[4]); +} // =================================================================== -class ProConfig::_Internal { +class CallMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_rotatingprivkey(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::SessionProtos::ProProof& proof(const ProConfig* msg); - static void set_has_proof(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static void set_has_uuid(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } static bool MissingRequiredFields(const HasBits& has_bits) { return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -const ::SessionProtos::ProProof& -ProConfig::_Internal::proof(const ProConfig* msg) { - return *msg->_impl_.proof_; -} -ProConfig::ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, +CallMessage::CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ProConfig) + // @@protoc_insertion_point(arena_constructor:SessionProtos.CallMessage) } -ProConfig::ProConfig(const ProConfig& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ProConfig* const _this = this; (void)_this; +CallMessage::CallMessage(const CallMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + CallMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.rotatingprivkey_){} - , decltype(_impl_.proof_){nullptr}}; + , decltype(_impl_.sdps_){from._impl_.sdps_} + , decltype(_impl_.sdpmlineindexes_){from._impl_.sdpmlineindexes_} + , decltype(_impl_.sdpmids_){from._impl_.sdpmids_} + , decltype(_impl_.uuid_){} + , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.rotatingprivkey_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.uuid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + _impl_.uuid_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_rotatingprivkey()) { - _this->_impl_.rotatingprivkey_.Set(from._internal_rotatingprivkey(), + if (from._internal_has_uuid()) { + _this->_impl_.uuid_.Set(from._internal_uuid(), _this->GetArenaForAllocation()); } - if (from._internal_has_proof()) { - _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); - } - // @@protoc_insertion_point(copy_constructor:SessionProtos.ProConfig) + _this->_impl_.type_ = from._impl_.type_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.CallMessage) } -inline void ProConfig::SharedCtor( +inline void CallMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.rotatingprivkey_){} - , decltype(_impl_.proof_){nullptr} + , decltype(_impl_.sdps_){arena} + , decltype(_impl_.sdpmlineindexes_){arena} + , decltype(_impl_.sdpmids_){arena} + , decltype(_impl_.uuid_){} + , decltype(_impl_.type_){6} }; - _impl_.rotatingprivkey_.InitDefault(); + _impl_.uuid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + _impl_.uuid_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ProConfig::~ProConfig() { - // @@protoc_insertion_point(destructor:SessionProtos.ProConfig) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +CallMessage::~CallMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.CallMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void ProConfig::SharedDtor() { +inline void CallMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.rotatingprivkey_.Destroy(); - if (this != internal_default_instance()) delete _impl_.proof_; + _impl_.sdps_.~RepeatedPtrField(); + _impl_.sdpmlineindexes_.~RepeatedField(); + _impl_.sdpmids_.~RepeatedPtrField(); + _impl_.uuid_.Destroy(); } -void ProConfig::SetCachedSize(int size) const { +void CallMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ProConfig::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ProConfig) +void CallMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.CallMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.sdps_.Clear(); + _impl_.sdpmlineindexes_.Clear(); + _impl_.sdpmids_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.rotatingprivkey_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(_impl_.proof_ != nullptr); - _impl_.proof_->Clear(); + _impl_.uuid_.ClearNonDefaultToEmpty(); } + _impl_.type_ = 6; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ProConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes rotatingPrivKey = 1; + // required .SessionProtos.CallMessage.Type type = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_rotatingprivkey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::CallMessage_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::CallMessage_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // required .SessionProtos.ProProof proof = 2; + // repeated string sdps = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_sdps(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.CallMessage.sdps"); + #endif // !NDEBUG + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else + goto handle_unusual; + continue; + // repeated uint32 sdpMLineIndexes = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_sdpmlineindexes(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<24>(ptr)); + } else if (static_cast(tag) == 26) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt32Parser(_internal_mutable_sdpmlineindexes(), ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // repeated string sdpMids = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_sdpmids(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.CallMessage.sdpMids"); + #endif // !NDEBUG + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else + goto handle_unusual; + continue; + // required string uuid = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_uuid(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.CallMessage.uuid"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -2994,7 +3477,7 @@ const char* ProConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -3007,68 +3490,96 @@ const char* ProConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx #undef CHK_ } -uint8_t* ProConfig::_InternalSerialize( +uint8_t* CallMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProConfig) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.CallMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes rotatingPrivKey = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_rotatingprivkey(), target); + // required .SessionProtos.CallMessage.Type type = 1; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - // required .SessionProtos.ProProof proof = 2; - if (cached_has_bits & 0x00000002u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, _Internal::proof(this), - _Internal::proof(this).GetCachedSize(), target, stream); + // repeated string sdps = 2; + for (int i = 0, n = this->_internal_sdps_size(); i < n; i++) { + const auto& s = this->_internal_sdps(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.CallMessage.sdps"); + target = stream->WriteString(2, s, target); + } + + // repeated uint32 sdpMLineIndexes = 3; + for (int i = 0, n = this->_internal_sdpmlineindexes_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(3, this->_internal_sdpmlineindexes(i), target); + } + + // repeated string sdpMids = 4; + for (int i = 0, n = this->_internal_sdpmids_size(); i < n; i++) { + const auto& s = this->_internal_sdpmids(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.CallMessage.sdpMids"); + target = stream->WriteString(4, s, target); + } + + // required string uuid = 5; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_uuid().data(), static_cast(this->_internal_uuid().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.CallMessage.uuid"); + target = stream->WriteStringMaybeAliased( + 5, this->_internal_uuid(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProConfig) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.CallMessage) return target; } -size_t ProConfig::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProConfig) +size_t CallMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.CallMessage) size_t total_size = 0; - if (_internal_has_rotatingprivkey()) { - // required bytes rotatingPrivKey = 1; + if (_internal_has_uuid()) { + // required string uuid = 5; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingprivkey()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_uuid()); } - if (_internal_has_proof()) { - // required .SessionProtos.ProProof proof = 2; + if (_internal_has_type()) { + // required .SessionProtos.CallMessage.Type type = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } return total_size; } -size_t ProConfig::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProConfig) +size_t CallMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.CallMessage) size_t total_size = 0; if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes rotatingPrivKey = 1; + // required string uuid = 5; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingprivkey()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_uuid()); - // required .SessionProtos.ProProof proof = 2; + // required .SessionProtos.CallMessage.Type type = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -3077,83 +3588,108 @@ size_t ProConfig::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + // repeated string sdps = 2; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdps_.size()); + for (int i = 0, n = _impl_.sdps_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.sdps_.Get(i)); + } + + // repeated uint32 sdpMLineIndexes = 3; + { + size_t data_size = ::_pbi::WireFormatLite:: + UInt32Size(this->_impl_.sdpmlineindexes_); + total_size += 1 * + ::_pbi::FromIntSize(this->_internal_sdpmlineindexes_size()); + total_size += data_size; + } + + // repeated string sdpMids = 4; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdpmids_.size()); + for (int i = 0, n = _impl_.sdpmids_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.sdpmids_.Get(i)); } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} -void ProConfig::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void ProConfig::MergeFrom(const ProConfig& from) { - ProConfig* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProConfig) +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CallMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + CallMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CallMessage::GetClassData() const { return &_class_data_; } + + +void CallMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.CallMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; + _this->_impl_.sdps_.MergeFrom(from._impl_.sdps_); + _this->_impl_.sdpmlineindexes_.MergeFrom(from._impl_.sdpmlineindexes_); + _this->_impl_.sdpmids_.MergeFrom(from._impl_.sdpmids_); cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_rotatingprivkey(from._internal_rotatingprivkey()); + _this->_internal_set_uuid(from._internal_uuid()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( - from._internal_proof()); + _this->_impl_.type_ = from._impl_.type_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void ProConfig::CopyFrom(const ProConfig& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProConfig) +void CallMessage::CopyFrom(const CallMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.CallMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool ProConfig::IsInitialized() const { +bool CallMessage::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (_internal_has_proof()) { - if (!_impl_.proof_->IsInitialized()) return false; - } return true; } -void ProConfig::InternalSwap(ProConfig* other) { +void CallMessage::InternalSwap(CallMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.sdps_.InternalSwap(&other->_impl_.sdps_); + _impl_.sdpmlineindexes_.InternalSwap(&other->_impl_.sdpmlineindexes_); + _impl_.sdpmids_.InternalSwap(&other->_impl_.sdpmids_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.rotatingprivkey_, lhs_arena, - &other->_impl_.rotatingprivkey_, rhs_arena + &_impl_.uuid_, lhs_arena, + &other->_impl_.uuid_, rhs_arena ); - swap(_impl_.proof_, other->_impl_.proof_); + swap(_impl_.type_, other->_impl_.type_); } -std::string ProConfig::GetTypeName() const { - return "SessionProtos.ProConfig"; +::PROTOBUF_NAMESPACE_ID::Metadata CallMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[5]); } - // =================================================================== -class ProMessageConfig::_Internal { +class KeyPair::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static const ::SessionProtos::ProProof& proof(const ProMessageConfig* msg); - static void set_has_proof(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_publickey(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_flags(HasBits* has_bits) { + static void set_has_privatekey(HasBits* has_bits) { (*has_bits)[0] |= 2u; } static bool MissingRequiredFields(const HasBits& has_bits) { @@ -3161,99 +3697,120 @@ class ProMessageConfig::_Internal { } }; -const ::SessionProtos::ProProof& -ProMessageConfig::_Internal::proof(const ProMessageConfig* msg) { - return *msg->_impl_.proof_; -} -ProMessageConfig::ProMessageConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, +KeyPair::KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ProMessageConfig) + // @@protoc_insertion_point(arena_constructor:SessionProtos.KeyPair) } -ProMessageConfig::ProMessageConfig(const ProMessageConfig& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ProMessageConfig* const _this = this; (void)_this; +KeyPair::KeyPair(const KeyPair& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + KeyPair* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.proof_){nullptr} - , decltype(_impl_.flags_){}}; + , decltype(_impl_.publickey_){} + , decltype(_impl_.privatekey_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - if (from._internal_has_proof()) { - _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.publickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.publickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_publickey()) { + _this->_impl_.publickey_.Set(from._internal_publickey(), + _this->GetArenaForAllocation()); } - _this->_impl_.flags_ = from._impl_.flags_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.ProMessageConfig) + _impl_.privatekey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.privatekey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_privatekey()) { + _this->_impl_.privatekey_.Set(from._internal_privatekey(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.KeyPair) } -inline void ProMessageConfig::SharedCtor( +inline void KeyPair::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.proof_){nullptr} - , decltype(_impl_.flags_){0u} + , decltype(_impl_.publickey_){} + , decltype(_impl_.privatekey_){} }; + _impl_.publickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.publickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.privatekey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.privatekey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ProMessageConfig::~ProMessageConfig() { - // @@protoc_insertion_point(destructor:SessionProtos.ProMessageConfig) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +KeyPair::~KeyPair() { + // @@protoc_insertion_point(destructor:SessionProtos.KeyPair) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void ProMessageConfig::SharedDtor() { +inline void KeyPair::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - if (this != internal_default_instance()) delete _impl_.proof_; + _impl_.publickey_.Destroy(); + _impl_.privatekey_.Destroy(); } -void ProMessageConfig::SetCachedSize(int size) const { +void KeyPair::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ProMessageConfig::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ProMessageConfig) +void KeyPair::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.KeyPair) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(_impl_.proof_ != nullptr); - _impl_.proof_->Clear(); + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _impl_.publickey_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.privatekey_.ClearNonDefaultToEmpty(); + } } - _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ProMessageConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.ProProof proof = 1; + // required bytes publicKey = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); + auto str = _internal_mutable_publickey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // required uint32 flags = 2; + // required bytes privateKey = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_privatekey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; @@ -3269,7 +3826,7 @@ const char* ProMessageConfig::_InternalParse(const char* ptr, ::_pbi::ParseConte } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -3282,64 +3839,67 @@ const char* ProMessageConfig::_InternalParse(const char* ptr, ::_pbi::ParseConte #undef CHK_ } -uint8_t* ProMessageConfig::_InternalSerialize( +uint8_t* KeyPair::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProMessageConfig) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.KeyPair) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.ProProof proof = 1; + // required bytes publicKey = 1; if (cached_has_bits & 0x00000001u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, _Internal::proof(this), - _Internal::proof(this).GetCachedSize(), target, stream); + target = stream->WriteBytesMaybeAliased( + 1, this->_internal_publickey(), target); } - // required uint32 flags = 2; + // required bytes privateKey = 2; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_flags(), target); + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_privatekey(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProMessageConfig) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.KeyPair) return target; } -size_t ProMessageConfig::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProMessageConfig) +size_t KeyPair::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.KeyPair) size_t total_size = 0; - if (_internal_has_proof()) { - // required .SessionProtos.ProProof proof = 1; + if (_internal_has_publickey()) { + // required bytes publicKey = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); } - if (_internal_has_flags()) { - // required uint32 flags = 2; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + if (_internal_has_privatekey()) { + // required bytes privateKey = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_privatekey()); } return total_size; } -size_t ProMessageConfig::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProMessageConfig) +size_t KeyPair::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.KeyPair) size_t total_size = 0; if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required .SessionProtos.ProProof proof = 1; + // required bytes publicKey = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_publickey()); - // required uint32 flags = 2; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + // required bytes privateKey = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_privatekey()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -3348,23 +3908,20 @@ size_t ProMessageConfig::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void ProMessageConfig::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData KeyPair::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + KeyPair::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*KeyPair::GetClassData() const { return &_class_data_; } -void ProMessageConfig::MergeFrom(const ProMessageConfig& from) { - ProMessageConfig* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProMessageConfig) + +void KeyPair::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.KeyPair) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -3372,378 +3929,156 @@ void ProMessageConfig::MergeFrom(const ProMessageConfig& from) { cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( - from._internal_proof()); + _this->_internal_set_publickey(from._internal_publickey()); } if (cached_has_bits & 0x00000002u) { - _this->_impl_.flags_ = from._impl_.flags_; + _this->_internal_set_privatekey(from._internal_privatekey()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void ProMessageConfig::CopyFrom(const ProMessageConfig& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProMessageConfig) +void KeyPair::CopyFrom(const KeyPair& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.KeyPair) if (&from == this) return; Clear(); MergeFrom(from); } -bool ProMessageConfig::IsInitialized() const { +bool KeyPair::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (_internal_has_proof()) { - if (!_impl_.proof_->IsInitialized()) return false; - } return true; } -void ProMessageConfig::InternalSwap(ProMessageConfig* other) { +void KeyPair::InternalSwap(KeyPair* other) { using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ProMessageConfig, _impl_.flags_) - + sizeof(ProMessageConfig::_impl_.flags_) - - PROTOBUF_FIELD_OFFSET(ProMessageConfig, _impl_.proof_)>( - reinterpret_cast(&_impl_.proof_), - reinterpret_cast(&other->_impl_.proof_)); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.publickey_, lhs_arena, + &other->_impl_.publickey_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.privatekey_, lhs_arena, + &other->_impl_.privatekey_, rhs_arena + ); } -std::string ProMessageConfig::GetTypeName() const { - return "SessionProtos.ProMessageConfig"; +::PROTOBUF_NAMESPACE_ID::Metadata KeyPair::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[6]); } - // =================================================================== -class Content::_Internal { +class DataExtractionNotification::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static const ::SessionProtos::DataMessage& datamessage(const Content* msg); - static void set_has_datamessage(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::SessionProtos::CallMessage& callmessage(const Content* msg); - static void set_has_callmessage(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::ReceiptMessage& receiptmessage(const Content* msg); - static void set_has_receiptmessage(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static const ::SessionProtos::TypingMessage& typingmessage(const Content* msg); - static void set_has_typingmessage(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static const ::SessionProtos::ConfigurationMessage& configurationmessage(const Content* msg); - static void set_has_configurationmessage(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static const ::SessionProtos::DataExtractionNotification& dataextractionnotification(const Content* msg); - static void set_has_dataextractionnotification(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static const ::SessionProtos::UnsendRequest& unsendrequest(const Content* msg); - static void set_has_unsendrequest(HasBits* has_bits) { - (*has_bits)[0] |= 64u; - } - static const ::SessionProtos::MessageRequestResponse& messagerequestresponse(const Content* msg); - static void set_has_messagerequestresponse(HasBits* has_bits) { - (*has_bits)[0] |= 128u; - } - static const ::SessionProtos::SharedConfigMessage& sharedconfigmessage(const Content* msg); - static void set_has_sharedconfigmessage(HasBits* has_bits) { - (*has_bits)[0] |= 256u; + static void set_has_timestamp(HasBits* has_bits) { + (*has_bits)[0] |= 1u; } - static const ::SessionProtos::ProMessageConfig& promessageconfig(const Content* msg); - static void set_has_promessageconfig(HasBits* has_bits) { - (*has_bits)[0] |= 512u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000002) ^ 0x00000002) != 0; } }; -const ::SessionProtos::DataMessage& -Content::_Internal::datamessage(const Content* msg) { - return *msg->_impl_.datamessage_; -} -const ::SessionProtos::CallMessage& -Content::_Internal::callmessage(const Content* msg) { - return *msg->_impl_.callmessage_; -} -const ::SessionProtos::ReceiptMessage& -Content::_Internal::receiptmessage(const Content* msg) { - return *msg->_impl_.receiptmessage_; -} -const ::SessionProtos::TypingMessage& -Content::_Internal::typingmessage(const Content* msg) { - return *msg->_impl_.typingmessage_; -} -const ::SessionProtos::ConfigurationMessage& -Content::_Internal::configurationmessage(const Content* msg) { - return *msg->_impl_.configurationmessage_; -} -const ::SessionProtos::DataExtractionNotification& -Content::_Internal::dataextractionnotification(const Content* msg) { - return *msg->_impl_.dataextractionnotification_; -} -const ::SessionProtos::UnsendRequest& -Content::_Internal::unsendrequest(const Content* msg) { - return *msg->_impl_.unsendrequest_; -} -const ::SessionProtos::MessageRequestResponse& -Content::_Internal::messagerequestresponse(const Content* msg) { - return *msg->_impl_.messagerequestresponse_; -} -const ::SessionProtos::SharedConfigMessage& -Content::_Internal::sharedconfigmessage(const Content* msg) { - return *msg->_impl_.sharedconfigmessage_; -} -const ::SessionProtos::ProMessageConfig& -Content::_Internal::promessageconfig(const Content* msg) { - return *msg->_impl_.promessageconfig_; -} -Content::Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataExtractionNotification::DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.Content) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataExtractionNotification) } -Content::Content(const Content& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - Content* const _this = this; (void)_this; +DataExtractionNotification::DataExtractionNotification(const DataExtractionNotification& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataExtractionNotification* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.datamessage_){nullptr} - , decltype(_impl_.callmessage_){nullptr} - , decltype(_impl_.receiptmessage_){nullptr} - , decltype(_impl_.typingmessage_){nullptr} - , decltype(_impl_.configurationmessage_){nullptr} - , decltype(_impl_.dataextractionnotification_){nullptr} - , decltype(_impl_.unsendrequest_){nullptr} - , decltype(_impl_.messagerequestresponse_){nullptr} - , decltype(_impl_.sharedconfigmessage_){nullptr} - , decltype(_impl_.promessageconfig_){nullptr}}; + , decltype(_impl_.timestamp_){} + , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - if (from._internal_has_datamessage()) { - _this->_impl_.datamessage_ = new ::SessionProtos::DataMessage(*from._impl_.datamessage_); - } - if (from._internal_has_callmessage()) { - _this->_impl_.callmessage_ = new ::SessionProtos::CallMessage(*from._impl_.callmessage_); - } - if (from._internal_has_receiptmessage()) { - _this->_impl_.receiptmessage_ = new ::SessionProtos::ReceiptMessage(*from._impl_.receiptmessage_); - } - if (from._internal_has_typingmessage()) { - _this->_impl_.typingmessage_ = new ::SessionProtos::TypingMessage(*from._impl_.typingmessage_); - } - if (from._internal_has_configurationmessage()) { - _this->_impl_.configurationmessage_ = new ::SessionProtos::ConfigurationMessage(*from._impl_.configurationmessage_); - } - if (from._internal_has_dataextractionnotification()) { - _this->_impl_.dataextractionnotification_ = new ::SessionProtos::DataExtractionNotification(*from._impl_.dataextractionnotification_); - } - if (from._internal_has_unsendrequest()) { - _this->_impl_.unsendrequest_ = new ::SessionProtos::UnsendRequest(*from._impl_.unsendrequest_); - } - if (from._internal_has_messagerequestresponse()) { - _this->_impl_.messagerequestresponse_ = new ::SessionProtos::MessageRequestResponse(*from._impl_.messagerequestresponse_); - } - if (from._internal_has_sharedconfigmessage()) { - _this->_impl_.sharedconfigmessage_ = new ::SessionProtos::SharedConfigMessage(*from._impl_.sharedconfigmessage_); - } - if (from._internal_has_promessageconfig()) { - _this->_impl_.promessageconfig_ = new ::SessionProtos::ProMessageConfig(*from._impl_.promessageconfig_); - } - // @@protoc_insertion_point(copy_constructor:SessionProtos.Content) + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, + static_cast(reinterpret_cast(&_impl_.type_) - + reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.type_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataExtractionNotification) } -inline void Content::SharedCtor( +inline void DataExtractionNotification::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.datamessage_){nullptr} - , decltype(_impl_.callmessage_){nullptr} - , decltype(_impl_.receiptmessage_){nullptr} - , decltype(_impl_.typingmessage_){nullptr} - , decltype(_impl_.configurationmessage_){nullptr} - , decltype(_impl_.dataextractionnotification_){nullptr} - , decltype(_impl_.unsendrequest_){nullptr} - , decltype(_impl_.messagerequestresponse_){nullptr} - , decltype(_impl_.sharedconfigmessage_){nullptr} - , decltype(_impl_.promessageconfig_){nullptr} + , decltype(_impl_.timestamp_){uint64_t{0u}} + , decltype(_impl_.type_){1} }; } -Content::~Content() { - // @@protoc_insertion_point(destructor:SessionProtos.Content) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +DataExtractionNotification::~DataExtractionNotification() { + // @@protoc_insertion_point(destructor:SessionProtos.DataExtractionNotification) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void Content::SharedDtor() { +inline void DataExtractionNotification::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - if (this != internal_default_instance()) delete _impl_.datamessage_; - if (this != internal_default_instance()) delete _impl_.callmessage_; - if (this != internal_default_instance()) delete _impl_.receiptmessage_; - if (this != internal_default_instance()) delete _impl_.typingmessage_; - if (this != internal_default_instance()) delete _impl_.configurationmessage_; - if (this != internal_default_instance()) delete _impl_.dataextractionnotification_; - if (this != internal_default_instance()) delete _impl_.unsendrequest_; - if (this != internal_default_instance()) delete _impl_.messagerequestresponse_; - if (this != internal_default_instance()) delete _impl_.sharedconfigmessage_; - if (this != internal_default_instance()) delete _impl_.promessageconfig_; } -void Content::SetCachedSize(int size) const { +void DataExtractionNotification::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void Content::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.Content) +void DataExtractionNotification::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataExtractionNotification) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(_impl_.datamessage_ != nullptr); - _impl_.datamessage_->Clear(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(_impl_.callmessage_ != nullptr); - _impl_.callmessage_->Clear(); - } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.receiptmessage_ != nullptr); - _impl_.receiptmessage_->Clear(); - } - if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(_impl_.typingmessage_ != nullptr); - _impl_.typingmessage_->Clear(); - } - if (cached_has_bits & 0x00000010u) { - GOOGLE_DCHECK(_impl_.configurationmessage_ != nullptr); - _impl_.configurationmessage_->Clear(); - } - if (cached_has_bits & 0x00000020u) { - GOOGLE_DCHECK(_impl_.dataextractionnotification_ != nullptr); - _impl_.dataextractionnotification_->Clear(); - } - if (cached_has_bits & 0x00000040u) { - GOOGLE_DCHECK(_impl_.unsendrequest_ != nullptr); - _impl_.unsendrequest_->Clear(); - } - if (cached_has_bits & 0x00000080u) { - GOOGLE_DCHECK(_impl_.messagerequestresponse_ != nullptr); - _impl_.messagerequestresponse_->Clear(); - } - } - if (cached_has_bits & 0x00000300u) { - if (cached_has_bits & 0x00000100u) { - GOOGLE_DCHECK(_impl_.sharedconfigmessage_ != nullptr); - _impl_.sharedconfigmessage_->Clear(); - } - if (cached_has_bits & 0x00000200u) { - GOOGLE_DCHECK(_impl_.promessageconfig_ != nullptr); - _impl_.promessageconfig_->Clear(); - } + if (cached_has_bits & 0x00000003u) { + _impl_.timestamp_ = uint64_t{0u}; + _impl_.type_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional .SessionProtos.DataMessage dataMessage = 1; + // required .SessionProtos.DataExtractionNotification.Type type = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_datamessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.CallMessage callMessage = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_callmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr = ctx->ParseMessage(_internal_mutable_receiptmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.TypingMessage typingMessage = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr = ctx->ParseMessage(_internal_mutable_typingmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - ptr = ctx->ParseMessage(_internal_mutable_configurationmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { - ptr = ctx->ParseMessage(_internal_mutable_dataextractionnotification(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - case 9: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { - ptr = ctx->ParseMessage(_internal_mutable_unsendrequest(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - case 10: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { - ptr = ctx->ParseMessage(_internal_mutable_messagerequestresponse(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { - ptr = ctx->ParseMessage(_internal_mutable_sharedconfigmessage(), ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataExtractionNotification_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::DataExtractionNotification_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; - case 12: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 98)) { - ptr = ctx->ParseMessage(_internal_mutable_promessageconfig(), ptr); + // optional uint64 timestamp = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_timestamp(&has_bits); + _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3759,7 +4094,7 @@ const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -3772,478 +4107,244 @@ const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) #undef CHK_ } -uint8_t* Content::_InternalSerialize( +uint8_t* DataExtractionNotification::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.Content) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataExtractionNotification) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional .SessionProtos.DataMessage dataMessage = 1; - if (cached_has_bits & 0x00000001u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, _Internal::datamessage(this), - _Internal::datamessage(this).GetCachedSize(), target, stream); - } - - // optional .SessionProtos.CallMessage callMessage = 3; + // required .SessionProtos.DataExtractionNotification.Type type = 1; if (cached_has_bits & 0x00000002u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::callmessage(this), - _Internal::callmessage(this).GetCachedSize(), target, stream); - } - - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(5, _Internal::receiptmessage(this), - _Internal::receiptmessage(this).GetCachedSize(), target, stream); - } - - // optional .SessionProtos.TypingMessage typingMessage = 6; - if (cached_has_bits & 0x00000008u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, _Internal::typingmessage(this), - _Internal::typingmessage(this).GetCachedSize(), target, stream); - } - - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - if (cached_has_bits & 0x00000010u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, _Internal::configurationmessage(this), - _Internal::configurationmessage(this).GetCachedSize(), target, stream); + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - if (cached_has_bits & 0x00000020u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(8, _Internal::dataextractionnotification(this), - _Internal::dataextractionnotification(this).GetCachedSize(), target, stream); + // optional uint64 timestamp = 2; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_timestamp(), target); } - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - if (cached_has_bits & 0x00000040u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(9, _Internal::unsendrequest(this), - _Internal::unsendrequest(this).GetCachedSize(), target, stream); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataExtractionNotification) + return target; +} - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - if (cached_has_bits & 0x00000080u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(10, _Internal::messagerequestresponse(this), - _Internal::messagerequestresponse(this).GetCachedSize(), target, stream); - } +size_t DataExtractionNotification::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataExtractionNotification) + size_t total_size = 0; - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - if (cached_has_bits & 0x00000100u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(11, _Internal::sharedconfigmessage(this), - _Internal::sharedconfigmessage(this).GetCachedSize(), target, stream); + // required .SessionProtos.DataExtractionNotification.Type type = 1; + if (_internal_has_type()) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; - if (cached_has_bits & 0x00000200u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(12, _Internal::promessageconfig(this), - _Internal::promessageconfig(this).GetCachedSize(), target, stream); + // optional uint64 timestamp = 2; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Content) - return target; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -size_t Content::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.Content) - size_t total_size = 0; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataExtractionNotification::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataExtractionNotification::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataExtractionNotification::GetClassData() const { return &_class_data_; } + +void DataExtractionNotification::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataExtractionNotification) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - // optional .SessionProtos.DataMessage dataMessage = 1; + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.datamessage_); + _this->_impl_.timestamp_ = from._impl_.timestamp_; } - - // optional .SessionProtos.CallMessage callMessage = 3; if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.callmessage_); + _this->_impl_.type_ = from._impl_.type_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.receiptmessage_); - } - - // optional .SessionProtos.TypingMessage typingMessage = 6; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.typingmessage_); - } - - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.configurationmessage_); - } - - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.dataextractionnotification_); - } - - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - if (cached_has_bits & 0x00000040u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.unsendrequest_); - } - - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - if (cached_has_bits & 0x00000080u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.messagerequestresponse_); - } - - } - if (cached_has_bits & 0x00000300u) { - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - if (cached_has_bits & 0x00000100u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.sharedconfigmessage_); - } - - // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; - if (cached_has_bits & 0x00000200u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.promessageconfig_); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void Content::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} - -void Content::MergeFrom(const Content& from) { - Content* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Content) - GOOGLE_DCHECK_NE(&from, _this); - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - if (cached_has_bits & 0x00000001u) { - _this->_internal_mutable_datamessage()->::SessionProtos::DataMessage::MergeFrom( - from._internal_datamessage()); - } - if (cached_has_bits & 0x00000002u) { - _this->_internal_mutable_callmessage()->::SessionProtos::CallMessage::MergeFrom( - from._internal_callmessage()); - } - if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_receiptmessage()->::SessionProtos::ReceiptMessage::MergeFrom( - from._internal_receiptmessage()); - } - if (cached_has_bits & 0x00000008u) { - _this->_internal_mutable_typingmessage()->::SessionProtos::TypingMessage::MergeFrom( - from._internal_typingmessage()); - } - if (cached_has_bits & 0x00000010u) { - _this->_internal_mutable_configurationmessage()->::SessionProtos::ConfigurationMessage::MergeFrom( - from._internal_configurationmessage()); - } - if (cached_has_bits & 0x00000020u) { - _this->_internal_mutable_dataextractionnotification()->::SessionProtos::DataExtractionNotification::MergeFrom( - from._internal_dataextractionnotification()); - } - if (cached_has_bits & 0x00000040u) { - _this->_internal_mutable_unsendrequest()->::SessionProtos::UnsendRequest::MergeFrom( - from._internal_unsendrequest()); - } - if (cached_has_bits & 0x00000080u) { - _this->_internal_mutable_messagerequestresponse()->::SessionProtos::MessageRequestResponse::MergeFrom( - from._internal_messagerequestresponse()); - } - } - if (cached_has_bits & 0x00000300u) { - if (cached_has_bits & 0x00000100u) { - _this->_internal_mutable_sharedconfigmessage()->::SessionProtos::SharedConfigMessage::MergeFrom( - from._internal_sharedconfigmessage()); - } - if (cached_has_bits & 0x00000200u) { - _this->_internal_mutable_promessageconfig()->::SessionProtos::ProMessageConfig::MergeFrom( - from._internal_promessageconfig()); - } - } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); -} - -void Content::CopyFrom(const Content& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.Content) +void DataExtractionNotification::CopyFrom(const DataExtractionNotification& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataExtractionNotification) if (&from == this) return; Clear(); MergeFrom(from); } -bool Content::IsInitialized() const { - if (_internal_has_datamessage()) { - if (!_impl_.datamessage_->IsInitialized()) return false; - } - if (_internal_has_callmessage()) { - if (!_impl_.callmessage_->IsInitialized()) return false; - } - if (_internal_has_receiptmessage()) { - if (!_impl_.receiptmessage_->IsInitialized()) return false; - } - if (_internal_has_typingmessage()) { - if (!_impl_.typingmessage_->IsInitialized()) return false; - } - if (_internal_has_configurationmessage()) { - if (!_impl_.configurationmessage_->IsInitialized()) return false; - } - if (_internal_has_dataextractionnotification()) { - if (!_impl_.dataextractionnotification_->IsInitialized()) return false; - } - if (_internal_has_unsendrequest()) { - if (!_impl_.unsendrequest_->IsInitialized()) return false; - } - if (_internal_has_messagerequestresponse()) { - if (!_impl_.messagerequestresponse_->IsInitialized()) return false; - } - if (_internal_has_sharedconfigmessage()) { - if (!_impl_.sharedconfigmessage_->IsInitialized()) return false; - } - if (_internal_has_promessageconfig()) { - if (!_impl_.promessageconfig_->IsInitialized()) return false; - } +bool DataExtractionNotification::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void Content::InternalSwap(Content* other) { +void DataExtractionNotification::InternalSwap(DataExtractionNotification* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Content, _impl_.promessageconfig_) - + sizeof(Content::_impl_.promessageconfig_) - - PROTOBUF_FIELD_OFFSET(Content, _impl_.datamessage_)>( - reinterpret_cast(&_impl_.datamessage_), - reinterpret_cast(&other->_impl_.datamessage_)); + swap(_impl_.timestamp_, other->_impl_.timestamp_); + swap(_impl_.type_, other->_impl_.type_); } -std::string Content::GetTypeName() const { - return "SessionProtos.Content"; +::PROTOBUF_NAMESPACE_ID::Metadata DataExtractionNotification::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[7]); } - // =================================================================== -class CallMessage::_Internal { +class LokiProfile::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_uuid(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_displayname(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + static void set_has_profilepicture(HasBits* has_bits) { + (*has_bits)[0] |= 2u; } }; -CallMessage::CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +LokiProfile::LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.CallMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.LokiProfile) } -CallMessage::CallMessage(const CallMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - CallMessage* const _this = this; (void)_this; +LokiProfile::LokiProfile(const LokiProfile& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + LokiProfile* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.sdps_){from._impl_.sdps_} - , decltype(_impl_.sdpmlineindexes_){from._impl_.sdpmlineindexes_} - , decltype(_impl_.sdpmids_){from._impl_.sdpmids_} - , decltype(_impl_.uuid_){} - , decltype(_impl_.type_){}}; + , decltype(_impl_.displayname_){} + , decltype(_impl_.profilepicture_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.uuid_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.displayname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.uuid_.Set("", GetArenaForAllocation()); + _impl_.displayname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_uuid()) { - _this->_impl_.uuid_.Set(from._internal_uuid(), + if (from._internal_has_displayname()) { + _this->_impl_.displayname_.Set(from._internal_displayname(), _this->GetArenaForAllocation()); } - _this->_impl_.type_ = from._impl_.type_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.CallMessage) + _impl_.profilepicture_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_profilepicture()) { + _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.LokiProfile) } -inline void CallMessage::SharedCtor( +inline void LokiProfile::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.sdps_){arena} - , decltype(_impl_.sdpmlineindexes_){arena} - , decltype(_impl_.sdpmids_){arena} - , decltype(_impl_.uuid_){} - , decltype(_impl_.type_){6} + , decltype(_impl_.displayname_){} + , decltype(_impl_.profilepicture_){} }; - _impl_.uuid_.InitDefault(); + _impl_.displayname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.uuid_.Set("", GetArenaForAllocation()); + _impl_.displayname_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.profilepicture_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -CallMessage::~CallMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.CallMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +LokiProfile::~LokiProfile() { + // @@protoc_insertion_point(destructor:SessionProtos.LokiProfile) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void CallMessage::SharedDtor() { +inline void LokiProfile::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.sdps_.~RepeatedPtrField(); - _impl_.sdpmlineindexes_.~RepeatedField(); - _impl_.sdpmids_.~RepeatedPtrField(); - _impl_.uuid_.Destroy(); + _impl_.displayname_.Destroy(); + _impl_.profilepicture_.Destroy(); } -void CallMessage::SetCachedSize(int size) const { +void LokiProfile::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void CallMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.CallMessage) +void LokiProfile::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.LokiProfile) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.sdps_.Clear(); - _impl_.sdpmlineindexes_.Clear(); - _impl_.sdpmids_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.uuid_.ClearNonDefaultToEmpty(); + _impl_.displayname_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.profilepicture_.ClearNonDefaultToEmpty(); } - _impl_.type_ = 6; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.CallMessage.Type type = 1; + // optional string displayName = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_displayname(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::CallMessage_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::CallMessage_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.LokiProfile.displayName"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // repeated string sdps = 2; + // optional string profilePicture = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_sdps(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else - goto handle_unusual; - continue; - // repeated uint32 sdpMLineIndexes = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_sdpmlineindexes(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<24>(ptr)); - } else if (static_cast(tag) == 26) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt32Parser(_internal_mutable_sdpmlineindexes(), ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated string sdpMids = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_sdpmids(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else - goto handle_unusual; - continue; - // required string uuid = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_uuid(); + auto str = _internal_mutable_profilepicture(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.LokiProfile.profilePicture"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4258,7 +4359,7 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4271,318 +4372,305 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c #undef CHK_ } -uint8_t* CallMessage::_InternalSerialize( +uint8_t* LokiProfile::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.CallMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.LokiProfile) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.CallMessage.Type type = 1; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); - } - - // repeated string sdps = 2; - for (int i = 0, n = this->_internal_sdps_size(); i < n; i++) { - const auto& s = this->_internal_sdps(i); - target = stream->WriteString(2, s, target); - } - - // repeated uint32 sdpMLineIndexes = 3; - for (int i = 0, n = this->_internal_sdpmlineindexes_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(3, this->_internal_sdpmlineindexes(i), target); - } - - // repeated string sdpMids = 4; - for (int i = 0, n = this->_internal_sdpmids_size(); i < n; i++) { - const auto& s = this->_internal_sdpmids(i); - target = stream->WriteString(4, s, target); + // optional string displayName = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_displayname().data(), static_cast(this->_internal_displayname().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.LokiProfile.displayName"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_displayname(), target); } - // required string uuid = 5; - if (cached_has_bits & 0x00000001u) { + // optional string profilePicture = 2; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_profilepicture().data(), static_cast(this->_internal_profilepicture().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.LokiProfile.profilePicture"); target = stream->WriteStringMaybeAliased( - 5, this->_internal_uuid(), target); + 2, this->_internal_profilepicture(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.CallMessage) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.LokiProfile) return target; } -size_t CallMessage::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.CallMessage) - size_t total_size = 0; - - if (_internal_has_uuid()) { - // required string uuid = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_uuid()); - } - - if (_internal_has_type()) { - // required .SessionProtos.CallMessage.Type type = 1; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); - } - - return total_size; -} -size_t CallMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.CallMessage) +size_t LokiProfile::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.LokiProfile) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string uuid = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_uuid()); - - // required .SessionProtos.CallMessage.Type type = 1; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated string sdps = 2; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdps_.size()); - for (int i = 0, n = _impl_.sdps_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.sdps_.Get(i)); - } - - // repeated uint32 sdpMLineIndexes = 3; - { - size_t data_size = ::_pbi::WireFormatLite:: - UInt32Size(this->_impl_.sdpmlineindexes_); - total_size += 1 * - ::_pbi::FromIntSize(this->_internal_sdpmlineindexes_size()); - total_size += data_size; - } + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + // optional string displayName = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_displayname()); + } - // repeated string sdpMids = 4; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.sdpmids_.size()); - for (int i = 0, n = _impl_.sdpmids_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.sdpmids_.Get(i)); - } + // optional string profilePicture = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_profilepicture()); + } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void CallMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData LokiProfile::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + LokiProfile::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*LokiProfile::GetClassData() const { return &_class_data_; } -void CallMessage::MergeFrom(const CallMessage& from) { - CallMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.CallMessage) + +void LokiProfile::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.LokiProfile) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.sdps_.MergeFrom(from._impl_.sdps_); - _this->_impl_.sdpmlineindexes_.MergeFrom(from._impl_.sdpmlineindexes_); - _this->_impl_.sdpmids_.MergeFrom(from._impl_.sdpmids_); cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_uuid(from._internal_uuid()); + _this->_internal_set_displayname(from._internal_displayname()); } if (cached_has_bits & 0x00000002u) { - _this->_impl_.type_ = from._impl_.type_; + _this->_internal_set_profilepicture(from._internal_profilepicture()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void CallMessage::CopyFrom(const CallMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.CallMessage) +void LokiProfile::CopyFrom(const LokiProfile& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.LokiProfile) if (&from == this) return; Clear(); MergeFrom(from); } -bool CallMessage::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool LokiProfile::IsInitialized() const { return true; } -void CallMessage::InternalSwap(CallMessage* other) { +void LokiProfile::InternalSwap(LokiProfile* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.sdps_.InternalSwap(&other->_impl_.sdps_); - _impl_.sdpmlineindexes_.InternalSwap(&other->_impl_.sdpmlineindexes_); - _impl_.sdpmids_.InternalSwap(&other->_impl_.sdpmids_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.uuid_, lhs_arena, - &other->_impl_.uuid_, rhs_arena + &_impl_.displayname_, lhs_arena, + &other->_impl_.displayname_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.profilepicture_, lhs_arena, + &other->_impl_.profilepicture_, rhs_arena ); - swap(_impl_.type_, other->_impl_.type_); } -std::string CallMessage::GetTypeName() const { - return "SessionProtos.CallMessage"; +::PROTOBUF_NAMESPACE_ID::Metadata LokiProfile::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[8]); } - // =================================================================== -class KeyPair::_Internal { +class DataMessage_Quote_QuotedAttachment::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_contenttype(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_privatekey(HasBits* has_bits) { + static void set_has_filename(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + static const ::SessionProtos::AttachmentPointer& thumbnail(const DataMessage_Quote_QuotedAttachment* msg); + static void set_has_thumbnail(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_flags(HasBits* has_bits) { + (*has_bits)[0] |= 8u; } }; -KeyPair::KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::AttachmentPointer& +DataMessage_Quote_QuotedAttachment::_Internal::thumbnail(const DataMessage_Quote_QuotedAttachment* msg) { + return *msg->_impl_.thumbnail_; +} +DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.KeyPair) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) } -KeyPair::KeyPair(const KeyPair& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - KeyPair* const _this = this; (void)_this; +DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataMessage_Quote_QuotedAttachment* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.privatekey_){}}; + , decltype(_impl_.contenttype_){} + , decltype(_impl_.filename_){} + , decltype(_impl_.thumbnail_){nullptr} + , decltype(_impl_.flags_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.contenttype_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), + if (from._internal_has_contenttype()) { + _this->_impl_.contenttype_.Set(from._internal_contenttype(), _this->GetArenaForAllocation()); } - _impl_.privatekey_.InitDefault(); + _impl_.filename_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.privatekey_.Set("", GetArenaForAllocation()); + _impl_.filename_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_privatekey()) { - _this->_impl_.privatekey_.Set(from._internal_privatekey(), + if (from._internal_has_filename()) { + _this->_impl_.filename_.Set(from._internal_filename(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.KeyPair) + if (from._internal_has_thumbnail()) { + _this->_impl_.thumbnail_ = new ::SessionProtos::AttachmentPointer(*from._impl_.thumbnail_); + } + _this->_impl_.flags_ = from._impl_.flags_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) } -inline void KeyPair::SharedCtor( +inline void DataMessage_Quote_QuotedAttachment::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.privatekey_){} - }; - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + , decltype(_impl_.contenttype_){} + , decltype(_impl_.filename_){} + , decltype(_impl_.thumbnail_){nullptr} + , decltype(_impl_.flags_){0u} + }; + _impl_.contenttype_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.contenttype_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.privatekey_.InitDefault(); + _impl_.filename_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.privatekey_.Set("", GetArenaForAllocation()); + _impl_.filename_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -KeyPair::~KeyPair() { - // @@protoc_insertion_point(destructor:SessionProtos.KeyPair) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +DataMessage_Quote_QuotedAttachment::~DataMessage_Quote_QuotedAttachment() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote.QuotedAttachment) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void KeyPair::SharedDtor() { +inline void DataMessage_Quote_QuotedAttachment::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.publickey_.Destroy(); - _impl_.privatekey_.Destroy(); + _impl_.contenttype_.Destroy(); + _impl_.filename_.Destroy(); + if (this != internal_default_instance()) delete _impl_.thumbnail_; } -void KeyPair::SetCachedSize(int size) const { +void DataMessage_Quote_QuotedAttachment::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void KeyPair::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.KeyPair) +void DataMessage_Quote_QuotedAttachment::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote.QuotedAttachment) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + _impl_.contenttype_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.privatekey_.ClearNonDefaultToEmpty(); + _impl_.filename_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + GOOGLE_DCHECK(_impl_.thumbnail_ != nullptr); + _impl_.thumbnail_->Clear(); } } + _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes publicKey = 1; + // optional string contentType = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); + auto str = _internal_mutable_contenttype(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.QuotedAttachment.contentType"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // required bytes privateKey = 2; + // optional string fileName = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_privatekey(); + auto str = _internal_mutable_filename(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.QuotedAttachment.fileName"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_thumbnail(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional uint32 flags = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); } else goto handle_unusual; continue; @@ -4597,7 +4685,7 @@ const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4610,249 +4698,341 @@ const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) #undef CHK_ } -uint8_t* KeyPair::_InternalSerialize( +uint8_t* DataMessage_Quote_QuotedAttachment::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.KeyPair) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote.QuotedAttachment) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes publicKey = 1; + // optional string contentType = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_contenttype().data(), static_cast(this->_internal_contenttype().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Quote.QuotedAttachment.contentType"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_contenttype(), target); } - // required bytes privateKey = 2; + // optional string fileName = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 2, this->_internal_privatekey(), target); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_filename().data(), static_cast(this->_internal_filename().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Quote.QuotedAttachment.fileName"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_filename(), target); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::thumbnail(this), + _Internal::thumbnail(this).GetCachedSize(), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.KeyPair) - return target; -} - -size_t KeyPair::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.KeyPair) - size_t total_size = 0; - if (_internal_has_publickey()) { - // required bytes publicKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); } - if (_internal_has_privatekey()) { - // required bytes privateKey = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_privatekey()); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - - return total_size; + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote.QuotedAttachment) + return target; } -size_t KeyPair::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.KeyPair) - size_t total_size = 0; - - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes publicKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - // required bytes privateKey = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_privatekey()); +size_t DataMessage_Quote_QuotedAttachment::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote.QuotedAttachment) + size_t total_size = 0; - } else { - total_size += RequiredFieldsByteSizeFallback(); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + // optional string contentType = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_contenttype()); + } + + // optional string fileName = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_filename()); + } + + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.thumbnail_); + } + + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void KeyPair::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Quote_QuotedAttachment::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataMessage_Quote_QuotedAttachment::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Quote_QuotedAttachment::GetClassData() const { return &_class_data_; } -void KeyPair::MergeFrom(const KeyPair& from) { - KeyPair* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.KeyPair) + +void DataMessage_Quote_QuotedAttachment::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_contenttype(from._internal_contenttype()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_privatekey(from._internal_privatekey()); + _this->_internal_set_filename(from._internal_filename()); } + if (cached_has_bits & 0x00000004u) { + _this->_internal_mutable_thumbnail()->::SessionProtos::AttachmentPointer::MergeFrom( + from._internal_thumbnail()); + } + if (cached_has_bits & 0x00000008u) { + _this->_impl_.flags_ = from._impl_.flags_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void KeyPair::CopyFrom(const KeyPair& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.KeyPair) +void DataMessage_Quote_QuotedAttachment::CopyFrom(const DataMessage_Quote_QuotedAttachment& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) if (&from == this) return; Clear(); MergeFrom(from); } -bool KeyPair::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool DataMessage_Quote_QuotedAttachment::IsInitialized() const { + if (_internal_has_thumbnail()) { + if (!_impl_.thumbnail_->IsInitialized()) return false; + } return true; } -void KeyPair::InternalSwap(KeyPair* other) { +void DataMessage_Quote_QuotedAttachment::InternalSwap(DataMessage_Quote_QuotedAttachment* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena + &_impl_.contenttype_, lhs_arena, + &other->_impl_.contenttype_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.privatekey_, lhs_arena, - &other->_impl_.privatekey_, rhs_arena + &_impl_.filename_, lhs_arena, + &other->_impl_.filename_, rhs_arena ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.flags_) + + sizeof(DataMessage_Quote_QuotedAttachment::_impl_.flags_) + - PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.thumbnail_)>( + reinterpret_cast(&_impl_.thumbnail_), + reinterpret_cast(&other->_impl_.thumbnail_)); } -std::string KeyPair::GetTypeName() const { - return "SessionProtos.KeyPair"; +::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Quote_QuotedAttachment::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[9]); } - // =================================================================== -class DataExtractionNotification::_Internal { +class DataMessage_Quote::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 2u; + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static void set_has_timestamp(HasBits* has_bits) { + static void set_has_author(HasBits* has_bits) { (*has_bits)[0] |= 1u; } + static void set_has_text(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000002) ^ 0x00000002) != 0; + return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; } }; -DataExtractionNotification::DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_Quote::DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataExtractionNotification) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote) } -DataExtractionNotification::DataExtractionNotification(const DataExtractionNotification& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataExtractionNotification* const _this = this; (void)_this; +DataMessage_Quote::DataMessage_Quote(const DataMessage_Quote& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataMessage_Quote* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.timestamp_){} - , decltype(_impl_.type_){}}; - - _internal_metadata_.MergeFrom(from._internal_metadata_); - ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, - static_cast(reinterpret_cast(&_impl_.type_) - - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.type_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataExtractionNotification) -} + , decltype(_impl_.attachments_){from._impl_.attachments_} + , decltype(_impl_.author_){} + , decltype(_impl_.text_){} + , decltype(_impl_.id_){}}; -inline void DataExtractionNotification::SharedCtor( - ::_pb::Arena* arena, bool is_message_owned) { - (void)arena; - (void)is_message_owned; - new (&_impl_) Impl_{ - decltype(_impl_._has_bits_){} - , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.timestamp_){uint64_t{0u}} - , decltype(_impl_.type_){1} - }; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.author_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.author_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_author()) { + _this->_impl_.author_.Set(from._internal_author(), + _this->GetArenaForAllocation()); + } + _impl_.text_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.text_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_text()) { + _this->_impl_.text_.Set(from._internal_text(), + _this->GetArenaForAllocation()); + } + _this->_impl_.id_ = from._impl_.id_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote) } -DataExtractionNotification::~DataExtractionNotification() { - // @@protoc_insertion_point(destructor:SessionProtos.DataExtractionNotification) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +inline void DataMessage_Quote::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.attachments_){arena} + , decltype(_impl_.author_){} + , decltype(_impl_.text_){} + , decltype(_impl_.id_){uint64_t{0u}} + }; + _impl_.author_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.author_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.text_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.text_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +DataMessage_Quote::~DataMessage_Quote() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataExtractionNotification::SharedDtor() { +inline void DataMessage_Quote::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.attachments_.~RepeatedPtrField(); + _impl_.author_.Destroy(); + _impl_.text_.Destroy(); } -void DataExtractionNotification::SetCachedSize(int size) const { +void DataMessage_Quote::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataExtractionNotification::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataExtractionNotification) +void DataMessage_Quote::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.attachments_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { - _impl_.timestamp_ = uint64_t{0u}; - _impl_.type_ = 1; + if (cached_has_bits & 0x00000001u) { + _impl_.author_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.text_.ClearNonDefaultToEmpty(); + } } + _impl_.id_ = uint64_t{0u}; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.DataExtractionNotification.Type type = 1; + // required uint64 id = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _Internal::set_has_id(&has_bits); + _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataExtractionNotification_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::DataExtractionNotification_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } } else goto handle_unusual; continue; - // optional uint64 timestamp = 2; + // required string author = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - _Internal::set_has_timestamp(&has_bits); - _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_author(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.author"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // optional string text = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_text(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.text"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; @@ -4867,7 +5047,7 @@ const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi:: } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4880,240 +5060,344 @@ const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi:: #undef CHK_ } -uint8_t* DataExtractionNotification::_InternalSerialize( +uint8_t* DataMessage_Quote::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataExtractionNotification) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.DataExtractionNotification.Type type = 1; - if (cached_has_bits & 0x00000002u) { + // required uint64 id = 1; + if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); } - // optional uint64 timestamp = 2; + // required string author = 2; if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_timestamp(), target); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_author().data(), static_cast(this->_internal_author().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Quote.author"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_author(), target); + } + + // optional string text = 3; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_text().data(), static_cast(this->_internal_text().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Quote.text"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_text(), target); + } + + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + for (unsigned i = 0, + n = static_cast(this->_internal_attachments_size()); i < n; i++) { + const auto& repfield = this->_internal_attachments(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataExtractionNotification) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote) return target; } -size_t DataExtractionNotification::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataExtractionNotification) +size_t DataMessage_Quote::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Quote) size_t total_size = 0; - // required .SessionProtos.DataExtractionNotification.Type type = 1; - if (_internal_has_type()) { + if (_internal_has_author()) { + // required string author = 2; total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_author()); + } + + if (_internal_has_id()) { + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); + } + + return total_size; +} +size_t DataMessage_Quote::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. + // required string author = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_author()); + + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // optional uint64 timestamp = 2; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + total_size += 1UL * this->_internal_attachments_size(); + for (const auto& msg : this->_impl_.attachments_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + // optional string text = 3; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_text()); } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} -void DataExtractionNotification::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataExtractionNotification::MergeFrom(const DataExtractionNotification& from) { - DataExtractionNotification* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataExtractionNotification) +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Quote::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataMessage_Quote::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Quote::GetClassData() const { return &_class_data_; } + + +void DataMessage_Quote::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; + _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _this->_impl_.timestamp_ = from._impl_.timestamp_; + _this->_internal_set_author(from._internal_author()); } if (cached_has_bits & 0x00000002u) { - _this->_impl_.type_ = from._impl_.type_; + _this->_internal_set_text(from._internal_text()); + } + if (cached_has_bits & 0x00000004u) { + _this->_impl_.id_ = from._impl_.id_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataExtractionNotification::CopyFrom(const DataExtractionNotification& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataExtractionNotification) +void DataMessage_Quote::CopyFrom(const DataMessage_Quote& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataExtractionNotification::IsInitialized() const { +bool DataMessage_Quote::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) + return false; return true; } -void DataExtractionNotification::InternalSwap(DataExtractionNotification* other) { +void DataMessage_Quote::InternalSwap(DataMessage_Quote* other) { using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - swap(_impl_.timestamp_, other->_impl_.timestamp_); - swap(_impl_.type_, other->_impl_.type_); + _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.author_, lhs_arena, + &other->_impl_.author_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.text_, lhs_arena, + &other->_impl_.text_, rhs_arena + ); + swap(_impl_.id_, other->_impl_.id_); } -std::string DataExtractionNotification::GetTypeName() const { - return "SessionProtos.DataExtractionNotification"; +::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Quote::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[10]); } - // =================================================================== -class LokiProfile::_Internal { +class DataMessage_Preview::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_displayname(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_url(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_profilepicture(HasBits* has_bits) { + static void set_has_title(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static const ::SessionProtos::AttachmentPointer& image(const DataMessage_Preview* msg); + static void set_has_image(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } }; -LokiProfile::LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::AttachmentPointer& +DataMessage_Preview::_Internal::image(const DataMessage_Preview* msg) { + return *msg->_impl_.image_; +} +DataMessage_Preview::DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.LokiProfile) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Preview) } -LokiProfile::LokiProfile(const LokiProfile& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - LokiProfile* const _this = this; (void)_this; +DataMessage_Preview::DataMessage_Preview(const DataMessage_Preview& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataMessage_Preview* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){}}; + , decltype(_impl_.url_){} + , decltype(_impl_.title_){} + , decltype(_impl_.image_){nullptr}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.displayname_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_displayname()) { - _this->_impl_.displayname_.Set(from._internal_displayname(), + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), _this->GetArenaForAllocation()); } - _impl_.profilepicture_.InitDefault(); + _impl_.title_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.title_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilepicture()) { - _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + if (from._internal_has_title()) { + _this->_impl_.title_.Set(from._internal_title(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.LokiProfile) + if (from._internal_has_image()) { + _this->_impl_.image_ = new ::SessionProtos::AttachmentPointer(*from._impl_.image_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Preview) } -inline void LokiProfile::SharedCtor( +inline void DataMessage_Preview::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){} + , decltype(_impl_.url_){} + , decltype(_impl_.title_){} + , decltype(_impl_.image_){nullptr} }; - _impl_.displayname_.InitDefault(); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.InitDefault(); + _impl_.title_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.title_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -LokiProfile::~LokiProfile() { - // @@protoc_insertion_point(destructor:SessionProtos.LokiProfile) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +DataMessage_Preview::~DataMessage_Preview() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Preview) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void LokiProfile::SharedDtor() { +inline void DataMessage_Preview::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.displayname_.Destroy(); - _impl_.profilepicture_.Destroy(); + _impl_.url_.Destroy(); + _impl_.title_.Destroy(); + if (this != internal_default_instance()) delete _impl_.image_; } -void LokiProfile::SetCachedSize(int size) const { +void DataMessage_Preview::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void LokiProfile::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.LokiProfile) +void DataMessage_Preview::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Preview) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _impl_.displayname_.ClearNonDefaultToEmpty(); + _impl_.url_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.profilepicture_.ClearNonDefaultToEmpty(); + _impl_.title_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + GOOGLE_DCHECK(_impl_.image_ != nullptr); + _impl_.image_->Clear(); } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional string displayName = 1; + // required string url = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_displayname(); + auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Preview.url"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional string profilePicture = 2; + // optional string title = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_profilepicture(); + auto str = _internal_mutable_title(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Preview.title"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // optional .SessionProtos.AttachmentPointer image = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_image(), ptr); + CHK_(ptr); } else goto handle_unusual; continue; @@ -5128,7 +5412,7 @@ const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -5141,293 +5425,328 @@ const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* c #undef CHK_ } -uint8_t* LokiProfile::_InternalSerialize( +uint8_t* DataMessage_Preview::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.LokiProfile) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Preview) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional string displayName = 1; + // required string url = 1; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_url().data(), static_cast(this->_internal_url().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Preview.url"); target = stream->WriteStringMaybeAliased( - 1, this->_internal_displayname(), target); + 1, this->_internal_url(), target); } - // optional string profilePicture = 2; + // optional string title = 2; if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_title().data(), static_cast(this->_internal_title().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Preview.title"); target = stream->WriteStringMaybeAliased( - 2, this->_internal_profilepicture(), target); + 2, this->_internal_title(), target); + } + + // optional .SessionProtos.AttachmentPointer image = 3; + if (cached_has_bits & 0x00000004u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::image(this), + _Internal::image(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.LokiProfile) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Preview) return target; } -size_t LokiProfile::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.LokiProfile) +size_t DataMessage_Preview::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Preview) size_t total_size = 0; + // required string url = 1; + if (_internal_has_url()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); + } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - // optional string displayName = 1; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000006u) { + // optional string title = 2; + if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_displayname()); + this->_internal_title()); } - // optional string profilePicture = 2; - if (cached_has_bits & 0x00000002u) { + // optional .SessionProtos.AttachmentPointer image = 3; + if (cached_has_bits & 0x00000004u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_profilepicture()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.image_); } } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void LokiProfile::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Preview::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataMessage_Preview::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Preview::GetClassData() const { return &_class_data_; } -void LokiProfile::MergeFrom(const LokiProfile& from) { - LokiProfile* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.LokiProfile) + +void DataMessage_Preview::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Preview) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_displayname(from._internal_displayname()); + _this->_internal_set_url(from._internal_url()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_profilepicture(from._internal_profilepicture()); + _this->_internal_set_title(from._internal_title()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_mutable_image()->::SessionProtos::AttachmentPointer::MergeFrom( + from._internal_image()); } } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void LokiProfile::CopyFrom(const LokiProfile& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.LokiProfile) +void DataMessage_Preview::CopyFrom(const DataMessage_Preview& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Preview) if (&from == this) return; Clear(); MergeFrom(from); } -bool LokiProfile::IsInitialized() const { +bool DataMessage_Preview::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (_internal_has_image()) { + if (!_impl_.image_->IsInitialized()) return false; + } return true; } -void LokiProfile::InternalSwap(LokiProfile* other) { +void DataMessage_Preview::InternalSwap(DataMessage_Preview* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.displayname_, lhs_arena, - &other->_impl_.displayname_, rhs_arena + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilepicture_, lhs_arena, - &other->_impl_.profilepicture_, rhs_arena + &_impl_.title_, lhs_arena, + &other->_impl_.title_, rhs_arena ); + swap(_impl_.image_, other->_impl_.image_); } -std::string LokiProfile::GetTypeName() const { - return "SessionProtos.LokiProfile"; +::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Preview::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[11]); } - // =================================================================== -class DataMessage_Quote_QuotedAttachment::_Internal { +class DataMessage_Reaction::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_contenttype(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_author(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_filename(HasBits* has_bits) { + static void set_has_emoji(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::AttachmentPointer& thumbnail(const DataMessage_Quote_QuotedAttachment* msg); - static void set_has_thumbnail(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_flags(HasBits* has_bits) { + static void set_has_action(HasBits* has_bits) { (*has_bits)[0] |= 8u; } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000000d) ^ 0x0000000d) != 0; + } }; -const ::SessionProtos::AttachmentPointer& -DataMessage_Quote_QuotedAttachment::_Internal::thumbnail(const DataMessage_Quote_QuotedAttachment* msg) { - return *msg->_impl_.thumbnail_; -} -DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_Reaction::DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Reaction) } -DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Quote_QuotedAttachment* const _this = this; (void)_this; +DataMessage_Reaction::DataMessage_Reaction(const DataMessage_Reaction& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataMessage_Reaction* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.contenttype_){} - , decltype(_impl_.filename_){} - , decltype(_impl_.thumbnail_){nullptr} - , decltype(_impl_.flags_){}}; + , decltype(_impl_.author_){} + , decltype(_impl_.emoji_){} + , decltype(_impl_.id_){} + , decltype(_impl_.action_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.contenttype_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.contenttype_.Set("", GetArenaForAllocation()); + _impl_.author_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_contenttype()) { - _this->_impl_.contenttype_.Set(from._internal_contenttype(), + if (from._internal_has_author()) { + _this->_impl_.author_.Set(from._internal_author(), _this->GetArenaForAllocation()); } - _impl_.filename_.InitDefault(); + _impl_.emoji_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.Set("", GetArenaForAllocation()); + _impl_.emoji_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_filename()) { - _this->_impl_.filename_.Set(from._internal_filename(), + if (from._internal_has_emoji()) { + _this->_impl_.emoji_.Set(from._internal_emoji(), _this->GetArenaForAllocation()); } - if (from._internal_has_thumbnail()) { - _this->_impl_.thumbnail_ = new ::SessionProtos::AttachmentPointer(*from._impl_.thumbnail_); - } - _this->_impl_.flags_ = from._impl_.flags_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) + ::memcpy(&_impl_.id_, &from._impl_.id_, + static_cast(reinterpret_cast(&_impl_.action_) - + reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Reaction) } -inline void DataMessage_Quote_QuotedAttachment::SharedCtor( +inline void DataMessage_Reaction::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.contenttype_){} - , decltype(_impl_.filename_){} - , decltype(_impl_.thumbnail_){nullptr} - , decltype(_impl_.flags_){0u} + , decltype(_impl_.author_){} + , decltype(_impl_.emoji_){} + , decltype(_impl_.id_){uint64_t{0u}} + , decltype(_impl_.action_){0} }; - _impl_.contenttype_.InitDefault(); + _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.contenttype_.Set("", GetArenaForAllocation()); + _impl_.author_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.InitDefault(); + _impl_.emoji_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.Set("", GetArenaForAllocation()); + _impl_.emoji_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Quote_QuotedAttachment::~DataMessage_Quote_QuotedAttachment() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote.QuotedAttachment) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +DataMessage_Reaction::~DataMessage_Reaction() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Reaction) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_Quote_QuotedAttachment::SharedDtor() { +inline void DataMessage_Reaction::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.contenttype_.Destroy(); - _impl_.filename_.Destroy(); - if (this != internal_default_instance()) delete _impl_.thumbnail_; + _impl_.author_.Destroy(); + _impl_.emoji_.Destroy(); } -void DataMessage_Quote_QuotedAttachment::SetCachedSize(int size) const { +void DataMessage_Reaction::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Quote_QuotedAttachment::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +void DataMessage_Reaction::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Reaction) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.contenttype_.ClearNonDefaultToEmpty(); + _impl_.author_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.filename_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.thumbnail_ != nullptr); - _impl_.thumbnail_->Clear(); + _impl_.emoji_.ClearNonDefaultToEmpty(); } } - _impl_.flags_ = 0u; + if (cached_has_bits & 0x0000000cu) { + ::memset(&_impl_.id_, 0, static_cast( + reinterpret_cast(&_impl_.action_) - + reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); + } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional string contentType = 1; + // required uint64 id = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_contenttype(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _Internal::set_has_id(&has_bits); + _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional string fileName = 2; + // required string author = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_filename(); + auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Reaction.author"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional .SessionProtos.AttachmentPointer thumbnail = 3; + // optional string emoji = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_thumbnail(), ptr); + auto str = _internal_mutable_emoji(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Reaction.emoji"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional uint32 flags = 4; + // required .SessionProtos.DataMessage.Reaction.Action action = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_Reaction_Action_IsValid(val))) { + _internal_set_action(static_cast<::SessionProtos::DataMessage_Reaction_Action>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; @@ -5442,7 +5761,7 @@ const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -5455,100 +5774,124 @@ const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, #undef CHK_ } -uint8_t* DataMessage_Quote_QuotedAttachment::_InternalSerialize( +uint8_t* DataMessage_Reaction::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Reaction) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional string contentType = 1; + // required uint64 id = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); + } + + // required string author = 2; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_author().data(), static_cast(this->_internal_author().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Reaction.author"); target = stream->WriteStringMaybeAliased( - 1, this->_internal_contenttype(), target); + 2, this->_internal_author(), target); } - // optional string fileName = 2; + // optional string emoji = 3; if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_emoji().data(), static_cast(this->_internal_emoji().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.Reaction.emoji"); target = stream->WriteStringMaybeAliased( - 2, this->_internal_filename(), target); - } - - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::thumbnail(this), - _Internal::thumbnail(this).GetCachedSize(), target, stream); + 3, this->_internal_emoji(), target); } - // optional uint32 flags = 4; + // required .SessionProtos.DataMessage.Reaction.Action action = 4; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 4, this->_internal_action(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Reaction) return target; } -size_t DataMessage_Quote_QuotedAttachment::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +size_t DataMessage_Reaction::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Reaction) size_t total_size = 0; - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + if (_internal_has_author()) { + // required string author = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_author()); + } - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional string contentType = 1; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_contenttype()); - } + if (_internal_has_id()) { + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); + } - // optional string fileName = 2; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_filename()); - } + if (_internal_has_action()) { + // required .SessionProtos.DataMessage.Reaction.Action action = 4; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); + } - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.thumbnail_); - } + return total_size; +} +size_t DataMessage_Reaction::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Reaction) + size_t total_size = 0; - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000008u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - } + if (((_impl_._has_bits_[0] & 0x0000000d) ^ 0x0000000d) == 0) { // All required fields are present. + // required string author = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_author()); + + // required uint64 id = 1; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); + + // required .SessionProtos.DataMessage.Reaction.Action action = 4; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); + } else { + total_size += RequiredFieldsByteSizeFallback(); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // optional string emoji = 3; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_emoji()); } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} -void DataMessage_Quote_QuotedAttachment::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage_Quote_QuotedAttachment::MergeFrom(const DataMessage_Quote_QuotedAttachment& from) { - DataMessage_Quote_QuotedAttachment* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Reaction::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataMessage_Reaction::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Reaction::GetClassData() const { return &_class_data_; } + + +void DataMessage_Reaction::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Reaction) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -5556,228 +5899,199 @@ void DataMessage_Quote_QuotedAttachment::MergeFrom(const DataMessage_Quote_Quote cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_contenttype(from._internal_contenttype()); + _this->_internal_set_author(from._internal_author()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_filename(from._internal_filename()); + _this->_internal_set_emoji(from._internal_emoji()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_thumbnail()->::SessionProtos::AttachmentPointer::MergeFrom( - from._internal_thumbnail()); + _this->_impl_.id_ = from._impl_.id_; } if (cached_has_bits & 0x00000008u) { - _this->_impl_.flags_ = from._impl_.flags_; + _this->_impl_.action_ = from._impl_.action_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage_Quote_QuotedAttachment::CopyFrom(const DataMessage_Quote_QuotedAttachment& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) +void DataMessage_Reaction::CopyFrom(const DataMessage_Reaction& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Reaction) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Quote_QuotedAttachment::IsInitialized() const { - if (_internal_has_thumbnail()) { - if (!_impl_.thumbnail_->IsInitialized()) return false; - } +bool DataMessage_Reaction::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage_Quote_QuotedAttachment::InternalSwap(DataMessage_Quote_QuotedAttachment* other) { +void DataMessage_Reaction::InternalSwap(DataMessage_Reaction* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.contenttype_, lhs_arena, - &other->_impl_.contenttype_, rhs_arena + &_impl_.author_, lhs_arena, + &other->_impl_.author_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.filename_, lhs_arena, - &other->_impl_.filename_, rhs_arena + &_impl_.emoji_, lhs_arena, + &other->_impl_.emoji_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.flags_) - + sizeof(DataMessage_Quote_QuotedAttachment::_impl_.flags_) - - PROTOBUF_FIELD_OFFSET(DataMessage_Quote_QuotedAttachment, _impl_.thumbnail_)>( - reinterpret_cast(&_impl_.thumbnail_), - reinterpret_cast(&other->_impl_.thumbnail_)); + PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.action_) + + sizeof(DataMessage_Reaction::_impl_.action_) + - PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.id_)>( + reinterpret_cast(&_impl_.id_), + reinterpret_cast(&other->_impl_.id_)); } -std::string DataMessage_Quote_QuotedAttachment::GetTypeName() const { - return "SessionProtos.DataMessage.Quote.QuotedAttachment"; +::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Reaction::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[12]); } - // =================================================================== -class DataMessage_Quote::_Internal { +class DataMessage_OpenGroupInvitation::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_id(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_author(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_url(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_text(HasBits* has_bits) { + static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -DataMessage_Quote::DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, +DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.OpenGroupInvitation) } -DataMessage_Quote::DataMessage_Quote(const DataMessage_Quote& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Quote* const _this = this; (void)_this; +DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataMessage_OpenGroupInvitation* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){from._impl_.attachments_} - , decltype(_impl_.author_){} - , decltype(_impl_.text_){} - , decltype(_impl_.id_){}}; + , decltype(_impl_.url_){} + , decltype(_impl_.name_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.author_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_author()) { - _this->_impl_.author_.Set(from._internal_author(), + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), _this->GetArenaForAllocation()); } - _impl_.text_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.text_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_text()) { - _this->_impl_.text_.Set(from._internal_text(), + if (from._internal_has_name()) { + _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation()); } - _this->_impl_.id_ = from._impl_.id_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.OpenGroupInvitation) } -inline void DataMessage_Quote::SharedCtor( +inline void DataMessage_OpenGroupInvitation::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){arena} - , decltype(_impl_.author_){} - , decltype(_impl_.text_){} - , decltype(_impl_.id_){uint64_t{0u}} + , decltype(_impl_.url_){} + , decltype(_impl_.name_){} }; - _impl_.author_.InitDefault(); + _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.text_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.text_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Quote::~DataMessage_Quote() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +DataMessage_OpenGroupInvitation::~DataMessage_OpenGroupInvitation() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.OpenGroupInvitation) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_Quote::SharedDtor() { +inline void DataMessage_OpenGroupInvitation::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.attachments_.~RepeatedPtrField(); - _impl_.author_.Destroy(); - _impl_.text_.Destroy(); + _impl_.url_.Destroy(); + _impl_.name_.Destroy(); } -void DataMessage_Quote::SetCachedSize(int size) const { +void DataMessage_OpenGroupInvitation::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Quote::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Quote) +void DataMessage_OpenGroupInvitation::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.OpenGroupInvitation) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.attachments_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.author_.ClearNonDefaultToEmpty(); + _impl_.url_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.text_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } } - _impl_.id_ = uint64_t{0u}; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint64 id = 1; + // required string url = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_id(&has_bits); - _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // required string author = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_author(); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.OpenGroupInvitation.url"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional string text = 3; + // required string name = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_text(); + auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.OpenGroupInvitation.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5792,7 +6106,7 @@ const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseCont } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -5805,77 +6119,75 @@ const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseCont #undef CHK_ } -uint8_t* DataMessage_Quote::_InternalSerialize( +uint8_t* DataMessage_OpenGroupInvitation::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.OpenGroupInvitation) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint64 id = 1; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); - } - - // required string author = 2; + // required string url = 1; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_url().data(), static_cast(this->_internal_url().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.OpenGroupInvitation.url"); target = stream->WriteStringMaybeAliased( - 2, this->_internal_author(), target); + 1, this->_internal_url(), target); } - // optional string text = 3; + // required string name = 3; if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.OpenGroupInvitation.name"); target = stream->WriteStringMaybeAliased( - 3, this->_internal_text(), target); - } - - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - for (unsigned i = 0, - n = static_cast(this->_internal_attachments_size()); i < n; i++) { - const auto& repfield = this->_internal_attachments(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); + 3, this->_internal_name(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.OpenGroupInvitation) return target; } -size_t DataMessage_Quote::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Quote) +size_t DataMessage_OpenGroupInvitation::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.OpenGroupInvitation) size_t total_size = 0; - if (_internal_has_author()) { - // required string author = 2; + if (_internal_has_url()) { + // required string url = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); + this->_internal_url()); } - if (_internal_has_id()) { - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); + if (_internal_has_name()) { + // required string name = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } return total_size; } -size_t DataMessage_Quote::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Quote) +size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.OpenGroupInvitation) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. - // required string author = 2; + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string url = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); + this->_internal_url()); - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); + // required string name = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -5884,590 +6196,919 @@ size_t DataMessage_Quote::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - total_size += 1UL * this->_internal_attachments_size(); - for (const auto& msg : this->_impl_.attachments_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // optional string text = 3; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_text()); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage_Quote::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_OpenGroupInvitation::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataMessage_OpenGroupInvitation::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_OpenGroupInvitation::GetClassData() const { return &_class_data_; } -void DataMessage_Quote::MergeFrom(const DataMessage_Quote& from) { - DataMessage_Quote* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote) + +void DataMessage_OpenGroupInvitation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.OpenGroupInvitation) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_author(from._internal_author()); + _this->_internal_set_url(from._internal_url()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_text(from._internal_text()); - } - if (cached_has_bits & 0x00000004u) { - _this->_impl_.id_ = from._impl_.id_; + _this->_internal_set_name(from._internal_name()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage_Quote::CopyFrom(const DataMessage_Quote& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Quote) +void DataMessage_OpenGroupInvitation::CopyFrom(const DataMessage_OpenGroupInvitation& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.OpenGroupInvitation) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Quote::IsInitialized() const { +bool DataMessage_OpenGroupInvitation::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) - return false; return true; } -void DataMessage_Quote::InternalSwap(DataMessage_Quote* other) { +void DataMessage_OpenGroupInvitation::InternalSwap(DataMessage_OpenGroupInvitation* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.author_, lhs_arena, - &other->_impl_.author_, rhs_arena + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.text_, lhs_arena, - &other->_impl_.text_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(_impl_.id_, other->_impl_.id_); } -std::string DataMessage_Quote::GetTypeName() const { - return "SessionProtos.DataMessage.Quote"; +::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_OpenGroupInvitation::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[13]); } - // =================================================================== -class DataMessage_Preview::_Internal { +class DataMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_url(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_body(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_title(HasBits* has_bits) { + static void set_has_flags(HasBits* has_bits) { + (*has_bits)[0] |= 512u; + } + static void set_has_profilekey(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::AttachmentPointer& image(const DataMessage_Preview* msg); - static void set_has_image(HasBits* has_bits) { + static void set_has_timestamp(HasBits* has_bits) { + (*has_bits)[0] |= 256u; + } + static const ::SessionProtos::DataMessage_Quote& quote(const DataMessage* msg); + static void set_has_quote(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static const ::SessionProtos::DataMessage_Reaction& reaction(const DataMessage* msg); + static void set_has_reaction(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static const ::SessionProtos::LokiProfile& profile(const DataMessage* msg); + static void set_has_profile(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation(const DataMessage* msg); + static void set_has_opengroupinvitation(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } + static void set_has_synctarget(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + static void set_has_blockscommunitymessagerequests(HasBits* has_bits) { + (*has_bits)[0] |= 1024u; + } + static const ::SessionProtos::GroupUpdateMessage& groupupdatemessage(const DataMessage* msg); + static void set_has_groupupdatemessage(HasBits* has_bits) { + (*has_bits)[0] |= 128u; } }; -const ::SessionProtos::AttachmentPointer& -DataMessage_Preview::_Internal::image(const DataMessage_Preview* msg) { - return *msg->_impl_.image_; +const ::SessionProtos::DataMessage_Quote& +DataMessage::_Internal::quote(const DataMessage* msg) { + return *msg->_impl_.quote_; } -DataMessage_Preview::DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { - SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Preview) +const ::SessionProtos::DataMessage_Reaction& +DataMessage::_Internal::reaction(const DataMessage* msg) { + return *msg->_impl_.reaction_; } -DataMessage_Preview::DataMessage_Preview(const DataMessage_Preview& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Preview* const _this = this; (void)_this; - new (&_impl_) Impl_{ +const ::SessionProtos::LokiProfile& +DataMessage::_Internal::profile(const DataMessage* msg) { + return *msg->_impl_.profile_; +} +const ::SessionProtos::DataMessage_OpenGroupInvitation& +DataMessage::_Internal::opengroupinvitation(const DataMessage* msg) { + return *msg->_impl_.opengroupinvitation_; +} +const ::SessionProtos::GroupUpdateMessage& +DataMessage::_Internal::groupupdatemessage(const DataMessage* msg) { + return *msg->_impl_.groupupdatemessage_; +} +DataMessage::DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage) +} +DataMessage::DataMessage(const DataMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + DataMessage* const _this = this; (void)_this; + new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.url_){} - , decltype(_impl_.title_){} - , decltype(_impl_.image_){nullptr}}; + , decltype(_impl_.attachments_){from._impl_.attachments_} + , decltype(_impl_.preview_){from._impl_.preview_} + , decltype(_impl_.body_){} + , decltype(_impl_.profilekey_){} + , decltype(_impl_.synctarget_){} + , decltype(_impl_.quote_){nullptr} + , decltype(_impl_.reaction_){nullptr} + , decltype(_impl_.profile_){nullptr} + , decltype(_impl_.opengroupinvitation_){nullptr} + , decltype(_impl_.groupupdatemessage_){nullptr} + , decltype(_impl_.timestamp_){} + , decltype(_impl_.flags_){} + , decltype(_impl_.blockscommunitymessagerequests_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.url_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.body_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.body_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_url()) { - _this->_impl_.url_.Set(from._internal_url(), + if (from._internal_has_body()) { + _this->_impl_.body_.Set(from._internal_body(), _this->GetArenaForAllocation()); } - _impl_.title_.InitDefault(); + _impl_.profilekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.title_.Set("", GetArenaForAllocation()); + _impl_.profilekey_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_title()) { - _this->_impl_.title_.Set(from._internal_title(), + if (from._internal_has_profilekey()) { + _this->_impl_.profilekey_.Set(from._internal_profilekey(), _this->GetArenaForAllocation()); } - if (from._internal_has_image()) { - _this->_impl_.image_ = new ::SessionProtos::AttachmentPointer(*from._impl_.image_); + _impl_.synctarget_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.synctarget_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_synctarget()) { + _this->_impl_.synctarget_.Set(from._internal_synctarget(), + _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Preview) + if (from._internal_has_quote()) { + _this->_impl_.quote_ = new ::SessionProtos::DataMessage_Quote(*from._impl_.quote_); + } + if (from._internal_has_reaction()) { + _this->_impl_.reaction_ = new ::SessionProtos::DataMessage_Reaction(*from._impl_.reaction_); + } + if (from._internal_has_profile()) { + _this->_impl_.profile_ = new ::SessionProtos::LokiProfile(*from._impl_.profile_); + } + if (from._internal_has_opengroupinvitation()) { + _this->_impl_.opengroupinvitation_ = new ::SessionProtos::DataMessage_OpenGroupInvitation(*from._impl_.opengroupinvitation_); + } + if (from._internal_has_groupupdatemessage()) { + _this->_impl_.groupupdatemessage_ = new ::SessionProtos::GroupUpdateMessage(*from._impl_.groupupdatemessage_); + } + ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, + static_cast(reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - + reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.blockscommunitymessagerequests_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage) } -inline void DataMessage_Preview::SharedCtor( +inline void DataMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.url_){} - , decltype(_impl_.title_){} - , decltype(_impl_.image_){nullptr} + , decltype(_impl_.attachments_){arena} + , decltype(_impl_.preview_){arena} + , decltype(_impl_.body_){} + , decltype(_impl_.profilekey_){} + , decltype(_impl_.synctarget_){} + , decltype(_impl_.quote_){nullptr} + , decltype(_impl_.reaction_){nullptr} + , decltype(_impl_.profile_){nullptr} + , decltype(_impl_.opengroupinvitation_){nullptr} + , decltype(_impl_.groupupdatemessage_){nullptr} + , decltype(_impl_.timestamp_){uint64_t{0u}} + , decltype(_impl_.flags_){0u} + , decltype(_impl_.blockscommunitymessagerequests_){false} }; - _impl_.url_.InitDefault(); + _impl_.body_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.body_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.title_.InitDefault(); + _impl_.profilekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.title_.Set("", GetArenaForAllocation()); + _impl_.profilekey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.synctarget_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.synctarget_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Preview::~DataMessage_Preview() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Preview) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +DataMessage::~DataMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.DataMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_Preview::SharedDtor() { +inline void DataMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.url_.Destroy(); - _impl_.title_.Destroy(); - if (this != internal_default_instance()) delete _impl_.image_; + _impl_.attachments_.~RepeatedPtrField(); + _impl_.preview_.~RepeatedPtrField(); + _impl_.body_.Destroy(); + _impl_.profilekey_.Destroy(); + _impl_.synctarget_.Destroy(); + if (this != internal_default_instance()) delete _impl_.quote_; + if (this != internal_default_instance()) delete _impl_.reaction_; + if (this != internal_default_instance()) delete _impl_.profile_; + if (this != internal_default_instance()) delete _impl_.opengroupinvitation_; + if (this != internal_default_instance()) delete _impl_.groupupdatemessage_; } -void DataMessage_Preview::SetCachedSize(int size) const { +void DataMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Preview::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Preview) +void DataMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.attachments_.Clear(); + _impl_.preview_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _impl_.url_.ClearNonDefaultToEmpty(); + _impl_.body_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.title_.ClearNonDefaultToEmpty(); + _impl_.profilekey_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.image_ != nullptr); - _impl_.image_->Clear(); + _impl_.synctarget_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000008u) { + GOOGLE_DCHECK(_impl_.quote_ != nullptr); + _impl_.quote_->Clear(); + } + if (cached_has_bits & 0x00000010u) { + GOOGLE_DCHECK(_impl_.reaction_ != nullptr); + _impl_.reaction_->Clear(); + } + if (cached_has_bits & 0x00000020u) { + GOOGLE_DCHECK(_impl_.profile_ != nullptr); + _impl_.profile_->Clear(); + } + if (cached_has_bits & 0x00000040u) { + GOOGLE_DCHECK(_impl_.opengroupinvitation_ != nullptr); + _impl_.opengroupinvitation_->Clear(); + } + if (cached_has_bits & 0x00000080u) { + GOOGLE_DCHECK(_impl_.groupupdatemessage_ != nullptr); + _impl_.groupupdatemessage_->Clear(); } } + if (cached_has_bits & 0x00000700u) { + ::memset(&_impl_.timestamp_, 0, static_cast( + reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - + reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.blockscommunitymessagerequests_)); + } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required string url = 1; + // optional string body = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_url(); + auto str = _internal_mutable_body(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.body"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional string title = 2; + // repeated .SessionProtos.AttachmentPointer attachments = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_title(); + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else + goto handle_unusual; + continue; + // optional uint32 flags = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes profileKey = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + auto str = _internal_mutable_profilekey(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.AttachmentPointer image = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_image(), ptr); + // optional uint64 timestamp = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { + _Internal::set_has_timestamp(&has_bits); + _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - _impl_._has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -uint8_t* DataMessage_Preview::_InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Preview) - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _impl_._has_bits_[0]; - // required string url = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 1, this->_internal_url(), target); - } - - // optional string title = 2; - if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_title(), target); - } - - // optional .SessionProtos.AttachmentPointer image = 3; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::image(this), - _Internal::image(this).GetCachedSize(), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Preview) - return target; -} - -size_t DataMessage_Preview::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Preview) - size_t total_size = 0; + // optional .SessionProtos.DataMessage.Quote quote = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { + ptr = ctx->ParseMessage(_internal_mutable_quote(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // repeated .SessionProtos.DataMessage.Preview preview = 10; + case 10: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_preview(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr)); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataMessage.Reaction reaction = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { + ptr = ctx->ParseMessage(_internal_mutable_reaction(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.LokiProfile profile = 101; + case 101: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + ptr = ctx->ParseMessage(_internal_mutable_profile(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; + case 102: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + ptr = ctx->ParseMessage(_internal_mutable_opengroupinvitation(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string syncTarget = 105; + case 105: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { + auto str = _internal_mutable_synctarget(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.syncTarget"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // optional bool blocksCommunityMessageRequests = 106; + case 106: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 80)) { + _Internal::set_has_blockscommunitymessagerequests(&has_bits); + _impl_.blockscommunitymessagerequests_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .SessionProtos.GroupUpdateMessage groupUpdateMessage = 120; + case 120: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 194)) { + ptr = ctx->ParseMessage(_internal_mutable_groupupdatemessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} - // required string url = 1; - if (_internal_has_url()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); - } +uint8_t* DataMessage::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage) uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000006u) { - // optional string title = 2; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_title()); - } + // optional string body = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_body().data(), static_cast(this->_internal_body().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.body"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_body(), target); + } - // optional .SessionProtos.AttachmentPointer image = 3; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.image_); - } + // repeated .SessionProtos.AttachmentPointer attachments = 2; + for (unsigned i = 0, + n = static_cast(this->_internal_attachments_size()); i < n; i++) { + const auto& repfield = this->_internal_attachments(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); + } + + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000200u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); + } + + // optional bytes profileKey = 6; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteBytesMaybeAliased( + 6, this->_internal_profilekey(), target); + } + + // optional uint64 timestamp = 7; + if (cached_has_bits & 0x00000100u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(7, this->_internal_timestamp(), target); + } + + // optional .SessionProtos.DataMessage.Quote quote = 8; + if (cached_has_bits & 0x00000008u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(8, _Internal::quote(this), + _Internal::quote(this).GetCachedSize(), target, stream); + } + + // repeated .SessionProtos.DataMessage.Preview preview = 10; + for (unsigned i = 0, + n = static_cast(this->_internal_preview_size()); i < n; i++) { + const auto& repfield = this->_internal_preview(i); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(10, repfield, repfield.GetCachedSize(), target, stream); + } + + // optional .SessionProtos.DataMessage.Reaction reaction = 11; + if (cached_has_bits & 0x00000010u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(11, _Internal::reaction(this), + _Internal::reaction(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.LokiProfile profile = 101; + if (cached_has_bits & 0x00000020u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(101, _Internal::profile(this), + _Internal::profile(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; + if (cached_has_bits & 0x00000040u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(102, _Internal::opengroupinvitation(this), + _Internal::opengroupinvitation(this).GetCachedSize(), target, stream); + } + + // optional string syncTarget = 105; + if (cached_has_bits & 0x00000004u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_synctarget().data(), static_cast(this->_internal_synctarget().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.DataMessage.syncTarget"); + target = stream->WriteStringMaybeAliased( + 105, this->_internal_synctarget(), target); + } + + // optional bool blocksCommunityMessageRequests = 106; + if (cached_has_bits & 0x00000400u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(106, this->_internal_blockscommunitymessagerequests(), target); + } + // optional .SessionProtos.GroupUpdateMessage groupUpdateMessage = 120; + if (cached_has_bits & 0x00000080u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(120, _Internal::groupupdatemessage(this), + _Internal::groupupdatemessage(this).GetCachedSize(), target, stream); } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage) + return target; } -void DataMessage_Preview::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +size_t DataMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage) + size_t total_size = 0; -void DataMessage_Preview::MergeFrom(const DataMessage_Preview& from) { - DataMessage_Preview* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Preview) - GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + // repeated .SessionProtos.AttachmentPointer attachments = 2; + total_size += 1UL * this->_internal_attachments_size(); + for (const auto& msg : this->_impl_.attachments_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .SessionProtos.DataMessage.Preview preview = 10; + total_size += 1UL * this->_internal_preview_size(); + for (const auto& msg : this->_impl_.preview_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x000000ffu) { + // optional string body = 1; if (cached_has_bits & 0x00000001u) { - _this->_internal_set_url(from._internal_url()); + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_body()); } + + // optional bytes profileKey = 6; if (cached_has_bits & 0x00000002u) { - _this->_internal_set_title(from._internal_title()); + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_profilekey()); } + + // optional string syncTarget = 105; if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_image()->::SessionProtos::AttachmentPointer::MergeFrom( - from._internal_image()); + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_synctarget()); } - } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); -} -void DataMessage_Preview::CopyFrom(const DataMessage_Preview& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Preview) - if (&from == this) return; - Clear(); - MergeFrom(from); -} + // optional .SessionProtos.DataMessage.Quote quote = 8; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.quote_); + } -bool DataMessage_Preview::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (_internal_has_image()) { - if (!_impl_.image_->IsInitialized()) return false; + // optional .SessionProtos.DataMessage.Reaction reaction = 11; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.reaction_); + } + + // optional .SessionProtos.LokiProfile profile = 101; + if (cached_has_bits & 0x00000020u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.profile_); + } + + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; + if (cached_has_bits & 0x00000040u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.opengroupinvitation_); + } + + // optional .SessionProtos.GroupUpdateMessage groupUpdateMessage = 120; + if (cached_has_bits & 0x00000080u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.groupupdatemessage_); + } + + } + if (cached_has_bits & 0x00000700u) { + // optional uint64 timestamp = 7; + if (cached_has_bits & 0x00000100u) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); + } + + // optional uint32 flags = 4; + if (cached_has_bits & 0x00000200u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + + // optional bool blocksCommunityMessageRequests = 106; + if (cached_has_bits & 0x00000400u) { + total_size += 2 + 1; + } + + } + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + DataMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage::GetClassData() const { return &_class_data_; } + + +void DataMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); + _this->_impl_.preview_.MergeFrom(from._impl_.preview_); + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_body(from._internal_body()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_profilekey(from._internal_profilekey()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_synctarget(from._internal_synctarget()); + } + if (cached_has_bits & 0x00000008u) { + _this->_internal_mutable_quote()->::SessionProtos::DataMessage_Quote::MergeFrom( + from._internal_quote()); + } + if (cached_has_bits & 0x00000010u) { + _this->_internal_mutable_reaction()->::SessionProtos::DataMessage_Reaction::MergeFrom( + from._internal_reaction()); + } + if (cached_has_bits & 0x00000020u) { + _this->_internal_mutable_profile()->::SessionProtos::LokiProfile::MergeFrom( + from._internal_profile()); + } + if (cached_has_bits & 0x00000040u) { + _this->_internal_mutable_opengroupinvitation()->::SessionProtos::DataMessage_OpenGroupInvitation::MergeFrom( + from._internal_opengroupinvitation()); + } + if (cached_has_bits & 0x00000080u) { + _this->_internal_mutable_groupupdatemessage()->::SessionProtos::GroupUpdateMessage::MergeFrom( + from._internal_groupupdatemessage()); + } + } + if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000100u) { + _this->_impl_.timestamp_ = from._impl_.timestamp_; + } + if (cached_has_bits & 0x00000200u) { + _this->_impl_.flags_ = from._impl_.flags_; + } + if (cached_has_bits & 0x00000400u) { + _this->_impl_.blockscommunitymessagerequests_ = from._impl_.blockscommunitymessagerequests_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void DataMessage::CopyFrom(const DataMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool DataMessage::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) + return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.preview_)) + return false; + if (_internal_has_quote()) { + if (!_impl_.quote_->IsInitialized()) return false; + } + if (_internal_has_reaction()) { + if (!_impl_.reaction_->IsInitialized()) return false; + } + if (_internal_has_opengroupinvitation()) { + if (!_impl_.opengroupinvitation_->IsInitialized()) return false; + } + if (_internal_has_groupupdatemessage()) { + if (!_impl_.groupupdatemessage_->IsInitialized()) return false; } return true; } -void DataMessage_Preview::InternalSwap(DataMessage_Preview* other) { +void DataMessage::InternalSwap(DataMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); + _impl_.preview_.InternalSwap(&other->_impl_.preview_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.url_, lhs_arena, - &other->_impl_.url_, rhs_arena + &_impl_.body_, lhs_arena, + &other->_impl_.body_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.title_, lhs_arena, - &other->_impl_.title_, rhs_arena + &_impl_.profilekey_, lhs_arena, + &other->_impl_.profilekey_, rhs_arena ); - swap(_impl_.image_, other->_impl_.image_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.synctarget_, lhs_arena, + &other->_impl_.synctarget_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.blockscommunitymessagerequests_) + + sizeof(DataMessage::_impl_.blockscommunitymessagerequests_) + - PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.quote_)>( + reinterpret_cast(&_impl_.quote_), + reinterpret_cast(&other->_impl_.quote_)); } -std::string DataMessage_Preview::GetTypeName() const { - return "SessionProtos.DataMessage.Preview"; +::PROTOBUF_NAMESPACE_ID::Metadata DataMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[14]); } - // =================================================================== -class DataMessage_Reaction::_Internal { +class ReceiptMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_id(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_author(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_emoji(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_action(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x0000000d) ^ 0x0000000d) != 0; + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; } }; -DataMessage_Reaction::DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, +ReceiptMessage::ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(arena_constructor:SessionProtos.ReceiptMessage) } -DataMessage_Reaction::DataMessage_Reaction(const DataMessage_Reaction& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_Reaction* const _this = this; (void)_this; +ReceiptMessage::ReceiptMessage(const ReceiptMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + ReceiptMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.author_){} - , decltype(_impl_.emoji_){} - , decltype(_impl_.id_){} - , decltype(_impl_.action_){}}; + , decltype(_impl_.timestamp_){from._impl_.timestamp_} + , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.author_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_author()) { - _this->_impl_.author_.Set(from._internal_author(), - _this->GetArenaForAllocation()); - } - _impl_.emoji_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.emoji_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_emoji()) { - _this->_impl_.emoji_.Set(from._internal_emoji(), - _this->GetArenaForAllocation()); - } - ::memcpy(&_impl_.id_, &from._impl_.id_, - static_cast(reinterpret_cast(&_impl_.action_) - - reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.Reaction) + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.type_ = from._impl_.type_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.ReceiptMessage) } -inline void DataMessage_Reaction::SharedCtor( +inline void ReceiptMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.author_){} - , decltype(_impl_.emoji_){} - , decltype(_impl_.id_){uint64_t{0u}} - , decltype(_impl_.action_){0} + , decltype(_impl_.timestamp_){arena} + , decltype(_impl_.type_){0} }; - _impl_.author_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.author_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.emoji_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.emoji_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_Reaction::~DataMessage_Reaction() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Reaction) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +ReceiptMessage::~ReceiptMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.ReceiptMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_Reaction::SharedDtor() { +inline void ReceiptMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.author_.Destroy(); - _impl_.emoji_.Destroy(); + _impl_.timestamp_.~RepeatedField(); } -void DataMessage_Reaction::SetCachedSize(int size) const { +void ReceiptMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_Reaction::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.Reaction) +void ReceiptMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ReceiptMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _impl_.author_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.emoji_.ClearNonDefaultToEmpty(); - } - } - if (cached_has_bits & 0x0000000cu) { - ::memset(&_impl_.id_, 0, static_cast( - reinterpret_cast(&_impl_.action_) - - reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); - } + _impl_.timestamp_.Clear(); + _impl_.type_ = 0; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* ReceiptMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint64 id = 1; + // required .SessionProtos.ReceiptMessage.Type type = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_id(&has_bits); - _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // required string author = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_author(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string emoji = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_emoji(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::ReceiptMessage_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::ReceiptMessage_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // repeated uint64 timestamp = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_timestamp(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<16>(ptr)); + } else if (static_cast(tag) == 18) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt64Parser(_internal_mutable_timestamp(), ptr, ctx); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_Reaction_Action_IsValid(val))) { - _internal_set_action(static_cast<::SessionProtos::DataMessage_Reaction_Action>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields()); - } } else goto handle_unusual; continue; @@ -6482,7 +7123,7 @@ const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseC } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -6495,312 +7136,479 @@ const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseC #undef CHK_ } -uint8_t* DataMessage_Reaction::_InternalSerialize( +uint8_t* ReceiptMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ReceiptMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint64 id = 1; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_id(), target); - } - - // required string author = 2; + // required .SessionProtos.ReceiptMessage.Type type = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_author(), target); - } - - // optional string emoji = 3; - if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_emoji(), target); + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - if (cached_has_bits & 0x00000008u) { + // repeated uint64 timestamp = 2; + for (int i = 0, n = this->_internal_timestamp_size(); i < n; i++) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 4, this->_internal_action(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_timestamp(i), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ReceiptMessage) return target; } -size_t DataMessage_Reaction::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.Reaction) - size_t total_size = 0; - - if (_internal_has_author()) { - // required string author = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); - } - - if (_internal_has_id()) { - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - } - - if (_internal_has_action()) { - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); - } - - return total_size; -} -size_t DataMessage_Reaction::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.Reaction) +size_t ReceiptMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ReceiptMessage) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x0000000d) ^ 0x0000000d) == 0) { // All required fields are present. - // required string author = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_author()); - - // required uint64 id = 1; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_id()); - - // required .SessionProtos.DataMessage.Reaction.Action action = 4; + // required .SessionProtos.ReceiptMessage.Type type = 1; + if (_internal_has_type()) { total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_action()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // optional string emoji = 3; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_emoji()); + // repeated uint64 timestamp = 2; + { + size_t data_size = ::_pbi::WireFormatLite:: + UInt64Size(this->_impl_.timestamp_); + total_size += 1 * + ::_pbi::FromIntSize(this->_internal_timestamp_size()); + total_size += data_size; } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage_Reaction::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ReceiptMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + ReceiptMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ReceiptMessage::GetClassData() const { return &_class_data_; } -void DataMessage_Reaction::MergeFrom(const DataMessage_Reaction& from) { - DataMessage_Reaction* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Reaction) + +void ReceiptMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ReceiptMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { - _this->_internal_set_author(from._internal_author()); - } - if (cached_has_bits & 0x00000002u) { - _this->_internal_set_emoji(from._internal_emoji()); - } - if (cached_has_bits & 0x00000004u) { - _this->_impl_.id_ = from._impl_.id_; - } - if (cached_has_bits & 0x00000008u) { - _this->_impl_.action_ = from._impl_.action_; - } - _this->_impl_._has_bits_[0] |= cached_has_bits; + _this->_impl_.timestamp_.MergeFrom(from._impl_.timestamp_); + if (from._internal_has_type()) { + _this->_internal_set_type(from._internal_type()); } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage_Reaction::CopyFrom(const DataMessage_Reaction& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.Reaction) +void ReceiptMessage::CopyFrom(const ReceiptMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ReceiptMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_Reaction::IsInitialized() const { +bool ReceiptMessage::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage_Reaction::InternalSwap(DataMessage_Reaction* other) { +void ReceiptMessage::InternalSwap(ReceiptMessage* other) { using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.author_, lhs_arena, - &other->_impl_.author_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.emoji_, lhs_arena, - &other->_impl_.emoji_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.action_) - + sizeof(DataMessage_Reaction::_impl_.action_) - - PROTOBUF_FIELD_OFFSET(DataMessage_Reaction, _impl_.id_)>( - reinterpret_cast(&_impl_.id_), - reinterpret_cast(&other->_impl_.id_)); + _impl_.timestamp_.InternalSwap(&other->_impl_.timestamp_); + swap(_impl_.type_, other->_impl_.type_); } -std::string DataMessage_Reaction::GetTypeName() const { - return "SessionProtos.DataMessage.Reaction"; +::PROTOBUF_NAMESPACE_ID::Metadata ReceiptMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[15]); } - // =================================================================== -class DataMessage_OpenGroupInvitation::_Internal { +class AttachmentPointer::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_url(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 128u; + } + static void set_has_contenttype(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_name(HasBits* has_bits) { + static void set_has_key(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static void set_has_size(HasBits* has_bits) { + (*has_bits)[0] |= 256u; + } + static void set_has_thumbnail(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_digest(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_filename(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_flags(HasBits* has_bits) { + (*has_bits)[0] |= 512u; + } + static void set_has_width(HasBits* has_bits) { + (*has_bits)[0] |= 1024u; + } + static void set_has_height(HasBits* has_bits) { + (*has_bits)[0] |= 2048u; + } + static void set_has_caption(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static void set_has_url(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + return ((has_bits[0] & 0x00000080) ^ 0x00000080) != 0; } }; -DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, +AttachmentPointer::AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.OpenGroupInvitation) + // @@protoc_insertion_point(arena_constructor:SessionProtos.AttachmentPointer) } -DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_OpenGroupInvitation* const _this = this; (void)_this; +AttachmentPointer::AttachmentPointer(const AttachmentPointer& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + AttachmentPointer* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.contenttype_){} + , decltype(_impl_.key_){} + , decltype(_impl_.thumbnail_){} + , decltype(_impl_.digest_){} + , decltype(_impl_.filename_){} + , decltype(_impl_.caption_){} , decltype(_impl_.url_){} - , decltype(_impl_.name_){}}; + , decltype(_impl_.id_){} + , decltype(_impl_.size_){} + , decltype(_impl_.flags_){} + , decltype(_impl_.width_){} + , decltype(_impl_.height_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.url_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.contenttype_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_url()) { - _this->_impl_.url_.Set(from._internal_url(), + if (from._internal_has_contenttype()) { + _this->_impl_.contenttype_.Set(from._internal_contenttype(), _this->GetArenaForAllocation()); } - _impl_.name_.InitDefault(); + _impl_.key_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_.key_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_name()) { - _this->_impl_.name_.Set(from._internal_name(), + if (from._internal_has_key()) { + _this->_impl_.key_.Set(from._internal_key(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.OpenGroupInvitation) + _impl_.thumbnail_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.thumbnail_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_thumbnail()) { + _this->_impl_.thumbnail_.Set(from._internal_thumbnail(), + _this->GetArenaForAllocation()); + } + _impl_.digest_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.digest_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_digest()) { + _this->_impl_.digest_.Set(from._internal_digest(), + _this->GetArenaForAllocation()); + } + _impl_.filename_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.filename_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_filename()) { + _this->_impl_.filename_.Set(from._internal_filename(), + _this->GetArenaForAllocation()); + } + _impl_.caption_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.caption_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_caption()) { + _this->_impl_.caption_.Set(from._internal_caption(), + _this->GetArenaForAllocation()); + } + _impl_.url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), + _this->GetArenaForAllocation()); + } + ::memcpy(&_impl_.id_, &from._impl_.id_, + static_cast(reinterpret_cast(&_impl_.height_) - + reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.height_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.AttachmentPointer) } -inline void DataMessage_OpenGroupInvitation::SharedCtor( +inline void AttachmentPointer::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.contenttype_){} + , decltype(_impl_.key_){} + , decltype(_impl_.thumbnail_){} + , decltype(_impl_.digest_){} + , decltype(_impl_.filename_){} + , decltype(_impl_.caption_){} , decltype(_impl_.url_){} - , decltype(_impl_.name_){} + , decltype(_impl_.id_){uint64_t{0u}} + , decltype(_impl_.size_){0u} + , decltype(_impl_.flags_){0u} + , decltype(_impl_.width_){0u} + , decltype(_impl_.height_){0u} }; - _impl_.url_.InitDefault(); + _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); + _impl_.contenttype_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.InitDefault(); + _impl_.key_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); + _impl_.key_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.thumbnail_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.thumbnail_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.digest_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.digest_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.filename_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.filename_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.caption_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.caption_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_OpenGroupInvitation::~DataMessage_OpenGroupInvitation() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.OpenGroupInvitation) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +AttachmentPointer::~AttachmentPointer() { + // @@protoc_insertion_point(destructor:SessionProtos.AttachmentPointer) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_OpenGroupInvitation::SharedDtor() { +inline void AttachmentPointer::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.contenttype_.Destroy(); + _impl_.key_.Destroy(); + _impl_.thumbnail_.Destroy(); + _impl_.digest_.Destroy(); + _impl_.filename_.Destroy(); + _impl_.caption_.Destroy(); _impl_.url_.Destroy(); - _impl_.name_.Destroy(); } -void DataMessage_OpenGroupInvitation::SetCachedSize(int size) const { +void AttachmentPointer::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_OpenGroupInvitation::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.OpenGroupInvitation) +void AttachmentPointer::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.AttachmentPointer) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x0000007fu) { if (cached_has_bits & 0x00000001u) { - _impl_.url_.ClearNonDefaultToEmpty(); + _impl_.contenttype_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.name_.ClearNonDefaultToEmpty(); + _impl_.key_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + _impl_.thumbnail_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000008u) { + _impl_.digest_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000010u) { + _impl_.filename_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000020u) { + _impl_.caption_.ClearNonDefaultToEmpty(); } + if (cached_has_bits & 0x00000040u) { + _impl_.url_.ClearNonDefaultToEmpty(); + } + } + _impl_.id_ = uint64_t{0u}; + if (cached_has_bits & 0x00000f00u) { + ::memset(&_impl_.size_, 0, static_cast( + reinterpret_cast(&_impl_.height_) - + reinterpret_cast(&_impl_.size_)) + sizeof(_impl_.height_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required string url = 1; + // required fixed64 id = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_url(); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 9)) { + _Internal::set_has_id(&has_bits); + _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); + ptr += sizeof(uint64_t); + } else + goto handle_unusual; + continue; + // optional string contentType = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_contenttype(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.contentType"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // required string name = 3; + // optional bytes key = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_name(); + auto str = _internal_mutable_key(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional uint32 size = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_size(&has_bits); + _impl_.size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes thumbnail = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_thumbnail(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes digest = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { + auto str = _internal_mutable_digest(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string fileName = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { + auto str = _internal_mutable_filename(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.fileName"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // optional uint32 flags = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 64)) { + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional uint32 width = 9; + case 9: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 72)) { + _Internal::set_has_width(&has_bits); + _impl_.width_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional uint32 height = 10; + case 10: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 80)) { + _Internal::set_has_height(&has_bits); + _impl_.height_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string caption = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { + auto str = _internal_mutable_caption(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.caption"); + #endif // !NDEBUG + } else + goto handle_unusual; + continue; + // optional string url = 101; + case 101: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.url"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6815,7 +7623,7 @@ const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_ } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -6828,270 +7636,455 @@ const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_ #undef CHK_ } -uint8_t* DataMessage_OpenGroupInvitation::_InternalSerialize( +uint8_t* AttachmentPointer::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.OpenGroupInvitation) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.AttachmentPointer) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required string url = 1; + // required fixed64 id = 1; + if (cached_has_bits & 0x00000080u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteFixed64ToArray(1, this->_internal_id(), target); + } + + // optional string contentType = 2; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_contenttype().data(), static_cast(this->_internal_contenttype().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.AttachmentPointer.contentType"); target = stream->WriteStringMaybeAliased( - 1, this->_internal_url(), target); + 2, this->_internal_contenttype(), target); } - // required string name = 3; + // optional bytes key = 3; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_name(), target); + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_key(), target); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + // optional uint32 size = 4; + if (cached_has_bits & 0x00000100u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_size(), target); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.OpenGroupInvitation) - return target; -} -size_t DataMessage_OpenGroupInvitation::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.OpenGroupInvitation) - size_t total_size = 0; + // optional bytes thumbnail = 5; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 5, this->_internal_thumbnail(), target); + } - if (_internal_has_url()) { - // required string url = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); + // optional bytes digest = 6; + if (cached_has_bits & 0x00000008u) { + target = stream->WriteBytesMaybeAliased( + 6, this->_internal_digest(), target); } - if (_internal_has_name()) { - // required string name = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + // optional string fileName = 7; + if (cached_has_bits & 0x00000010u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_filename().data(), static_cast(this->_internal_filename().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.AttachmentPointer.fileName"); + target = stream->WriteStringMaybeAliased( + 7, this->_internal_filename(), target); } - return total_size; -} -size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.OpenGroupInvitation) - size_t total_size = 0; + // optional uint32 flags = 8; + if (cached_has_bits & 0x00000200u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_flags(), target); + } - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string url = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); + // optional uint32 width = 9; + if (cached_has_bits & 0x00000400u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(9, this->_internal_width(), target); + } - // required string name = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + // optional uint32 height = 10; + if (cached_has_bits & 0x00000800u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(10, this->_internal_height(), target); + } - } else { - total_size += RequiredFieldsByteSizeFallback(); + // optional string caption = 11; + if (cached_has_bits & 0x00000020u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_caption().data(), static_cast(this->_internal_caption().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.AttachmentPointer.caption"); + target = stream->WriteStringMaybeAliased( + 11, this->_internal_caption(), target); + } + + // optional string url = 101; + if (cached_has_bits & 0x00000040u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_url().data(), static_cast(this->_internal_url().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.AttachmentPointer.url"); + target = stream->WriteStringMaybeAliased( + 101, this->_internal_url(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.AttachmentPointer) + return target; +} + +size_t AttachmentPointer::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.AttachmentPointer) + size_t total_size = 0; + + // required fixed64 id = 1; + if (_internal_has_id()) { + total_size += 1 + 8; } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000007fu) { + // optional string contentType = 2; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_contenttype()); + } + + // optional bytes key = 3; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_key()); + } + + // optional bytes thumbnail = 5; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_thumbnail()); + } + + // optional bytes digest = 6; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_digest()); + } + + // optional string fileName = 7; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_filename()); + } + + // optional string caption = 11; + if (cached_has_bits & 0x00000020u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_caption()); + } + + // optional string url = 101; + if (cached_has_bits & 0x00000040u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); + } + } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} + if (cached_has_bits & 0x00000f00u) { + // optional uint32 size = 4; + if (cached_has_bits & 0x00000100u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_size()); + } + + // optional uint32 flags = 8; + if (cached_has_bits & 0x00000200u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + + // optional uint32 width = 9; + if (cached_has_bits & 0x00000400u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_width()); + } + + // optional uint32 height = 10; + if (cached_has_bits & 0x00000800u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_height()); + } -void DataMessage_OpenGroupInvitation::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); + } + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage_OpenGroupInvitation::MergeFrom(const DataMessage_OpenGroupInvitation& from) { - DataMessage_OpenGroupInvitation* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.OpenGroupInvitation) +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData AttachmentPointer::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + AttachmentPointer::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*AttachmentPointer::GetClassData() const { return &_class_data_; } + + +void AttachmentPointer::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.AttachmentPointer) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_url(from._internal_url()); + _this->_internal_set_contenttype(from._internal_contenttype()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_name(from._internal_name()); + _this->_internal_set_key(from._internal_key()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_thumbnail(from._internal_thumbnail()); + } + if (cached_has_bits & 0x00000008u) { + _this->_internal_set_digest(from._internal_digest()); + } + if (cached_has_bits & 0x00000010u) { + _this->_internal_set_filename(from._internal_filename()); + } + if (cached_has_bits & 0x00000020u) { + _this->_internal_set_caption(from._internal_caption()); + } + if (cached_has_bits & 0x00000040u) { + _this->_internal_set_url(from._internal_url()); + } + if (cached_has_bits & 0x00000080u) { + _this->_impl_.id_ = from._impl_.id_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + if (cached_has_bits & 0x00000f00u) { + if (cached_has_bits & 0x00000100u) { + _this->_impl_.size_ = from._impl_.size_; + } + if (cached_has_bits & 0x00000200u) { + _this->_impl_.flags_ = from._impl_.flags_; + } + if (cached_has_bits & 0x00000400u) { + _this->_impl_.width_ = from._impl_.width_; + } + if (cached_has_bits & 0x00000800u) { + _this->_impl_.height_ = from._impl_.height_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage_OpenGroupInvitation::CopyFrom(const DataMessage_OpenGroupInvitation& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.OpenGroupInvitation) +void AttachmentPointer::CopyFrom(const AttachmentPointer& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.AttachmentPointer) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_OpenGroupInvitation::IsInitialized() const { +bool AttachmentPointer::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage_OpenGroupInvitation::InternalSwap(DataMessage_OpenGroupInvitation* other) { +void AttachmentPointer::InternalSwap(AttachmentPointer* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.url_, lhs_arena, - &other->_impl_.url_, rhs_arena + &_impl_.contenttype_, lhs_arena, + &other->_impl_.contenttype_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.name_, lhs_arena, - &other->_impl_.name_, rhs_arena + &_impl_.key_, lhs_arena, + &other->_impl_.key_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.thumbnail_, lhs_arena, + &other->_impl_.thumbnail_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.digest_, lhs_arena, + &other->_impl_.digest_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.filename_, lhs_arena, + &other->_impl_.filename_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.caption_, lhs_arena, + &other->_impl_.caption_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(AttachmentPointer, _impl_.height_) + + sizeof(AttachmentPointer::_impl_.height_) + - PROTOBUF_FIELD_OFFSET(AttachmentPointer, _impl_.id_)>( + reinterpret_cast(&_impl_.id_), + reinterpret_cast(&other->_impl_.id_)); } -std::string DataMessage_OpenGroupInvitation::GetTypeName() const { - return "SessionProtos.DataMessage.OpenGroupInvitation"; +::PROTOBUF_NAMESPACE_ID::Metadata AttachmentPointer::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[16]); } - // =================================================================== -class DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_Internal { +class SharedConfigMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { - (*has_bits)[0] |= 1u; + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_kind(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static void set_has_encryptedkeypair(HasBits* has_bits) { + static void set_has_seqno(HasBits* has_bits) { (*has_bits)[0] |= 2u; } + static void set_has_data(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; } }; -DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::Arena* arena, +SharedConfigMessage::SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(arena_constructor:SessionProtos.SharedConfigMessage) } -DataMessage_ClosedGroupControlMessage_KeyPairWrapper::DataMessage_ClosedGroupControlMessage_KeyPairWrapper(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_ClosedGroupControlMessage_KeyPairWrapper* const _this = this; (void)_this; +SharedConfigMessage::SharedConfigMessage(const SharedConfigMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + SharedConfigMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.encryptedkeypair_){}}; + , decltype(_impl_.data_){} + , decltype(_impl_.seqno_){} + , decltype(_impl_.kind_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), - _this->GetArenaForAllocation()); - } - _impl_.encryptedkeypair_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.data_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); + _impl_.data_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_encryptedkeypair()) { - _this->_impl_.encryptedkeypair_.Set(from._internal_encryptedkeypair(), + if (from._internal_has_data()) { + _this->_impl_.data_.Set(from._internal_data(), _this->GetArenaForAllocation()); } - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + ::memcpy(&_impl_.seqno_, &from._impl_.seqno_, + static_cast(reinterpret_cast(&_impl_.kind_) - + reinterpret_cast(&_impl_.seqno_)) + sizeof(_impl_.kind_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.SharedConfigMessage) } -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SharedCtor( +inline void SharedConfigMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.encryptedkeypair_){} + , decltype(_impl_.data_){} + , decltype(_impl_.seqno_){int64_t{0}} + , decltype(_impl_.kind_){1} }; - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.encryptedkeypair_.InitDefault(); + _impl_.data_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); + _impl_.data_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_ClosedGroupControlMessage_KeyPairWrapper::~DataMessage_ClosedGroupControlMessage_KeyPairWrapper() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +SharedConfigMessage::~SharedConfigMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.SharedConfigMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SharedDtor() { +inline void SharedConfigMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.publickey_.Destroy(); - _impl_.encryptedkeypair_.Destroy(); + _impl_.data_.Destroy(); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::SetCachedSize(int size) const { +void SharedConfigMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +void SharedConfigMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.SharedConfigMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.encryptedkeypair_.ClearNonDefaultToEmpty(); - } + if (cached_has_bits & 0x00000001u) { + _impl_.data_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000006u) { + _impl_.seqno_ = int64_t{0}; + _impl_.kind_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* SharedConfigMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes publicKey = 1; + // required .SessionProtos.SharedConfigMessage.Kind kind = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::SharedConfigMessage_Kind_IsValid(val))) { + _internal_set_kind(static_cast<::SessionProtos::SharedConfigMessage_Kind>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // required bytes encryptedKeyPair = 2; + // required int64 seqno = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_encryptedkeypair(); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_seqno(&has_bits); + _impl_.seqno_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bytes data = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_data(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else @@ -7108,7 +8101,7 @@ const char* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalParse } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -7121,67 +8114,80 @@ const char* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalParse #undef CHK_ } -uint8_t* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_InternalSerialize( +uint8_t* SharedConfigMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.SharedConfigMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes publicKey = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + // required .SessionProtos.SharedConfigMessage.Kind kind = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_kind(), target); } - // required bytes encryptedKeyPair = 2; + // required int64 seqno = 2; if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_seqno(), target); + } + + // required bytes data = 3; + if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 2, this->_internal_encryptedkeypair(), target); + 3, this->_internal_data(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.SharedConfigMessage) return target; } -size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +size_t SharedConfigMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.SharedConfigMessage) size_t total_size = 0; - if (_internal_has_publickey()) { - // required bytes publicKey = 1; + if (_internal_has_data()) { + // required bytes data = 3; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + this->_internal_data()); + } + + if (_internal_has_seqno()) { + // required int64 seqno = 2; + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seqno()); } - if (_internal_has_encryptedkeypair()) { - // required bytes encryptedKeyPair = 2; + if (_internal_has_kind()) { + // required .SessionProtos.SharedConfigMessage.Kind kind = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_encryptedkeypair()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_kind()); } return total_size; } -size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +size_t SharedConfigMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.SharedConfigMessage) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes publicKey = 1; + if (((_impl_._has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required bytes data = 3; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + this->_internal_data()); + + // required int64 seqno = 2; + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seqno()); - // required bytes encryptedKeyPair = 2; + // required .SessionProtos.SharedConfigMessage.Kind kind = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_encryptedkeypair()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_kind()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -7190,320 +8196,347 @@ size_t DataMessage_ClosedGroupControlMessage_KeyPairWrapper::ByteSizeLong() cons // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SharedConfigMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + SharedConfigMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SharedConfigMessage::GetClassData() const { return &_class_data_; } + -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::MergeFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { - DataMessage_ClosedGroupControlMessage_KeyPairWrapper* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +void SharedConfigMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.SharedConfigMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_data(from._internal_data()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_encryptedkeypair(from._internal_encryptedkeypair()); + _this->_impl_.seqno_ = from._impl_.seqno_; } + if (cached_has_bits & 0x00000004u) { + _this->_impl_.kind_ = from._impl_.kind_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::CopyFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) +void SharedConfigMessage::CopyFrom(const SharedConfigMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.SharedConfigMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::IsInitialized() const { +bool SharedConfigMessage::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::InternalSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { +void SharedConfigMessage::InternalSwap(SharedConfigMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.encryptedkeypair_, lhs_arena, - &other->_impl_.encryptedkeypair_, rhs_arena + &_impl_.data_, lhs_arena, + &other->_impl_.data_, rhs_arena ); + swap(_impl_.seqno_, other->_impl_.seqno_); + swap(_impl_.kind_, other->_impl_.kind_); } -std::string DataMessage_ClosedGroupControlMessage_KeyPairWrapper::GetTypeName() const { - return "SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper"; +::PROTOBUF_NAMESPACE_ID::Metadata SharedConfigMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[17]); } - // =================================================================== -class DataMessage_ClosedGroupControlMessage::_Internal { +class GroupUpdateMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static void set_has_publickey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static const ::SessionProtos::GroupUpdateInviteMessage& invitemessage(const GroupUpdateMessage* msg); + static void set_has_invitemessage(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_name(HasBits* has_bits) { + static const ::SessionProtos::GroupUpdateInfoChangeMessage& infochangemessage(const GroupUpdateMessage* msg); + static void set_has_infochangemessage(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::KeyPair& encryptionkeypair(const DataMessage_ClosedGroupControlMessage* msg); - static void set_has_encryptionkeypair(HasBits* has_bits) { + static const ::SessionProtos::GroupUpdateMemberChangeMessage& memberchangemessage(const GroupUpdateMessage* msg); + static void set_has_memberchangemessage(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static void set_has_expirationtimer(HasBits* has_bits) { + static const ::SessionProtos::GroupUpdatePromoteMessage& promotemessage(const GroupUpdateMessage* msg); + static void set_has_promotemessage(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000010) ^ 0x00000010) != 0; + static const ::SessionProtos::GroupUpdateMemberLeftMessage& memberleftmessage(const GroupUpdateMessage* msg); + static void set_has_memberleftmessage(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static const ::SessionProtos::GroupUpdateInviteResponseMessage& inviteresponse(const GroupUpdateMessage* msg); + static void set_has_inviteresponse(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static const ::SessionProtos::GroupUpdateDeleteMemberContentMessage& deletemembercontent(const GroupUpdateMessage* msg); + static void set_has_deletemembercontent(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } + static const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage& memberleftnotificationmessage(const GroupUpdateMessage* msg); + static void set_has_memberleftnotificationmessage(HasBits* has_bits) { + (*has_bits)[0] |= 128u; } }; -const ::SessionProtos::KeyPair& -DataMessage_ClosedGroupControlMessage::_Internal::encryptionkeypair(const DataMessage_ClosedGroupControlMessage* msg) { - return *msg->_impl_.encryptionkeypair_; +const ::SessionProtos::GroupUpdateInviteMessage& +GroupUpdateMessage::_Internal::invitemessage(const GroupUpdateMessage* msg) { + return *msg->_impl_.invitemessage_; +} +const ::SessionProtos::GroupUpdateInfoChangeMessage& +GroupUpdateMessage::_Internal::infochangemessage(const GroupUpdateMessage* msg) { + return *msg->_impl_.infochangemessage_; +} +const ::SessionProtos::GroupUpdateMemberChangeMessage& +GroupUpdateMessage::_Internal::memberchangemessage(const GroupUpdateMessage* msg) { + return *msg->_impl_.memberchangemessage_; +} +const ::SessionProtos::GroupUpdatePromoteMessage& +GroupUpdateMessage::_Internal::promotemessage(const GroupUpdateMessage* msg) { + return *msg->_impl_.promotemessage_; +} +const ::SessionProtos::GroupUpdateMemberLeftMessage& +GroupUpdateMessage::_Internal::memberleftmessage(const GroupUpdateMessage* msg) { + return *msg->_impl_.memberleftmessage_; +} +const ::SessionProtos::GroupUpdateInviteResponseMessage& +GroupUpdateMessage::_Internal::inviteresponse(const GroupUpdateMessage* msg) { + return *msg->_impl_.inviteresponse_; } -DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +const ::SessionProtos::GroupUpdateDeleteMemberContentMessage& +GroupUpdateMessage::_Internal::deletemembercontent(const GroupUpdateMessage* msg) { + return *msg->_impl_.deletemembercontent_; +} +const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage& +GroupUpdateMessage::_Internal::memberleftnotificationmessage(const GroupUpdateMessage* msg) { + return *msg->_impl_.memberleftnotificationmessage_; +} +GroupUpdateMessage::GroupUpdateMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMessage) } -DataMessage_ClosedGroupControlMessage::DataMessage_ClosedGroupControlMessage(const DataMessage_ClosedGroupControlMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage_ClosedGroupControlMessage* const _this = this; (void)_this; +GroupUpdateMessage::GroupUpdateMessage(const GroupUpdateMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdateMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.members_){from._impl_.members_} - , decltype(_impl_.admins_){from._impl_.admins_} - , decltype(_impl_.wrappers_){from._impl_.wrappers_} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){} - , decltype(_impl_.type_){}}; + , decltype(_impl_.invitemessage_){nullptr} + , decltype(_impl_.infochangemessage_){nullptr} + , decltype(_impl_.memberchangemessage_){nullptr} + , decltype(_impl_.promotemessage_){nullptr} + , decltype(_impl_.memberleftmessage_){nullptr} + , decltype(_impl_.inviteresponse_){nullptr} + , decltype(_impl_.deletemembercontent_){nullptr} + , decltype(_impl_.memberleftnotificationmessage_){nullptr}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), - _this->GetArenaForAllocation()); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_invitemessage()) { + _this->_impl_.invitemessage_ = new ::SessionProtos::GroupUpdateInviteMessage(*from._impl_.invitemessage_); } - _impl_.name_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_name()) { - _this->_impl_.name_.Set(from._internal_name(), - _this->GetArenaForAllocation()); + if (from._internal_has_infochangemessage()) { + _this->_impl_.infochangemessage_ = new ::SessionProtos::GroupUpdateInfoChangeMessage(*from._impl_.infochangemessage_); } - if (from._internal_has_encryptionkeypair()) { - _this->_impl_.encryptionkeypair_ = new ::SessionProtos::KeyPair(*from._impl_.encryptionkeypair_); + if (from._internal_has_memberchangemessage()) { + _this->_impl_.memberchangemessage_ = new ::SessionProtos::GroupUpdateMemberChangeMessage(*from._impl_.memberchangemessage_); } - ::memcpy(&_impl_.expirationtimer_, &from._impl_.expirationtimer_, - static_cast(reinterpret_cast(&_impl_.type_) - - reinterpret_cast(&_impl_.expirationtimer_)) + sizeof(_impl_.type_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage.ClosedGroupControlMessage) + if (from._internal_has_promotemessage()) { + _this->_impl_.promotemessage_ = new ::SessionProtos::GroupUpdatePromoteMessage(*from._impl_.promotemessage_); + } + if (from._internal_has_memberleftmessage()) { + _this->_impl_.memberleftmessage_ = new ::SessionProtos::GroupUpdateMemberLeftMessage(*from._impl_.memberleftmessage_); + } + if (from._internal_has_inviteresponse()) { + _this->_impl_.inviteresponse_ = new ::SessionProtos::GroupUpdateInviteResponseMessage(*from._impl_.inviteresponse_); + } + if (from._internal_has_deletemembercontent()) { + _this->_impl_.deletemembercontent_ = new ::SessionProtos::GroupUpdateDeleteMemberContentMessage(*from._impl_.deletemembercontent_); + } + if (from._internal_has_memberleftnotificationmessage()) { + _this->_impl_.memberleftnotificationmessage_ = new ::SessionProtos::GroupUpdateMemberLeftNotificationMessage(*from._impl_.memberleftnotificationmessage_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateMessage) } -inline void DataMessage_ClosedGroupControlMessage::SharedCtor( +inline void GroupUpdateMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.members_){arena} - , decltype(_impl_.admins_){arena} - , decltype(_impl_.wrappers_){arena} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){0u} - , decltype(_impl_.type_){1} + , decltype(_impl_.invitemessage_){nullptr} + , decltype(_impl_.infochangemessage_){nullptr} + , decltype(_impl_.memberchangemessage_){nullptr} + , decltype(_impl_.promotemessage_){nullptr} + , decltype(_impl_.memberleftmessage_){nullptr} + , decltype(_impl_.inviteresponse_){nullptr} + , decltype(_impl_.deletemembercontent_){nullptr} + , decltype(_impl_.memberleftnotificationmessage_){nullptr} }; - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -DataMessage_ClosedGroupControlMessage::~DataMessage_ClosedGroupControlMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.ClosedGroupControlMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +GroupUpdateMessage::~GroupUpdateMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage_ClosedGroupControlMessage::SharedDtor() { +inline void GroupUpdateMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.members_.~RepeatedPtrField(); - _impl_.admins_.~RepeatedPtrField(); - _impl_.wrappers_.~RepeatedPtrField(); - _impl_.publickey_.Destroy(); - _impl_.name_.Destroy(); - if (this != internal_default_instance()) delete _impl_.encryptionkeypair_; + if (this != internal_default_instance()) delete _impl_.invitemessage_; + if (this != internal_default_instance()) delete _impl_.infochangemessage_; + if (this != internal_default_instance()) delete _impl_.memberchangemessage_; + if (this != internal_default_instance()) delete _impl_.promotemessage_; + if (this != internal_default_instance()) delete _impl_.memberleftmessage_; + if (this != internal_default_instance()) delete _impl_.inviteresponse_; + if (this != internal_default_instance()) delete _impl_.deletemembercontent_; + if (this != internal_default_instance()) delete _impl_.memberleftnotificationmessage_; } -void DataMessage_ClosedGroupControlMessage::SetCachedSize(int size) const { +void GroupUpdateMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage_ClosedGroupControlMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +void GroupUpdateMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.members_.Clear(); - _impl_.admins_.Clear(); - _impl_.wrappers_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.invitemessage_ != nullptr); + _impl_.invitemessage_->Clear(); } if (cached_has_bits & 0x00000002u) { - _impl_.name_.ClearNonDefaultToEmpty(); + GOOGLE_DCHECK(_impl_.infochangemessage_ != nullptr); + _impl_.infochangemessage_->Clear(); } if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.encryptionkeypair_ != nullptr); - _impl_.encryptionkeypair_->Clear(); + GOOGLE_DCHECK(_impl_.memberchangemessage_ != nullptr); + _impl_.memberchangemessage_->Clear(); + } + if (cached_has_bits & 0x00000008u) { + GOOGLE_DCHECK(_impl_.promotemessage_ != nullptr); + _impl_.promotemessage_->Clear(); + } + if (cached_has_bits & 0x00000010u) { + GOOGLE_DCHECK(_impl_.memberleftmessage_ != nullptr); + _impl_.memberleftmessage_->Clear(); + } + if (cached_has_bits & 0x00000020u) { + GOOGLE_DCHECK(_impl_.inviteresponse_ != nullptr); + _impl_.inviteresponse_->Clear(); + } + if (cached_has_bits & 0x00000040u) { + GOOGLE_DCHECK(_impl_.deletemembercontent_ != nullptr); + _impl_.deletemembercontent_->Clear(); + } + if (cached_has_bits & 0x00000080u) { + GOOGLE_DCHECK(_impl_.memberleftnotificationmessage_ != nullptr); + _impl_.memberleftnotificationmessage_->Clear(); } - } - if (cached_has_bits & 0x00000018u) { - _impl_.expirationtimer_ = 0u; - _impl_.type_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage_ClosedGroupControlMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* GroupUpdateMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; + // optional .SessionProtos.GroupUpdateInviteMessage inviteMessage = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_invitemessage(), ptr); CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::DataMessage_ClosedGroupControlMessage_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } } else goto handle_unusual; continue; - // optional bytes publicKey = 2; + // optional .SessionProtos.GroupUpdateInfoChangeMessage infoChangeMessage = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_publickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_infochangemessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional string name = 3; + // optional .SessionProtos.GroupUpdateMemberChangeMessage memberChangeMessage = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_name(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + ptr = ctx->ParseMessage(_internal_mutable_memberchangemessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; + // optional .SessionProtos.GroupUpdatePromoteMessage promoteMessage = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr = ctx->ParseMessage(_internal_mutable_encryptionkeypair(), ptr); + ptr = ctx->ParseMessage(_internal_mutable_promotemessage(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // repeated bytes members = 5; + // optional .SessionProtos.GroupUpdateMemberLeftMessage memberLeftMessage = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_members(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + ptr = ctx->ParseMessage(_internal_mutable_memberleftmessage(), ptr); + CHK_(ptr); } else goto handle_unusual; continue; - // repeated bytes admins = 6; + // optional .SessionProtos.GroupUpdateInviteResponseMessage inviteResponse = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_admins(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); + ptr = ctx->ParseMessage(_internal_mutable_inviteresponse(), ptr); + CHK_(ptr); } else goto handle_unusual; continue; - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; + // optional .SessionProtos.GroupUpdateDeleteMemberContentMessage deleteMemberContent = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_wrappers(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr)); + ptr = ctx->ParseMessage(_internal_mutable_deletemembercontent(), ptr); + CHK_(ptr); } else goto handle_unusual; continue; - // optional uint32 expirationTimer = 8; + // optional .SessionProtos.GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8; case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 64)) { - _Internal::set_has_expirationtimer(&has_bits); - _impl_.expirationtimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { + ptr = ctx->ParseMessage(_internal_mutable_memberleftnotificationmessage(), ptr); CHK_(ptr); } else goto handle_unusual; @@ -7519,7 +8552,7 @@ const char* DataMessage_ClosedGroupControlMessage::_InternalParse(const char* pt } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -7532,618 +8565,440 @@ const char* DataMessage_ClosedGroupControlMessage::_InternalParse(const char* pt #undef CHK_ } -uint8_t* DataMessage_ClosedGroupControlMessage::_InternalSerialize( +uint8_t* GroupUpdateMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); - } - - // optional bytes publicKey = 2; + // optional .SessionProtos.GroupUpdateInviteMessage inviteMessage = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 2, this->_internal_publickey(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::invitemessage(this), + _Internal::invitemessage(this).GetCachedSize(), target, stream); } - // optional string name = 3; + // optional .SessionProtos.GroupUpdateInfoChangeMessage infoChangeMessage = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_name(), target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, _Internal::infochangemessage(this), + _Internal::infochangemessage(this).GetCachedSize(), target, stream); } - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; + // optional .SessionProtos.GroupUpdateMemberChangeMessage memberChangeMessage = 3; if (cached_has_bits & 0x00000004u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, _Internal::encryptionkeypair(this), - _Internal::encryptionkeypair(this).GetCachedSize(), target, stream); + InternalWriteMessage(3, _Internal::memberchangemessage(this), + _Internal::memberchangemessage(this).GetCachedSize(), target, stream); } - // repeated bytes members = 5; - for (int i = 0, n = this->_internal_members_size(); i < n; i++) { - const auto& s = this->_internal_members(i); - target = stream->WriteBytes(5, s, target); + // optional .SessionProtos.GroupUpdatePromoteMessage promoteMessage = 4; + if (cached_has_bits & 0x00000008u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, _Internal::promotemessage(this), + _Internal::promotemessage(this).GetCachedSize(), target, stream); } - // repeated bytes admins = 6; - for (int i = 0, n = this->_internal_admins_size(); i < n; i++) { - const auto& s = this->_internal_admins(i); - target = stream->WriteBytes(6, s, target); + // optional .SessionProtos.GroupUpdateMemberLeftMessage memberLeftMessage = 5; + if (cached_has_bits & 0x00000010u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(5, _Internal::memberleftmessage(this), + _Internal::memberleftmessage(this).GetCachedSize(), target, stream); } - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - for (unsigned i = 0, - n = static_cast(this->_internal_wrappers_size()); i < n; i++) { - const auto& repfield = this->_internal_wrappers(i); + // optional .SessionProtos.GroupUpdateInviteResponseMessage inviteResponse = 6; + if (cached_has_bits & 0x00000020u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, repfield, repfield.GetCachedSize(), target, stream); + InternalWriteMessage(6, _Internal::inviteresponse(this), + _Internal::inviteresponse(this).GetCachedSize(), target, stream); } - // optional uint32 expirationTimer = 8; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_expirationtimer(), target); + // optional .SessionProtos.GroupUpdateDeleteMemberContentMessage deleteMemberContent = 7; + if (cached_has_bits & 0x00000040u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(7, _Internal::deletemembercontent(this), + _Internal::deletemembercontent(this).GetCachedSize(), target, stream); + } + + // optional .SessionProtos.GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8; + if (cached_has_bits & 0x00000080u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(8, _Internal::memberleftnotificationmessage(this), + _Internal::memberleftnotificationmessage(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateMessage) return target; } -size_t DataMessage_ClosedGroupControlMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +size_t GroupUpdateMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateMessage) size_t total_size = 0; - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; - if (_internal_has_type()) { - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated bytes members = 5; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.members_.size()); - for (int i = 0, n = _impl_.members_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - _impl_.members_.Get(i)); - } - - // repeated bytes admins = 6; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.admins_.size()); - for (int i = 0, n = _impl_.admins_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - _impl_.admins_.Get(i)); - } - - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - total_size += 1UL * this->_internal_wrappers_size(); - for (const auto& msg : this->_impl_.wrappers_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional bytes publicKey = 2; + if (cached_has_bits & 0x000000ffu) { + // optional .SessionProtos.GroupUpdateInviteMessage inviteMessage = 1; if (cached_has_bits & 0x00000001u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.invitemessage_); } - // optional string name = 3; + // optional .SessionProtos.GroupUpdateInfoChangeMessage infoChangeMessage = 2; if (cached_has_bits & 0x00000002u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.infochangemessage_); } - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; + // optional .SessionProtos.GroupUpdateMemberChangeMessage memberChangeMessage = 3; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.encryptionkeypair_); + *_impl_.memberchangemessage_); } - // optional uint32 expirationTimer = 8; + // optional .SessionProtos.GroupUpdatePromoteMessage promoteMessage = 4; if (cached_has_bits & 0x00000008u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.promotemessage_); + } + + // optional .SessionProtos.GroupUpdateMemberLeftMessage memberLeftMessage = 5; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.memberleftmessage_); + } + + // optional .SessionProtos.GroupUpdateInviteResponseMessage inviteResponse = 6; + if (cached_has_bits & 0x00000020u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.inviteresponse_); + } + + // optional .SessionProtos.GroupUpdateDeleteMemberContentMessage deleteMemberContent = 7; + if (cached_has_bits & 0x00000040u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.deletemembercontent_); + } + + // optional .SessionProtos.GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8; + if (cached_has_bits & 0x00000080u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.memberleftnotificationmessage_); } } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage_ClosedGroupControlMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdateMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMessage::GetClassData() const { return &_class_data_; } -void DataMessage_ClosedGroupControlMessage::MergeFrom(const DataMessage_ClosedGroupControlMessage& from) { - DataMessage_ClosedGroupControlMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage) + +void GroupUpdateMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.members_.MergeFrom(from._impl_.members_); - _this->_impl_.admins_.MergeFrom(from._impl_.admins_); - _this->_impl_.wrappers_.MergeFrom(from._impl_.wrappers_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_mutable_invitemessage()->::SessionProtos::GroupUpdateInviteMessage::MergeFrom( + from._internal_invitemessage()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_name(from._internal_name()); + _this->_internal_mutable_infochangemessage()->::SessionProtos::GroupUpdateInfoChangeMessage::MergeFrom( + from._internal_infochangemessage()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_encryptionkeypair()->::SessionProtos::KeyPair::MergeFrom( - from._internal_encryptionkeypair()); + _this->_internal_mutable_memberchangemessage()->::SessionProtos::GroupUpdateMemberChangeMessage::MergeFrom( + from._internal_memberchangemessage()); } if (cached_has_bits & 0x00000008u) { - _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; + _this->_internal_mutable_promotemessage()->::SessionProtos::GroupUpdatePromoteMessage::MergeFrom( + from._internal_promotemessage()); } if (cached_has_bits & 0x00000010u) { - _this->_impl_.type_ = from._impl_.type_; + _this->_internal_mutable_memberleftmessage()->::SessionProtos::GroupUpdateMemberLeftMessage::MergeFrom( + from._internal_memberleftmessage()); + } + if (cached_has_bits & 0x00000020u) { + _this->_internal_mutable_inviteresponse()->::SessionProtos::GroupUpdateInviteResponseMessage::MergeFrom( + from._internal_inviteresponse()); + } + if (cached_has_bits & 0x00000040u) { + _this->_internal_mutable_deletemembercontent()->::SessionProtos::GroupUpdateDeleteMemberContentMessage::MergeFrom( + from._internal_deletemembercontent()); + } + if (cached_has_bits & 0x00000080u) { + _this->_internal_mutable_memberleftnotificationmessage()->::SessionProtos::GroupUpdateMemberLeftNotificationMessage::MergeFrom( + from._internal_memberleftnotificationmessage()); } - _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage_ClosedGroupControlMessage::CopyFrom(const DataMessage_ClosedGroupControlMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage.ClosedGroupControlMessage) +void GroupUpdateMessage::CopyFrom(const GroupUpdateMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage_ClosedGroupControlMessage::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.wrappers_)) - return false; - if (_internal_has_encryptionkeypair()) { - if (!_impl_.encryptionkeypair_->IsInitialized()) return false; +bool GroupUpdateMessage::IsInitialized() const { + if (_internal_has_invitemessage()) { + if (!_impl_.invitemessage_->IsInitialized()) return false; + } + if (_internal_has_infochangemessage()) { + if (!_impl_.infochangemessage_->IsInitialized()) return false; + } + if (_internal_has_memberchangemessage()) { + if (!_impl_.memberchangemessage_->IsInitialized()) return false; + } + if (_internal_has_promotemessage()) { + if (!_impl_.promotemessage_->IsInitialized()) return false; + } + if (_internal_has_inviteresponse()) { + if (!_impl_.inviteresponse_->IsInitialized()) return false; } return true; } -void DataMessage_ClosedGroupControlMessage::InternalSwap(DataMessage_ClosedGroupControlMessage* other) { +void GroupUpdateMessage::InternalSwap(GroupUpdateMessage* other) { using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.members_.InternalSwap(&other->_impl_.members_); - _impl_.admins_.InternalSwap(&other->_impl_.admins_); - _impl_.wrappers_.InternalSwap(&other->_impl_.wrappers_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.name_, lhs_arena, - &other->_impl_.name_, rhs_arena - ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage_ClosedGroupControlMessage, _impl_.expirationtimer_) - + sizeof(DataMessage_ClosedGroupControlMessage::_impl_.expirationtimer_) - - PROTOBUF_FIELD_OFFSET(DataMessage_ClosedGroupControlMessage, _impl_.encryptionkeypair_)>( - reinterpret_cast(&_impl_.encryptionkeypair_), - reinterpret_cast(&other->_impl_.encryptionkeypair_)); - swap(_impl_.type_, other->_impl_.type_); + PROTOBUF_FIELD_OFFSET(GroupUpdateMessage, _impl_.memberleftnotificationmessage_) + + sizeof(GroupUpdateMessage::_impl_.memberleftnotificationmessage_) + - PROTOBUF_FIELD_OFFSET(GroupUpdateMessage, _impl_.invitemessage_)>( + reinterpret_cast(&_impl_.invitemessage_), + reinterpret_cast(&other->_impl_.invitemessage_)); } -std::string DataMessage_ClosedGroupControlMessage::GetTypeName() const { - return "SessionProtos.DataMessage.ClosedGroupControlMessage"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[18]); } - // =================================================================== -class DataMessage::_Internal { +class GroupUpdateInviteMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_body(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_groupsessionid(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_flags(HasBits* has_bits) { - (*has_bits)[0] |= 256u; - } - static void set_has_expiretimer(HasBits* has_bits) { - (*has_bits)[0] |= 512u; - } - static void set_has_profilekey(HasBits* has_bits) { + static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_timestamp(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; + static void set_has_memberauthdata(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static const ::SessionProtos::DataMessage_Quote& quote(const DataMessage* msg); - static void set_has_quote(HasBits* has_bits) { + static void set_has_adminsignature(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static const ::SessionProtos::DataMessage_Reaction& reaction(const DataMessage* msg); - static void set_has_reaction(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static const ::SessionProtos::LokiProfile& profile(const DataMessage* msg); - static void set_has_profile(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation(const DataMessage* msg); - static void set_has_opengroupinvitation(HasBits* has_bits) { - (*has_bits)[0] |= 64u; - } - static const ::SessionProtos::DataMessage_ClosedGroupControlMessage& closedgroupcontrolmessage(const DataMessage* msg); - static void set_has_closedgroupcontrolmessage(HasBits* has_bits) { - (*has_bits)[0] |= 128u; - } - static void set_has_synctarget(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_blockscommunitymessagerequests(HasBits* has_bits) { - (*has_bits)[0] |= 2048u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000000f) ^ 0x0000000f) != 0; } }; -const ::SessionProtos::DataMessage_Quote& -DataMessage::_Internal::quote(const DataMessage* msg) { - return *msg->_impl_.quote_; -} -const ::SessionProtos::DataMessage_Reaction& -DataMessage::_Internal::reaction(const DataMessage* msg) { - return *msg->_impl_.reaction_; -} -const ::SessionProtos::LokiProfile& -DataMessage::_Internal::profile(const DataMessage* msg) { - return *msg->_impl_.profile_; -} -const ::SessionProtos::DataMessage_OpenGroupInvitation& -DataMessage::_Internal::opengroupinvitation(const DataMessage* msg) { - return *msg->_impl_.opengroupinvitation_; -} -const ::SessionProtos::DataMessage_ClosedGroupControlMessage& -DataMessage::_Internal::closedgroupcontrolmessage(const DataMessage* msg) { - return *msg->_impl_.closedgroupcontrolmessage_; -} -DataMessage::DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdateInviteMessage::GroupUpdateInviteMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateInviteMessage) } -DataMessage::DataMessage(const DataMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - DataMessage* const _this = this; (void)_this; +GroupUpdateInviteMessage::GroupUpdateInviteMessage(const GroupUpdateInviteMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdateInviteMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){from._impl_.attachments_} - , decltype(_impl_.preview_){from._impl_.preview_} - , decltype(_impl_.body_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.synctarget_){} - , decltype(_impl_.quote_){nullptr} - , decltype(_impl_.reaction_){nullptr} - , decltype(_impl_.profile_){nullptr} - , decltype(_impl_.opengroupinvitation_){nullptr} - , decltype(_impl_.closedgroupcontrolmessage_){nullptr} - , decltype(_impl_.flags_){} - , decltype(_impl_.expiretimer_){} - , decltype(_impl_.timestamp_){} - , decltype(_impl_.blockscommunitymessagerequests_){}}; + , decltype(_impl_.groupsessionid_){} + , decltype(_impl_.name_){} + , decltype(_impl_.memberauthdata_){} + , decltype(_impl_.adminsignature_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.body_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.groupsessionid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.body_.Set("", GetArenaForAllocation()); + _impl_.groupsessionid_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_body()) { - _this->_impl_.body_.Set(from._internal_body(), + if (from._internal_has_groupsessionid()) { + _this->_impl_.groupsessionid_.Set(from._internal_groupsessionid(), _this->GetArenaForAllocation()); } - _impl_.profilekey_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilekey()) { - _this->_impl_.profilekey_.Set(from._internal_profilekey(), + if (from._internal_has_name()) { + _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation()); } - _impl_.synctarget_.InitDefault(); + _impl_.memberauthdata_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.synctarget_.Set("", GetArenaForAllocation()); + _impl_.memberauthdata_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_synctarget()) { - _this->_impl_.synctarget_.Set(from._internal_synctarget(), + if (from._internal_has_memberauthdata()) { + _this->_impl_.memberauthdata_.Set(from._internal_memberauthdata(), _this->GetArenaForAllocation()); } - if (from._internal_has_quote()) { - _this->_impl_.quote_ = new ::SessionProtos::DataMessage_Quote(*from._impl_.quote_); - } - if (from._internal_has_reaction()) { - _this->_impl_.reaction_ = new ::SessionProtos::DataMessage_Reaction(*from._impl_.reaction_); - } - if (from._internal_has_profile()) { - _this->_impl_.profile_ = new ::SessionProtos::LokiProfile(*from._impl_.profile_); - } - if (from._internal_has_opengroupinvitation()) { - _this->_impl_.opengroupinvitation_ = new ::SessionProtos::DataMessage_OpenGroupInvitation(*from._impl_.opengroupinvitation_); - } - if (from._internal_has_closedgroupcontrolmessage()) { - _this->_impl_.closedgroupcontrolmessage_ = new ::SessionProtos::DataMessage_ClosedGroupControlMessage(*from._impl_.closedgroupcontrolmessage_); + _impl_.adminsignature_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.adminsignature_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_adminsignature()) { + _this->_impl_.adminsignature_.Set(from._internal_adminsignature(), + _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.flags_, &from._impl_.flags_, - static_cast(reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - - reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.blockscommunitymessagerequests_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.DataMessage) + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateInviteMessage) } -inline void DataMessage::SharedCtor( +inline void GroupUpdateInviteMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.attachments_){arena} - , decltype(_impl_.preview_){arena} - , decltype(_impl_.body_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.synctarget_){} - , decltype(_impl_.quote_){nullptr} - , decltype(_impl_.reaction_){nullptr} - , decltype(_impl_.profile_){nullptr} - , decltype(_impl_.opengroupinvitation_){nullptr} - , decltype(_impl_.closedgroupcontrolmessage_){nullptr} - , decltype(_impl_.flags_){0u} - , decltype(_impl_.expiretimer_){0u} - , decltype(_impl_.timestamp_){uint64_t{0u}} - , decltype(_impl_.blockscommunitymessagerequests_){false} + , decltype(_impl_.groupsessionid_){} + , decltype(_impl_.name_){} + , decltype(_impl_.memberauthdata_){} + , decltype(_impl_.adminsignature_){} }; - _impl_.body_.InitDefault(); + _impl_.groupsessionid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.body_.Set("", GetArenaForAllocation()); + _impl_.groupsessionid_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.InitDefault(); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.synctarget_.InitDefault(); + _impl_.memberauthdata_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.synctarget_.Set("", GetArenaForAllocation()); + _impl_.memberauthdata_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} + _impl_.adminsignature_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.adminsignature_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} -DataMessage::~DataMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.DataMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +GroupUpdateInviteMessage::~GroupUpdateInviteMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateInviteMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void DataMessage::SharedDtor() { +inline void GroupUpdateInviteMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.attachments_.~RepeatedPtrField(); - _impl_.preview_.~RepeatedPtrField(); - _impl_.body_.Destroy(); - _impl_.profilekey_.Destroy(); - _impl_.synctarget_.Destroy(); - if (this != internal_default_instance()) delete _impl_.quote_; - if (this != internal_default_instance()) delete _impl_.reaction_; - if (this != internal_default_instance()) delete _impl_.profile_; - if (this != internal_default_instance()) delete _impl_.opengroupinvitation_; - if (this != internal_default_instance()) delete _impl_.closedgroupcontrolmessage_; + _impl_.groupsessionid_.Destroy(); + _impl_.name_.Destroy(); + _impl_.memberauthdata_.Destroy(); + _impl_.adminsignature_.Destroy(); } -void DataMessage::SetCachedSize(int size) const { +void GroupUpdateInviteMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void DataMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.DataMessage) +void GroupUpdateInviteMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateInviteMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.attachments_.Clear(); - _impl_.preview_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _impl_.body_.ClearNonDefaultToEmpty(); + _impl_.groupsessionid_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.profilekey_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - _impl_.synctarget_.ClearNonDefaultToEmpty(); + _impl_.memberauthdata_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(_impl_.quote_ != nullptr); - _impl_.quote_->Clear(); - } - if (cached_has_bits & 0x00000010u) { - GOOGLE_DCHECK(_impl_.reaction_ != nullptr); - _impl_.reaction_->Clear(); - } - if (cached_has_bits & 0x00000020u) { - GOOGLE_DCHECK(_impl_.profile_ != nullptr); - _impl_.profile_->Clear(); - } - if (cached_has_bits & 0x00000040u) { - GOOGLE_DCHECK(_impl_.opengroupinvitation_ != nullptr); - _impl_.opengroupinvitation_->Clear(); - } - if (cached_has_bits & 0x00000080u) { - GOOGLE_DCHECK(_impl_.closedgroupcontrolmessage_ != nullptr); - _impl_.closedgroupcontrolmessage_->Clear(); + _impl_.adminsignature_.ClearNonDefaultToEmpty(); } } - if (cached_has_bits & 0x00000f00u) { - ::memset(&_impl_.flags_, 0, static_cast( - reinterpret_cast(&_impl_.blockscommunitymessagerequests_) - - reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.blockscommunitymessagerequests_)); - } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* GroupUpdateInviteMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional string body = 1; + // required string groupSessionId = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_body(); + auto str = _internal_mutable_groupsessionid(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateInviteMessage.groupSessionId"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // repeated .SessionProtos.AttachmentPointer attachments = 2; + // required string name = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_attachments(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else - goto handle_unusual; - continue; - // optional uint32 flags = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 expireTimer = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { - _Internal::set_has_expiretimer(&has_bits); - _impl_.expiretimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bytes profileKey = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - auto str = _internal_mutable_profilekey(); + auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateInviteMessage.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional uint64 timestamp = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { - _Internal::set_has_timestamp(&has_bits); - _impl_.timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.Quote quote = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { - ptr = ctx->ParseMessage(_internal_mutable_quote(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated .SessionProtos.DataMessage.Preview preview = 10; - case 10: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 82)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_preview(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr)); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { - ptr = ctx->ParseMessage(_internal_mutable_reaction(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.LokiProfile profile = 101; - case 101: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr = ctx->ParseMessage(_internal_mutable_profile(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - case 102: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr = ctx->ParseMessage(_internal_mutable_opengroupinvitation(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - case 104: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 66)) { - ptr = ctx->ParseMessage(_internal_mutable_closedgroupcontrolmessage(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string syncTarget = 105; - case 105: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 74)) { - auto str = _internal_mutable_synctarget(); + // required bytes memberAuthData = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_memberauthdata(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional bool blocksCommunityMessageRequests = 106; - case 106: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 80)) { - _Internal::set_has_blockscommunitymessagerequests(&has_bits); - _impl_.blockscommunitymessagerequests_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + // required bytes adminSignature = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_adminsignature(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; @@ -8159,7 +9014,7 @@ const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -8172,400 +9027,235 @@ const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c #undef CHK_ } -uint8_t* DataMessage::_InternalSerialize( +uint8_t* GroupUpdateInviteMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.DataMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateInviteMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional string body = 1; + // required string groupSessionId = 1; if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_groupsessionid().data(), static_cast(this->_internal_groupsessionid().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdateInviteMessage.groupSessionId"); target = stream->WriteStringMaybeAliased( - 1, this->_internal_body(), target); - } - - // repeated .SessionProtos.AttachmentPointer attachments = 2; - for (unsigned i = 0, - n = static_cast(this->_internal_attachments_size()); i < n; i++) { - const auto& repfield = this->_internal_attachments(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); - } - - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000100u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_flags(), target); - } - - // optional uint32 expireTimer = 5; - if (cached_has_bits & 0x00000200u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(5, this->_internal_expiretimer(), target); + 1, this->_internal_groupsessionid(), target); } - // optional bytes profileKey = 6; + // required string name = 2; if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 6, this->_internal_profilekey(), target); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdateInviteMessage.name"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_name(), target); } - // optional uint64 timestamp = 7; - if (cached_has_bits & 0x00000400u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(7, this->_internal_timestamp(), target); + // required bytes memberAuthData = 3; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_memberauthdata(), target); } - // optional .SessionProtos.DataMessage.Quote quote = 8; + // required bytes adminSignature = 4; if (cached_has_bits & 0x00000008u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(8, _Internal::quote(this), - _Internal::quote(this).GetCachedSize(), target, stream); - } - - // repeated .SessionProtos.DataMessage.Preview preview = 10; - for (unsigned i = 0, - n = static_cast(this->_internal_preview_size()); i < n; i++) { - const auto& repfield = this->_internal_preview(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(10, repfield, repfield.GetCachedSize(), target, stream); + target = stream->WriteBytesMaybeAliased( + 4, this->_internal_adminsignature(), target); } - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - if (cached_has_bits & 0x00000010u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(11, _Internal::reaction(this), - _Internal::reaction(this).GetCachedSize(), target, stream); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateInviteMessage) + return target; +} - // optional .SessionProtos.LokiProfile profile = 101; - if (cached_has_bits & 0x00000020u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(101, _Internal::profile(this), - _Internal::profile(this).GetCachedSize(), target, stream); - } +size_t GroupUpdateInviteMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.GroupUpdateInviteMessage) + size_t total_size = 0; - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - if (cached_has_bits & 0x00000040u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(102, _Internal::opengroupinvitation(this), - _Internal::opengroupinvitation(this).GetCachedSize(), target, stream); + if (_internal_has_groupsessionid()) { + // required string groupSessionId = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_groupsessionid()); } - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - if (cached_has_bits & 0x00000080u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(104, _Internal::closedgroupcontrolmessage(this), - _Internal::closedgroupcontrolmessage(this).GetCachedSize(), target, stream); + if (_internal_has_name()) { + // required string name = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } - // optional string syncTarget = 105; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteStringMaybeAliased( - 105, this->_internal_synctarget(), target); + if (_internal_has_memberauthdata()) { + // required bytes memberAuthData = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_memberauthdata()); } - // optional bool blocksCommunityMessageRequests = 106; - if (cached_has_bits & 0x00000800u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(106, this->_internal_blockscommunitymessagerequests(), target); + if (_internal_has_adminsignature()) { + // required bytes adminSignature = 4; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_adminsignature()); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage) - return target; + return total_size; } - -size_t DataMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.DataMessage) +size_t GroupUpdateInviteMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateInviteMessage) size_t total_size = 0; - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + if (((_impl_._has_bits_[0] & 0x0000000f) ^ 0x0000000f) == 0) { // All required fields are present. + // required string groupSessionId = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_groupsessionid()); - // repeated .SessionProtos.AttachmentPointer attachments = 2; - total_size += 1UL * this->_internal_attachments_size(); - for (const auto& msg : this->_impl_.attachments_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .SessionProtos.DataMessage.Preview preview = 10; - total_size += 1UL * this->_internal_preview_size(); - for (const auto& msg : this->_impl_.preview_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - // optional string body = 1; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_body()); - } - - // optional bytes profileKey = 6; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_profilekey()); - } - - // optional string syncTarget = 105; - if (cached_has_bits & 0x00000004u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_synctarget()); - } - - // optional .SessionProtos.DataMessage.Quote quote = 8; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.quote_); - } - - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.reaction_); - } - - // optional .SessionProtos.LokiProfile profile = 101; - if (cached_has_bits & 0x00000020u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.profile_); - } + // required string name = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - if (cached_has_bits & 0x00000040u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.opengroupinvitation_); - } + // required bytes memberAuthData = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_memberauthdata()); - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - if (cached_has_bits & 0x00000080u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.closedgroupcontrolmessage_); - } + // required bytes adminSignature = 4; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_adminsignature()); + } else { + total_size += RequiredFieldsByteSizeFallback(); } - if (cached_has_bits & 0x00000f00u) { - // optional uint32 flags = 4; - if (cached_has_bits & 0x00000100u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - } - - // optional uint32 expireTimer = 5; - if (cached_has_bits & 0x00000200u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expiretimer()); - } - - // optional uint64 timestamp = 7; - if (cached_has_bits & 0x00000400u) { - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); - } - - // optional bool blocksCommunityMessageRequests = 106; - if (cached_has_bits & 0x00000800u) { - total_size += 2 + 1; - } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void DataMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateInviteMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdateInviteMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateInviteMessage::GetClassData() const { return &_class_data_; } -void DataMessage::MergeFrom(const DataMessage& from) { - DataMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage) + +void GroupUpdateInviteMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateInviteMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.attachments_.MergeFrom(from._impl_.attachments_); - _this->_impl_.preview_.MergeFrom(from._impl_.preview_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_body(from._internal_body()); + _this->_internal_set_groupsessionid(from._internal_groupsessionid()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_profilekey(from._internal_profilekey()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_set_synctarget(from._internal_synctarget()); + _this->_internal_set_memberauthdata(from._internal_memberauthdata()); } if (cached_has_bits & 0x00000008u) { - _this->_internal_mutable_quote()->::SessionProtos::DataMessage_Quote::MergeFrom( - from._internal_quote()); - } - if (cached_has_bits & 0x00000010u) { - _this->_internal_mutable_reaction()->::SessionProtos::DataMessage_Reaction::MergeFrom( - from._internal_reaction()); - } - if (cached_has_bits & 0x00000020u) { - _this->_internal_mutable_profile()->::SessionProtos::LokiProfile::MergeFrom( - from._internal_profile()); - } - if (cached_has_bits & 0x00000040u) { - _this->_internal_mutable_opengroupinvitation()->::SessionProtos::DataMessage_OpenGroupInvitation::MergeFrom( - from._internal_opengroupinvitation()); - } - if (cached_has_bits & 0x00000080u) { - _this->_internal_mutable_closedgroupcontrolmessage()->::SessionProtos::DataMessage_ClosedGroupControlMessage::MergeFrom( - from._internal_closedgroupcontrolmessage()); - } - } - if (cached_has_bits & 0x00000f00u) { - if (cached_has_bits & 0x00000100u) { - _this->_impl_.flags_ = from._impl_.flags_; - } - if (cached_has_bits & 0x00000200u) { - _this->_impl_.expiretimer_ = from._impl_.expiretimer_; + _this->_internal_set_adminsignature(from._internal_adminsignature()); } - if (cached_has_bits & 0x00000400u) { - _this->_impl_.timestamp_ = from._impl_.timestamp_; - } - if (cached_has_bits & 0x00000800u) { - _this->_impl_.blockscommunitymessagerequests_ = from._impl_.blockscommunitymessagerequests_; - } - _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void DataMessage::CopyFrom(const DataMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.DataMessage) +void GroupUpdateInviteMessage::CopyFrom(const GroupUpdateInviteMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateInviteMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool DataMessage::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.attachments_)) - return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.preview_)) - return false; - if (_internal_has_quote()) { - if (!_impl_.quote_->IsInitialized()) return false; - } - if (_internal_has_reaction()) { - if (!_impl_.reaction_->IsInitialized()) return false; - } - if (_internal_has_opengroupinvitation()) { - if (!_impl_.opengroupinvitation_->IsInitialized()) return false; - } - if (_internal_has_closedgroupcontrolmessage()) { - if (!_impl_.closedgroupcontrolmessage_->IsInitialized()) return false; - } +bool GroupUpdateInviteMessage::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void DataMessage::InternalSwap(DataMessage* other) { +void GroupUpdateInviteMessage::InternalSwap(GroupUpdateInviteMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.attachments_.InternalSwap(&other->_impl_.attachments_); - _impl_.preview_.InternalSwap(&other->_impl_.preview_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.body_, lhs_arena, - &other->_impl_.body_, rhs_arena + &_impl_.groupsessionid_, lhs_arena, + &other->_impl_.groupsessionid_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilekey_, lhs_arena, - &other->_impl_.profilekey_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.synctarget_, lhs_arena, - &other->_impl_.synctarget_, rhs_arena + &_impl_.memberauthdata_, lhs_arena, + &other->_impl_.memberauthdata_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.adminsignature_, lhs_arena, + &other->_impl_.adminsignature_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.blockscommunitymessagerequests_) - + sizeof(DataMessage::_impl_.blockscommunitymessagerequests_) - - PROTOBUF_FIELD_OFFSET(DataMessage, _impl_.quote_)>( - reinterpret_cast(&_impl_.quote_), - reinterpret_cast(&other->_impl_.quote_)); } -std::string DataMessage::GetTypeName() const { - return "SessionProtos.DataMessage"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateInviteMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[19]); } - // =================================================================== -class ConfigurationMessage_ClosedGroup::_Internal { +class GroupUpdatePromoteMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_groupidentityseed(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static const ::SessionProtos::KeyPair& encryptionkeypair(const ConfigurationMessage_ClosedGroup* msg); - static void set_has_encryptionkeypair(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_expirationtimer(HasBits* has_bits) { - (*has_bits)[0] |= 8u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; } }; -const ::SessionProtos::KeyPair& -ConfigurationMessage_ClosedGroup::_Internal::encryptionkeypair(const ConfigurationMessage_ClosedGroup* msg) { - return *msg->_impl_.encryptionkeypair_; -} -ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdatePromoteMessage::GroupUpdatePromoteMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdatePromoteMessage) } -ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(const ConfigurationMessage_ClosedGroup& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage_ClosedGroup* const _this = this; (void)_this; +GroupUpdatePromoteMessage::GroupUpdatePromoteMessage(const GroupUpdatePromoteMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdatePromoteMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.members_){from._impl_.members_} - , decltype(_impl_.admins_){from._impl_.admins_} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){}}; + , decltype(_impl_.groupidentityseed_){} + , decltype(_impl_.name_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.groupidentityseed_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.groupidentityseed_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), + if (from._internal_has_groupidentityseed()) { + _this->_impl_.groupidentityseed_.Set(from._internal_groupidentityseed(), _this->GetArenaForAllocation()); } _impl_.name_.InitDefault(); @@ -8576,30 +9266,22 @@ ConfigurationMessage_ClosedGroup::ConfigurationMessage_ClosedGroup(const Configu _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation()); } - if (from._internal_has_encryptionkeypair()) { - _this->_impl_.encryptionkeypair_ = new ::SessionProtos::KeyPair(*from._impl_.encryptionkeypair_); - } - _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdatePromoteMessage) } -inline void ConfigurationMessage_ClosedGroup::SharedCtor( +inline void GroupUpdatePromoteMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.members_){arena} - , decltype(_impl_.admins_){arena} - , decltype(_impl_.publickey_){} + , decltype(_impl_.groupidentityseed_){} , decltype(_impl_.name_){} - , decltype(_impl_.encryptionkeypair_){nullptr} - , decltype(_impl_.expirationtimer_){0u} }; - _impl_.publickey_.InitDefault(); + _impl_.groupidentityseed_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); + _impl_.groupidentityseed_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -8607,121 +9289,69 @@ inline void ConfigurationMessage_ClosedGroup::SharedCtor( #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage_ClosedGroup::~ConfigurationMessage_ClosedGroup() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.ClosedGroup) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +GroupUpdatePromoteMessage::~GroupUpdatePromoteMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdatePromoteMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void ConfigurationMessage_ClosedGroup::SharedDtor() { +inline void GroupUpdatePromoteMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.members_.~RepeatedPtrField(); - _impl_.admins_.~RepeatedPtrField(); - _impl_.publickey_.Destroy(); + _impl_.groupidentityseed_.Destroy(); _impl_.name_.Destroy(); - if (this != internal_default_instance()) delete _impl_.encryptionkeypair_; } -void ConfigurationMessage_ClosedGroup::SetCachedSize(int size) const { +void GroupUpdatePromoteMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage_ClosedGroup::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.ClosedGroup) +void GroupUpdatePromoteMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdatePromoteMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.members_.Clear(); - _impl_.admins_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + _impl_.groupidentityseed_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { _impl_.name_.ClearNonDefaultToEmpty(); } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(_impl_.encryptionkeypair_ != nullptr); - _impl_.encryptionkeypair_->Clear(); - } } - _impl_.expirationtimer_ = 0u; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* GroupUpdatePromoteMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional bytes publicKey = 1; + // required bytes groupIdentitySeed = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); + auto str = _internal_mutable_groupidentityseed(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional string name = 2; + // required string name = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_encryptionkeypair(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // repeated bytes members = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_members(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else - goto handle_unusual; - continue; - // repeated bytes admins = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_admins(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); - } else - goto handle_unusual; - continue; - // optional uint32 expirationTimer = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { - _Internal::set_has_expirationtimer(&has_bits); - _impl_.expirationtimer_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdatePromoteMessage.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -8736,7 +9366,7 @@ const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, :: } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -8749,439 +9379,319 @@ const char* ConfigurationMessage_ClosedGroup::_InternalParse(const char* ptr, :: #undef CHK_ } -uint8_t* ConfigurationMessage_ClosedGroup::_InternalSerialize( +uint8_t* GroupUpdatePromoteMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdatePromoteMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // optional bytes publicKey = 1; + // required bytes groupIdentitySeed = 1; if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + 1, this->_internal_groupidentityseed(), target); } - // optional string name = 2; + // required string name = 2; if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdatePromoteMessage.name"); target = stream->WriteStringMaybeAliased( 2, this->_internal_name(), target); } - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; - if (cached_has_bits & 0x00000004u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::encryptionkeypair(this), - _Internal::encryptionkeypair(this).GetCachedSize(), target, stream); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdatePromoteMessage) + return target; +} - // repeated bytes members = 4; - for (int i = 0, n = this->_internal_members_size(); i < n; i++) { - const auto& s = this->_internal_members(i); - target = stream->WriteBytes(4, s, target); - } +size_t GroupUpdatePromoteMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.GroupUpdatePromoteMessage) + size_t total_size = 0; - // repeated bytes admins = 5; - for (int i = 0, n = this->_internal_admins_size(); i < n; i++) { - const auto& s = this->_internal_admins(i); - target = stream->WriteBytes(5, s, target); + if (_internal_has_groupidentityseed()) { + // required bytes groupIdentitySeed = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_groupidentityseed()); } - // optional uint32 expirationTimer = 6; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(6, this->_internal_expirationtimer(), target); + if (_internal_has_name()) { + // required string name = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.ClosedGroup) - return target; + return total_size; } - -size_t ConfigurationMessage_ClosedGroup::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.ClosedGroup) +size_t GroupUpdatePromoteMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdatePromoteMessage) size_t total_size = 0; - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required bytes groupIdentitySeed = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_groupidentityseed()); - // repeated bytes members = 4; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.members_.size()); - for (int i = 0, n = _impl_.members_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - _impl_.members_.Get(i)); - } + // required string name = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); - // repeated bytes admins = 5; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.admins_.size()); - for (int i = 0, n = _impl_.admins_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - _impl_.admins_.Get(i)); + } else { + total_size += RequiredFieldsByteSizeFallback(); } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional bytes publicKey = 1; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); - } - - // optional string name = 2; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - } - - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.encryptionkeypair_); - } - - // optional uint32 expirationTimer = 6; - if (cached_has_bits & 0x00000008u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void ConfigurationMessage_ClosedGroup::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdatePromoteMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdatePromoteMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdatePromoteMessage::GetClassData() const { return &_class_data_; } + -void ConfigurationMessage_ClosedGroup::MergeFrom(const ConfigurationMessage_ClosedGroup& from) { - ConfigurationMessage_ClosedGroup* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.ClosedGroup) +void GroupUpdatePromoteMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdatePromoteMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.members_.MergeFrom(from._impl_.members_); - _this->_impl_.admins_.MergeFrom(from._impl_.admins_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_groupidentityseed(from._internal_groupidentityseed()); } if (cached_has_bits & 0x00000002u) { _this->_internal_set_name(from._internal_name()); } - if (cached_has_bits & 0x00000004u) { - _this->_internal_mutable_encryptionkeypair()->::SessionProtos::KeyPair::MergeFrom( - from._internal_encryptionkeypair()); - } - if (cached_has_bits & 0x00000008u) { - _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; - } - _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void ConfigurationMessage_ClosedGroup::CopyFrom(const ConfigurationMessage_ClosedGroup& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.ClosedGroup) +void GroupUpdatePromoteMessage::CopyFrom(const GroupUpdatePromoteMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdatePromoteMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage_ClosedGroup::IsInitialized() const { - if (_internal_has_encryptionkeypair()) { - if (!_impl_.encryptionkeypair_->IsInitialized()) return false; - } +bool GroupUpdatePromoteMessage::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void ConfigurationMessage_ClosedGroup::InternalSwap(ConfigurationMessage_ClosedGroup* other) { +void GroupUpdatePromoteMessage::InternalSwap(GroupUpdatePromoteMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.members_.InternalSwap(&other->_impl_.members_); - _impl_.admins_.InternalSwap(&other->_impl_.admins_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena + &_impl_.groupidentityseed_, lhs_arena, + &other->_impl_.groupidentityseed_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &_impl_.name_, lhs_arena, &other->_impl_.name_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ClosedGroup, _impl_.expirationtimer_) - + sizeof(ConfigurationMessage_ClosedGroup::_impl_.expirationtimer_) - - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_ClosedGroup, _impl_.encryptionkeypair_)>( - reinterpret_cast(&_impl_.encryptionkeypair_), - reinterpret_cast(&other->_impl_.encryptionkeypair_)); } -std::string ConfigurationMessage_ClosedGroup::GetTypeName() const { - return "SessionProtos.ConfigurationMessage.ClosedGroup"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdatePromoteMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[20]); } - // =================================================================== -class ConfigurationMessage_Contact::_Internal { +class GroupUpdateInfoChangeMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_publickey(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_name(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_profilepicture(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_profilekey(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static void set_has_isapproved(HasBits* has_bits) { - (*has_bits)[0] |= 16u; + static void set_has_updatedname(HasBits* has_bits) { + (*has_bits)[0] |= 1u; } - static void set_has_isblocked(HasBits* has_bits) { - (*has_bits)[0] |= 32u; + static void set_has_updatedexpiration(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static void set_has_didapproveme(HasBits* has_bits) { - (*has_bits)[0] |= 64u; + static void set_has_adminsignature(HasBits* has_bits) { + (*has_bits)[0] |= 2u; } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + return ((has_bits[0] & 0x0000000a) ^ 0x0000000a) != 0; } }; -ConfigurationMessage_Contact::ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdateInfoChangeMessage::GroupUpdateInfoChangeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateInfoChangeMessage) } -ConfigurationMessage_Contact::ConfigurationMessage_Contact(const ConfigurationMessage_Contact& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage_Contact* const _this = this; (void)_this; +GroupUpdateInfoChangeMessage::GroupUpdateInfoChangeMessage(const GroupUpdateInfoChangeMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdateInfoChangeMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.profilepicture_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.isapproved_){} - , decltype(_impl_.isblocked_){} - , decltype(_impl_.didapproveme_){}}; + , decltype(_impl_.updatedname_){} + , decltype(_impl_.adminsignature_){} + , decltype(_impl_.updatedexpiration_){} + , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_publickey()) { - _this->_impl_.publickey_.Set(from._internal_publickey(), - _this->GetArenaForAllocation()); - } - _impl_.name_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_name()) { - _this->_impl_.name_.Set(from._internal_name(), - _this->GetArenaForAllocation()); - } - _impl_.profilepicture_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.updatedname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.updatedname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilepicture()) { - _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), + if (from._internal_has_updatedname()) { + _this->_impl_.updatedname_.Set(from._internal_updatedname(), _this->GetArenaForAllocation()); } - _impl_.profilekey_.InitDefault(); + _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.adminsignature_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilekey()) { - _this->_impl_.profilekey_.Set(from._internal_profilekey(), + if (from._internal_has_adminsignature()) { + _this->_impl_.adminsignature_.Set(from._internal_adminsignature(), _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.isapproved_, &from._impl_.isapproved_, - static_cast(reinterpret_cast(&_impl_.didapproveme_) - - reinterpret_cast(&_impl_.isapproved_)) + sizeof(_impl_.didapproveme_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage.Contact) + ::memcpy(&_impl_.updatedexpiration_, &from._impl_.updatedexpiration_, + static_cast(reinterpret_cast(&_impl_.type_) - + reinterpret_cast(&_impl_.updatedexpiration_)) + sizeof(_impl_.type_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateInfoChangeMessage) } -inline void ConfigurationMessage_Contact::SharedCtor( +inline void GroupUpdateInfoChangeMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.publickey_){} - , decltype(_impl_.name_){} - , decltype(_impl_.profilepicture_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.isapproved_){false} - , decltype(_impl_.isblocked_){false} - , decltype(_impl_.didapproveme_){false} + , decltype(_impl_.updatedname_){} + , decltype(_impl_.adminsignature_){} + , decltype(_impl_.updatedexpiration_){0u} + , decltype(_impl_.type_){1} }; - _impl_.publickey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.publickey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.name_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.InitDefault(); + _impl_.updatedname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + _impl_.updatedname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.InitDefault(); + _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.adminsignature_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage_Contact::~ConfigurationMessage_Contact() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage.Contact) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +GroupUpdateInfoChangeMessage::~GroupUpdateInfoChangeMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateInfoChangeMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void ConfigurationMessage_Contact::SharedDtor() { +inline void GroupUpdateInfoChangeMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.publickey_.Destroy(); - _impl_.name_.Destroy(); - _impl_.profilepicture_.Destroy(); - _impl_.profilekey_.Destroy(); + _impl_.updatedname_.Destroy(); + _impl_.adminsignature_.Destroy(); } -void ConfigurationMessage_Contact::SetCachedSize(int size) const { +void GroupUpdateInfoChangeMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage_Contact::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage.Contact) +void GroupUpdateInfoChangeMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateInfoChangeMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.publickey_.ClearNonDefaultToEmpty(); + _impl_.updatedname_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - _impl_.name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - _impl_.profilepicture_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000008u) { - _impl_.profilekey_.ClearNonDefaultToEmpty(); + _impl_.adminsignature_.ClearNonDefaultToEmpty(); } } - ::memset(&_impl_.isapproved_, 0, static_cast( - reinterpret_cast(&_impl_.didapproveme_) - - reinterpret_cast(&_impl_.isapproved_)) + sizeof(_impl_.didapproveme_)); + if (cached_has_bits & 0x0000000cu) { + _impl_.updatedexpiration_ = 0u; + _impl_.type_ = 1; + } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ConfigurationMessage_Contact::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* GroupUpdateInfoChangeMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required bytes publicKey = 1; + // required .SessionProtos.GroupUpdateInfoChangeMessage.Type type = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_publickey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::GroupUpdateInfoChangeMessage_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::GroupUpdateInfoChangeMessage_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // required string name = 2; + // optional string updatedName = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_name(); + auto str = _internal_mutable_updatedname(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateInfoChangeMessage.updatedName"); + #endif // !NDEBUG } else goto handle_unusual; continue; - // optional string profilePicture = 3; + // optional uint32 updatedExpiration = 3; case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_profilepicture(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { + _Internal::set_has_updatedexpiration(&has_bits); + _impl_.updatedexpiration_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional bytes profileKey = 4; + // required bytes adminSignature = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - auto str = _internal_mutable_profilekey(); + auto str = _internal_mutable_adminsignature(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // optional bool isApproved = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { - _Internal::set_has_isapproved(&has_bits); - _impl_.isapproved_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bool isBlocked = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { - _Internal::set_has_isblocked(&has_bits); - _impl_.isblocked_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bool didApproveMe = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 56)) { - _Internal::set_has_didapproveme(&has_bits); - _impl_.didapproveme_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -9193,7 +9703,7 @@ const char* ConfigurationMessage_Contact::_InternalParse(const char* ptr, ::_pbi } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -9206,97 +9716,82 @@ const char* ConfigurationMessage_Contact::_InternalParse(const char* ptr, ::_pbi #undef CHK_ } -uint8_t* ConfigurationMessage_Contact::_InternalSerialize( +uint8_t* GroupUpdateInfoChangeMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateInfoChangeMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required bytes publicKey = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_publickey(), target); + // required .SessionProtos.GroupUpdateInfoChangeMessage.Type type = 1; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - // required string name = 2; - if (cached_has_bits & 0x00000002u) { + // optional string updatedName = 2; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_updatedname().data(), static_cast(this->_internal_updatedname().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdateInfoChangeMessage.updatedName"); target = stream->WriteStringMaybeAliased( - 2, this->_internal_name(), target); + 2, this->_internal_updatedname(), target); } - // optional string profilePicture = 3; + // optional uint32 updatedExpiration = 3; if (cached_has_bits & 0x00000004u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_profilepicture(), target); - } - - // optional bytes profileKey = 4; - if (cached_has_bits & 0x00000008u) { - target = stream->WriteBytesMaybeAliased( - 4, this->_internal_profilekey(), target); - } - - // optional bool isApproved = 5; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_isapproved(), target); - } - - // optional bool isBlocked = 6; - if (cached_has_bits & 0x00000020u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(6, this->_internal_isblocked(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(3, this->_internal_updatedexpiration(), target); } - // optional bool didApproveMe = 7; - if (cached_has_bits & 0x00000040u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(7, this->_internal_didapproveme(), target); + // required bytes adminSignature = 4; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteBytesMaybeAliased( + 4, this->_internal_adminsignature(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateInfoChangeMessage) return target; } -size_t ConfigurationMessage_Contact::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ConfigurationMessage.Contact) +size_t GroupUpdateInfoChangeMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.GroupUpdateInfoChangeMessage) size_t total_size = 0; - if (_internal_has_publickey()) { - // required bytes publicKey = 1; + if (_internal_has_adminsignature()) { + // required bytes adminSignature = 4; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + this->_internal_adminsignature()); } - if (_internal_has_name()) { - // required string name = 2; + if (_internal_has_type()) { + // required .SessionProtos.GroupUpdateInfoChangeMessage.Type type = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } return total_size; } -size_t ConfigurationMessage_Contact::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage.Contact) +size_t GroupUpdateInfoChangeMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateInfoChangeMessage) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes publicKey = 1; + if (((_impl_._has_bits_[0] & 0x0000000a) ^ 0x0000000a) == 0) { // All required fields are present. + // required bytes adminSignature = 4; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_publickey()); + this->_internal_adminsignature()); - // required string name = 2; + // required .SessionProtos.GroupUpdateInfoChangeMessage.Type type = 1; total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } else { total_size += RequiredFieldsByteSizeFallback(); @@ -9305,373 +9800,254 @@ size_t ConfigurationMessage_Contact::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + // optional string updatedName = 2; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007cu) { - // optional string profilePicture = 3; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_profilepicture()); - } + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_updatedname()); + } - // optional bytes profileKey = 4; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_profilekey()); - } + // optional uint32 updatedExpiration = 3; + if (cached_has_bits & 0x00000004u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_updatedexpiration()); + } - // optional bool isApproved = 5; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + 1; - } + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} - // optional bool isBlocked = 6; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + 1; - } - - // optional bool didApproveMe = 7; - if (cached_has_bits & 0x00000040u) { - total_size += 1 + 1; - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateInfoChangeMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdateInfoChangeMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateInfoChangeMessage::GetClassData() const { return &_class_data_; } -void ConfigurationMessage_Contact::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} -void ConfigurationMessage_Contact::MergeFrom(const ConfigurationMessage_Contact& from) { - ConfigurationMessage_Contact* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage.Contact) +void GroupUpdateInfoChangeMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateInfoChangeMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_publickey(from._internal_publickey()); + _this->_internal_set_updatedname(from._internal_updatedname()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_name(from._internal_name()); + _this->_internal_set_adminsignature(from._internal_adminsignature()); } if (cached_has_bits & 0x00000004u) { - _this->_internal_set_profilepicture(from._internal_profilepicture()); + _this->_impl_.updatedexpiration_ = from._impl_.updatedexpiration_; } if (cached_has_bits & 0x00000008u) { - _this->_internal_set_profilekey(from._internal_profilekey()); - } - if (cached_has_bits & 0x00000010u) { - _this->_impl_.isapproved_ = from._impl_.isapproved_; - } - if (cached_has_bits & 0x00000020u) { - _this->_impl_.isblocked_ = from._impl_.isblocked_; - } - if (cached_has_bits & 0x00000040u) { - _this->_impl_.didapproveme_ = from._impl_.didapproveme_; + _this->_impl_.type_ = from._impl_.type_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void ConfigurationMessage_Contact::CopyFrom(const ConfigurationMessage_Contact& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage.Contact) +void GroupUpdateInfoChangeMessage::CopyFrom(const GroupUpdateInfoChangeMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateInfoChangeMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage_Contact::IsInitialized() const { +bool GroupUpdateInfoChangeMessage::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void ConfigurationMessage_Contact::InternalSwap(ConfigurationMessage_Contact* other) { +void GroupUpdateInfoChangeMessage::InternalSwap(GroupUpdateInfoChangeMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.publickey_, lhs_arena, - &other->_impl_.publickey_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.name_, lhs_arena, - &other->_impl_.name_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilepicture_, lhs_arena, - &other->_impl_.profilepicture_, rhs_arena + &_impl_.updatedname_, lhs_arena, + &other->_impl_.updatedname_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilekey_, lhs_arena, - &other->_impl_.profilekey_, rhs_arena + &_impl_.adminsignature_, lhs_arena, + &other->_impl_.adminsignature_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_Contact, _impl_.didapproveme_) - + sizeof(ConfigurationMessage_Contact::_impl_.didapproveme_) - - PROTOBUF_FIELD_OFFSET(ConfigurationMessage_Contact, _impl_.isapproved_)>( - reinterpret_cast(&_impl_.isapproved_), - reinterpret_cast(&other->_impl_.isapproved_)); + swap(_impl_.updatedexpiration_, other->_impl_.updatedexpiration_); + swap(_impl_.type_, other->_impl_.type_); } -std::string ConfigurationMessage_Contact::GetTypeName() const { - return "SessionProtos.ConfigurationMessage.Contact"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateInfoChangeMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[21]); } - // =================================================================== -class ConfigurationMessage::_Internal { +class GroupUpdateMemberChangeMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_displayname(HasBits* has_bits) { - (*has_bits)[0] |= 1u; + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } - static void set_has_profilepicture(HasBits* has_bits) { + static void set_has_historyshared(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static void set_has_profilekey(HasBits* has_bits) { - (*has_bits)[0] |= 4u; + static void set_has_adminsignature(HasBits* has_bits) { + (*has_bits)[0] |= 1u; } - static const ::SessionProtos::ProConfig& proconfig(const ConfigurationMessage* msg); - static void set_has_proconfig(HasBits* has_bits) { - (*has_bits)[0] |= 8u; + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; } }; -const ::SessionProtos::ProConfig& -ConfigurationMessage::_Internal::proconfig(const ConfigurationMessage* msg) { - return *msg->_impl_.proconfig_; -} -ConfigurationMessage::ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdateMemberChangeMessage::GroupUpdateMemberChangeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMemberChangeMessage) } -ConfigurationMessage::ConfigurationMessage(const ConfigurationMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ConfigurationMessage* const _this = this; (void)_this; +GroupUpdateMemberChangeMessage::GroupUpdateMemberChangeMessage(const GroupUpdateMemberChangeMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdateMemberChangeMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.closedgroups_){from._impl_.closedgroups_} - , decltype(_impl_.opengroups_){from._impl_.opengroups_} - , decltype(_impl_.contacts_){from._impl_.contacts_} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.proconfig_){nullptr}}; + , decltype(_impl_.membersessionids_){from._impl_.membersessionids_} + , decltype(_impl_.adminsignature_){} + , decltype(_impl_.historyshared_){} + , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.displayname_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_displayname()) { - _this->_impl_.displayname_.Set(from._internal_displayname(), - _this->GetArenaForAllocation()); - } - _impl_.profilepicture_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilepicture()) { - _this->_impl_.profilepicture_.Set(from._internal_profilepicture(), - _this->GetArenaForAllocation()); - } - _impl_.profilekey_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.adminsignature_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_profilekey()) { - _this->_impl_.profilekey_.Set(from._internal_profilekey(), + if (from._internal_has_adminsignature()) { + _this->_impl_.adminsignature_.Set(from._internal_adminsignature(), _this->GetArenaForAllocation()); } - if (from._internal_has_proconfig()) { - _this->_impl_.proconfig_ = new ::SessionProtos::ProConfig(*from._impl_.proconfig_); - } - // @@protoc_insertion_point(copy_constructor:SessionProtos.ConfigurationMessage) + ::memcpy(&_impl_.historyshared_, &from._impl_.historyshared_, + static_cast(reinterpret_cast(&_impl_.type_) - + reinterpret_cast(&_impl_.historyshared_)) + sizeof(_impl_.type_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateMemberChangeMessage) } -inline void ConfigurationMessage::SharedCtor( +inline void GroupUpdateMemberChangeMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.closedgroups_){arena} - , decltype(_impl_.opengroups_){arena} - , decltype(_impl_.contacts_){arena} - , decltype(_impl_.displayname_){} - , decltype(_impl_.profilepicture_){} - , decltype(_impl_.profilekey_){} - , decltype(_impl_.proconfig_){nullptr} + , decltype(_impl_.membersessionids_){arena} + , decltype(_impl_.adminsignature_){} + , decltype(_impl_.historyshared_){false} + , decltype(_impl_.type_){1} }; - _impl_.displayname_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.displayname_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.InitDefault(); + _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilepicture_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.profilekey_.Set("", GetArenaForAllocation()); + _impl_.adminsignature_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -ConfigurationMessage::~ConfigurationMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.ConfigurationMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +GroupUpdateMemberChangeMessage::~GroupUpdateMemberChangeMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateMemberChangeMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void ConfigurationMessage::SharedDtor() { +inline void GroupUpdateMemberChangeMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.closedgroups_.~RepeatedPtrField(); - _impl_.opengroups_.~RepeatedPtrField(); - _impl_.contacts_.~RepeatedPtrField(); - _impl_.displayname_.Destroy(); - _impl_.profilepicture_.Destroy(); - _impl_.profilekey_.Destroy(); - if (this != internal_default_instance()) delete _impl_.proconfig_; + _impl_.membersessionids_.~RepeatedPtrField(); + _impl_.adminsignature_.Destroy(); } -void ConfigurationMessage::SetCachedSize(int size) const { +void GroupUpdateMemberChangeMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void ConfigurationMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ConfigurationMessage) +void GroupUpdateMemberChangeMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateMemberChangeMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _impl_.closedgroups_.Clear(); - _impl_.opengroups_.Clear(); - _impl_.contacts_.Clear(); + _impl_.membersessionids_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { - _impl_.displayname_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.profilepicture_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - _impl_.profilekey_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(_impl_.proconfig_ != nullptr); - _impl_.proconfig_->Clear(); - } + if (cached_has_bits & 0x00000001u) { + _impl_.adminsignature_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000006u) { + _impl_.historyshared_ = false; + _impl_.type_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* GroupUpdateMemberChangeMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; + // required .SessionProtos.GroupUpdateMemberChangeMessage.Type type = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_closedgroups(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::SessionProtos::GroupUpdateMemberChangeMessage_Type_IsValid(val))) { + _internal_set_type(static_cast<::SessionProtos::GroupUpdateMemberChangeMessage_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } } else goto handle_unusual; continue; - // repeated string openGroups = 2; + // repeated string memberSessionIds = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { ptr -= 1; do { ptr += 1; - auto str = _internal_add_opengroups(); + auto str = _internal_add_membersessionids(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds"); + #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; - // optional string displayName = 3; + // optional bool historyShared = 3; case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_displayname(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { + _Internal::set_has_historyshared(&has_bits); + _impl_.historyshared_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional string profilePicture = 4; + // required bytes adminSignature = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { - auto str = _internal_mutable_profilepicture(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bytes profileKey = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_profilekey(); + auto str = _internal_mutable_adminsignature(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_contacts(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); - } else - goto handle_unusual; - continue; - // optional .SessionProtos.ProConfig proConfig = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - ptr = ctx->ParseMessage(_internal_mutable_proconfig(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -9683,7 +10059,7 @@ const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseC } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -9696,816 +10072,335 @@ const char* ConfigurationMessage::_InternalParse(const char* ptr, ::_pbi::ParseC #undef CHK_ } -uint8_t* ConfigurationMessage::_InternalSerialize( +uint8_t* GroupUpdateMemberChangeMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateMemberChangeMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; - for (unsigned i = 0, - n = static_cast(this->_internal_closedgroups_size()); i < n; i++) { - const auto& repfield = this->_internal_closedgroups(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); + cached_has_bits = _impl_._has_bits_[0]; + // required .SessionProtos.GroupUpdateMemberChangeMessage.Type type = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); } - // repeated string openGroups = 2; - for (int i = 0, n = this->_internal_opengroups_size(); i < n; i++) { - const auto& s = this->_internal_opengroups(i); + // repeated string memberSessionIds = 2; + for (int i = 0, n = this->_internal_membersessionids_size(); i < n; i++) { + const auto& s = this->_internal_membersessionids(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds"); target = stream->WriteString(2, s, target); } - cached_has_bits = _impl_._has_bits_[0]; - // optional string displayName = 3; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 3, this->_internal_displayname(), target); - } - - // optional string profilePicture = 4; + // optional bool historyShared = 3; if (cached_has_bits & 0x00000002u) { - target = stream->WriteStringMaybeAliased( - 4, this->_internal_profilepicture(), target); + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_historyshared(), target); } - // optional bytes profileKey = 5; - if (cached_has_bits & 0x00000004u) { + // required bytes adminSignature = 4; + if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 5, this->_internal_profilekey(), target); + 4, this->_internal_adminsignature(), target); } - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - for (unsigned i = 0, - n = static_cast(this->_internal_contacts_size()); i < n; i++) { - const auto& repfield = this->_internal_contacts(i); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateMemberChangeMessage) + return target; +} - // optional .SessionProtos.ProConfig proConfig = 7; - if (cached_has_bits & 0x00000008u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, _Internal::proconfig(this), - _Internal::proconfig(this).GetCachedSize(), target, stream); +size_t GroupUpdateMemberChangeMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.GroupUpdateMemberChangeMessage) + size_t total_size = 0; + + if (_internal_has_adminsignature()) { + // required bytes adminSignature = 4; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_adminsignature()); } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + if (_internal_has_type()) { + // required .SessionProtos.GroupUpdateMemberChangeMessage.Type type = 1; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ConfigurationMessage) - return target; -} -size_t ConfigurationMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ConfigurationMessage) + return total_size; +} +size_t GroupUpdateMemberChangeMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateMemberChangeMessage) size_t total_size = 0; + if (((_impl_._has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. + // required bytes adminSignature = 4; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_adminsignature()); + + // required .SessionProtos.GroupUpdateMemberChangeMessage.Type type = 1; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; - total_size += 1UL * this->_internal_closedgroups_size(); - for (const auto& msg : this->_impl_.closedgroups_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated string openGroups = 2; + // repeated string memberSessionIds = 2; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.opengroups_.size()); - for (int i = 0, n = _impl_.opengroups_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.membersessionids_.size()); + for (int i = 0, n = _impl_.membersessionids_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.opengroups_.Get(i)); - } - - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - total_size += 1UL * this->_internal_contacts_size(); - for (const auto& msg : this->_impl_.contacts_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + _impl_.membersessionids_.Get(i)); } + // optional bool historyShared = 3; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional string displayName = 3; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_displayname()); - } - - // optional string profilePicture = 4; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_profilepicture()); - } - - // optional bytes profileKey = 5; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_profilekey()); - } - - // optional .SessionProtos.ProConfig proConfig = 7; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proconfig_); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + if (cached_has_bits & 0x00000002u) { + total_size += 1 + 1; } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} -void ConfigurationMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void ConfigurationMessage::MergeFrom(const ConfigurationMessage& from) { - ConfigurationMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ConfigurationMessage) +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMemberChangeMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdateMemberChangeMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMemberChangeMessage::GetClassData() const { return &_class_data_; } + + +void GroupUpdateMemberChangeMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateMemberChangeMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - _this->_impl_.closedgroups_.MergeFrom(from._impl_.closedgroups_); - _this->_impl_.opengroups_.MergeFrom(from._impl_.opengroups_); - _this->_impl_.contacts_.MergeFrom(from._impl_.contacts_); + _this->_impl_.membersessionids_.MergeFrom(from._impl_.membersessionids_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_displayname(from._internal_displayname()); + _this->_internal_set_adminsignature(from._internal_adminsignature()); } if (cached_has_bits & 0x00000002u) { - _this->_internal_set_profilepicture(from._internal_profilepicture()); + _this->_impl_.historyshared_ = from._impl_.historyshared_; } if (cached_has_bits & 0x00000004u) { - _this->_internal_set_profilekey(from._internal_profilekey()); - } - if (cached_has_bits & 0x00000008u) { - _this->_internal_mutable_proconfig()->::SessionProtos::ProConfig::MergeFrom( - from._internal_proconfig()); + _this->_impl_.type_ = from._impl_.type_; } + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void ConfigurationMessage::CopyFrom(const ConfigurationMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ConfigurationMessage) +void GroupUpdateMemberChangeMessage::CopyFrom(const GroupUpdateMemberChangeMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateMemberChangeMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool ConfigurationMessage::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.closedgroups_)) - return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.contacts_)) - return false; - if (_internal_has_proconfig()) { - if (!_impl_.proconfig_->IsInitialized()) return false; - } +bool GroupUpdateMemberChangeMessage::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void ConfigurationMessage::InternalSwap(ConfigurationMessage* other) { +void GroupUpdateMemberChangeMessage::InternalSwap(GroupUpdateMemberChangeMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.closedgroups_.InternalSwap(&other->_impl_.closedgroups_); - _impl_.opengroups_.InternalSwap(&other->_impl_.opengroups_); - _impl_.contacts_.InternalSwap(&other->_impl_.contacts_); + _impl_.membersessionids_.InternalSwap(&other->_impl_.membersessionids_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.displayname_, lhs_arena, - &other->_impl_.displayname_, rhs_arena + &_impl_.adminsignature_, lhs_arena, + &other->_impl_.adminsignature_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilepicture_, lhs_arena, - &other->_impl_.profilepicture_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.profilekey_, lhs_arena, - &other->_impl_.profilekey_, rhs_arena - ); - swap(_impl_.proconfig_, other->_impl_.proconfig_); + swap(_impl_.historyshared_, other->_impl_.historyshared_); + swap(_impl_.type_, other->_impl_.type_); } -std::string ConfigurationMessage::GetTypeName() const { - return "SessionProtos.ConfigurationMessage"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMemberChangeMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[22]); } - // =================================================================== -class ReceiptMessage::_Internal { +class GroupUpdateMemberLeftMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } }; -ReceiptMessage::ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdateMemberLeftMessage::GroupUpdateMemberLeftMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { - SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ReceiptMessage) + : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) { + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMemberLeftMessage) } -ReceiptMessage::ReceiptMessage(const ReceiptMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - ReceiptMessage* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_._has_bits_){from._impl_._has_bits_} - , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.timestamp_){from._impl_.timestamp_} - , decltype(_impl_.type_){}}; - - _internal_metadata_.MergeFrom(from._internal_metadata_); - _this->_impl_.type_ = from._impl_.type_; - // @@protoc_insertion_point(copy_constructor:SessionProtos.ReceiptMessage) +GroupUpdateMemberLeftMessage::GroupUpdateMemberLeftMessage(const GroupUpdateMemberLeftMessage& from) + : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { + GroupUpdateMemberLeftMessage* const _this = this; (void)_this; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateMemberLeftMessage) } -inline void ReceiptMessage::SharedCtor( - ::_pb::Arena* arena, bool is_message_owned) { - (void)arena; - (void)is_message_owned; - new (&_impl_) Impl_{ - decltype(_impl_._has_bits_){} - , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.timestamp_){arena} - , decltype(_impl_.type_){0} - }; -} -ReceiptMessage::~ReceiptMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.ReceiptMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { - (void)arena; - return; - } - SharedDtor(); -} -inline void ReceiptMessage::SharedDtor() { - GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.timestamp_.~RepeatedField(); -} -void ReceiptMessage::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} -void ReceiptMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ReceiptMessage) - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMemberLeftMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMemberLeftMessage::GetClassData() const { return &_class_data_; } - _impl_.timestamp_.Clear(); - _impl_.type_ = 0; - _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); -} -const char* ReceiptMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // required .SessionProtos.ReceiptMessage.Type type = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::ReceiptMessage_Type_IsValid(val))) { - _internal_set_type(static_cast<::SessionProtos::ReceiptMessage_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } - } else - goto handle_unusual; - continue; - // repeated uint64 timestamp = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_timestamp(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<16>(ptr)); - } else if (static_cast(tag) == 18) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt64Parser(_internal_mutable_timestamp(), ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - _impl_._has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} -uint8_t* ReceiptMessage::_InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ReceiptMessage) - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.ReceiptMessage.Type type = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); - } - // repeated uint64 timestamp = 2; - for (int i = 0, n = this->_internal_timestamp_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_timestamp(i), target); - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ReceiptMessage) - return target; -} -size_t ReceiptMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ReceiptMessage) - size_t total_size = 0; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMemberLeftMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[23]); +} - // required .SessionProtos.ReceiptMessage.Type type = 1; - if (_internal_has_type()) { - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); - } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; +// =================================================================== - // repeated uint64 timestamp = 2; - { - size_t data_size = ::_pbi::WireFormatLite:: - UInt64Size(this->_impl_.timestamp_); - total_size += 1 * - ::_pbi::FromIntSize(this->_internal_timestamp_size()); - total_size += data_size; - } +class GroupUpdateMemberLeftNotificationMessage::_Internal { + public: +}; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; +GroupUpdateMemberLeftNotificationMessage::GroupUpdateMemberLeftNotificationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) { + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMemberLeftNotificationMessage) } - -void ReceiptMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); +GroupUpdateMemberLeftNotificationMessage::GroupUpdateMemberLeftNotificationMessage(const GroupUpdateMemberLeftNotificationMessage& from) + : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { + GroupUpdateMemberLeftNotificationMessage* const _this = this; (void)_this; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateMemberLeftNotificationMessage) } -void ReceiptMessage::MergeFrom(const ReceiptMessage& from) { - ReceiptMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ReceiptMessage) - GOOGLE_DCHECK_NE(&from, _this); - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - _this->_impl_.timestamp_.MergeFrom(from._impl_.timestamp_); - if (from._internal_has_type()) { - _this->_internal_set_type(from._internal_type()); - } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); -} -void ReceiptMessage::CopyFrom(const ReceiptMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ReceiptMessage) - if (&from == this) return; - Clear(); - MergeFrom(from); -} -bool ReceiptMessage::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - return true; -} -void ReceiptMessage::InternalSwap(ReceiptMessage* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.timestamp_.InternalSwap(&other->_impl_.timestamp_); - swap(_impl_.type_, other->_impl_.type_); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMemberLeftNotificationMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMemberLeftNotificationMessage::GetClassData() const { return &_class_data_; } + + + -std::string ReceiptMessage::GetTypeName() const { - return "SessionProtos.ReceiptMessage"; -} + +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMemberLeftNotificationMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[24]); +} + // =================================================================== -class AttachmentPointer::_Internal { +class GroupUpdateInviteResponseMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_id(HasBits* has_bits) { - (*has_bits)[0] |= 128u; - } - static void set_has_contenttype(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_isapproved(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_key(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_size(HasBits* has_bits) { - (*has_bits)[0] |= 256u; - } - static void set_has_thumbnail(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_digest(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static void set_has_filename(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static void set_has_flags(HasBits* has_bits) { - (*has_bits)[0] |= 512u; - } - static void set_has_width(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; - } - static void set_has_height(HasBits* has_bits) { - (*has_bits)[0] |= 2048u; - } - static void set_has_caption(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static void set_has_url(HasBits* has_bits) { - (*has_bits)[0] |= 64u; - } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000080) ^ 0x00000080) != 0; + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; } }; -AttachmentPointer::AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdateInviteResponseMessage::GroupUpdateInviteResponseMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.AttachmentPointer) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateInviteResponseMessage) } -AttachmentPointer::AttachmentPointer(const AttachmentPointer& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - AttachmentPointer* const _this = this; (void)_this; +GroupUpdateInviteResponseMessage::GroupUpdateInviteResponseMessage(const GroupUpdateInviteResponseMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdateInviteResponseMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.contenttype_){} - , decltype(_impl_.key_){} - , decltype(_impl_.thumbnail_){} - , decltype(_impl_.digest_){} - , decltype(_impl_.filename_){} - , decltype(_impl_.caption_){} - , decltype(_impl_.url_){} - , decltype(_impl_.id_){} - , decltype(_impl_.size_){} - , decltype(_impl_.flags_){} - , decltype(_impl_.width_){} - , decltype(_impl_.height_){}}; + , decltype(_impl_.isapproved_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.contenttype_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.contenttype_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_contenttype()) { - _this->_impl_.contenttype_.Set(from._internal_contenttype(), - _this->GetArenaForAllocation()); - } - _impl_.key_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.key_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_key()) { - _this->_impl_.key_.Set(from._internal_key(), - _this->GetArenaForAllocation()); - } - _impl_.thumbnail_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.thumbnail_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_thumbnail()) { - _this->_impl_.thumbnail_.Set(from._internal_thumbnail(), - _this->GetArenaForAllocation()); - } - _impl_.digest_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.digest_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_digest()) { - _this->_impl_.digest_.Set(from._internal_digest(), - _this->GetArenaForAllocation()); - } - _impl_.filename_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_filename()) { - _this->_impl_.filename_.Set(from._internal_filename(), - _this->GetArenaForAllocation()); - } - _impl_.caption_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.caption_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_caption()) { - _this->_impl_.caption_.Set(from._internal_caption(), - _this->GetArenaForAllocation()); - } - _impl_.url_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_url()) { - _this->_impl_.url_.Set(from._internal_url(), - _this->GetArenaForAllocation()); - } - ::memcpy(&_impl_.id_, &from._impl_.id_, - static_cast(reinterpret_cast(&_impl_.height_) - - reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.height_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.AttachmentPointer) + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.isapproved_ = from._impl_.isapproved_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateInviteResponseMessage) } -inline void AttachmentPointer::SharedCtor( +inline void GroupUpdateInviteResponseMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} - , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.contenttype_){} - , decltype(_impl_.key_){} - , decltype(_impl_.thumbnail_){} - , decltype(_impl_.digest_){} - , decltype(_impl_.filename_){} - , decltype(_impl_.caption_){} - , decltype(_impl_.url_){} - , decltype(_impl_.id_){uint64_t{0u}} - , decltype(_impl_.size_){0u} - , decltype(_impl_.flags_){0u} - , decltype(_impl_.width_){0u} - , decltype(_impl_.height_){0u} - }; - _impl_.contenttype_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.contenttype_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.key_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.key_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.thumbnail_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.thumbnail_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.digest_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.digest_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.filename_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.caption_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.caption_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.url_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -AttachmentPointer::~AttachmentPointer() { - // @@protoc_insertion_point(destructor:SessionProtos.AttachmentPointer) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void AttachmentPointer::SharedDtor() { - GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.contenttype_.Destroy(); - _impl_.key_.Destroy(); - _impl_.thumbnail_.Destroy(); - _impl_.digest_.Destroy(); - _impl_.filename_.Destroy(); - _impl_.caption_.Destroy(); - _impl_.url_.Destroy(); -} - -void AttachmentPointer::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void AttachmentPointer::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.AttachmentPointer) - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { - if (cached_has_bits & 0x00000001u) { - _impl_.contenttype_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - _impl_.key_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000004u) { - _impl_.thumbnail_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000008u) { - _impl_.digest_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000010u) { - _impl_.filename_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000020u) { - _impl_.caption_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000040u) { - _impl_.url_.ClearNonDefaultToEmpty(); - } - } - _impl_.id_ = uint64_t{0u}; - if (cached_has_bits & 0x00000f00u) { - ::memset(&_impl_.size_, 0, static_cast( - reinterpret_cast(&_impl_.height_) - - reinterpret_cast(&_impl_.size_)) + sizeof(_impl_.height_)); - } - _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // required fixed64 id = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 9)) { - _Internal::set_has_id(&has_bits); - _impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); - ptr += sizeof(uint64_t); - } else - goto handle_unusual; - continue; - // optional string contentType = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - auto str = _internal_mutable_contenttype(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bytes key = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_key(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 size = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _Internal::set_has_size(&has_bits); - _impl_.size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bytes thumbnail = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_thumbnail(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional bytes digest = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { - auto str = _internal_mutable_digest(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string fileName = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 58)) { - auto str = _internal_mutable_filename(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 flags = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 64)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 width = 9; - case 9: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 72)) { - _Internal::set_has_width(&has_bits); - _impl_.width_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional uint32 height = 10; - case 10: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 80)) { - _Internal::set_has_height(&has_bits); - _impl_.height_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string caption = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { - auto str = _internal_mutable_caption(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // optional string url = 101; - case 101: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { - auto str = _internal_mutable_url(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.isapproved_){false} + }; +} + +GroupUpdateInviteResponseMessage::~GroupUpdateInviteResponseMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateInviteResponseMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void GroupUpdateInviteResponseMessage::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} + +void GroupUpdateInviteResponseMessage::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void GroupUpdateInviteResponseMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateInviteResponseMessage) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.isapproved_ = false; + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* GroupUpdateInviteResponseMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required bool isApproved = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _Internal::set_has_isapproved(&has_bits); + _impl_.isapproved_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10521,7 +10416,7 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -10534,441 +10429,224 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont #undef CHK_ } -uint8_t* AttachmentPointer::_InternalSerialize( +uint8_t* GroupUpdateInviteResponseMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.AttachmentPointer) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateInviteResponseMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required fixed64 id = 1; - if (cached_has_bits & 0x00000080u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteFixed64ToArray(1, this->_internal_id(), target); - } - - // optional string contentType = 2; + // required bool isApproved = 1; if (cached_has_bits & 0x00000001u) { - target = stream->WriteStringMaybeAliased( - 2, this->_internal_contenttype(), target); - } - - // optional bytes key = 3; - if (cached_has_bits & 0x00000002u) { - target = stream->WriteBytesMaybeAliased( - 3, this->_internal_key(), target); - } - - // optional uint32 size = 4; - if (cached_has_bits & 0x00000100u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_size(), target); - } - - // optional bytes thumbnail = 5; - if (cached_has_bits & 0x00000004u) { - target = stream->WriteBytesMaybeAliased( - 5, this->_internal_thumbnail(), target); - } - - // optional bytes digest = 6; - if (cached_has_bits & 0x00000008u) { - target = stream->WriteBytesMaybeAliased( - 6, this->_internal_digest(), target); - } - - // optional string fileName = 7; - if (cached_has_bits & 0x00000010u) { - target = stream->WriteStringMaybeAliased( - 7, this->_internal_filename(), target); - } - - // optional uint32 flags = 8; - if (cached_has_bits & 0x00000200u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_flags(), target); - } - - // optional uint32 width = 9; - if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(9, this->_internal_width(), target); - } - - // optional uint32 height = 10; - if (cached_has_bits & 0x00000800u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(10, this->_internal_height(), target); - } - - // optional string caption = 11; - if (cached_has_bits & 0x00000020u) { - target = stream->WriteStringMaybeAliased( - 11, this->_internal_caption(), target); - } - - // optional string url = 101; - if (cached_has_bits & 0x00000040u) { - target = stream->WriteStringMaybeAliased( - 101, this->_internal_url(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.AttachmentPointer) - return target; -} - -size_t AttachmentPointer::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.AttachmentPointer) - size_t total_size = 0; - - // required fixed64 id = 1; - if (_internal_has_id()) { - total_size += 1 + 8; - } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { - // optional string contentType = 2; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_contenttype()); - } - - // optional bytes key = 3; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_key()); - } - - // optional bytes thumbnail = 5; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_thumbnail()); - } - - // optional bytes digest = 6; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_digest()); - } - - // optional string fileName = 7; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_filename()); - } - - // optional string caption = 11; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_caption()); - } - - // optional string url = 101; - if (cached_has_bits & 0x00000040u) { - total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_url()); - } - - } - if (cached_has_bits & 0x00000f00u) { - // optional uint32 size = 4; - if (cached_has_bits & 0x00000100u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_size()); - } - - // optional uint32 flags = 8; - if (cached_has_bits & 0x00000200u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - } - - // optional uint32 width = 9; - if (cached_has_bits & 0x00000400u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_width()); - } - - // optional uint32 height = 10; - if (cached_has_bits & 0x00000800u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_height()); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void AttachmentPointer::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} - -void AttachmentPointer::MergeFrom(const AttachmentPointer& from) { - AttachmentPointer* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.AttachmentPointer) - GOOGLE_DCHECK_NE(&from, _this); - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - if (cached_has_bits & 0x00000001u) { - _this->_internal_set_contenttype(from._internal_contenttype()); - } - if (cached_has_bits & 0x00000002u) { - _this->_internal_set_key(from._internal_key()); - } - if (cached_has_bits & 0x00000004u) { - _this->_internal_set_thumbnail(from._internal_thumbnail()); - } - if (cached_has_bits & 0x00000008u) { - _this->_internal_set_digest(from._internal_digest()); - } - if (cached_has_bits & 0x00000010u) { - _this->_internal_set_filename(from._internal_filename()); - } - if (cached_has_bits & 0x00000020u) { - _this->_internal_set_caption(from._internal_caption()); - } - if (cached_has_bits & 0x00000040u) { - _this->_internal_set_url(from._internal_url()); - } - if (cached_has_bits & 0x00000080u) { - _this->_impl_.id_ = from._impl_.id_; - } - _this->_impl_._has_bits_[0] |= cached_has_bits; - } - if (cached_has_bits & 0x00000f00u) { - if (cached_has_bits & 0x00000100u) { - _this->_impl_.size_ = from._impl_.size_; - } - if (cached_has_bits & 0x00000200u) { - _this->_impl_.flags_ = from._impl_.flags_; - } - if (cached_has_bits & 0x00000400u) { - _this->_impl_.width_ = from._impl_.width_; - } - if (cached_has_bits & 0x00000800u) { - _this->_impl_.height_ = from._impl_.height_; - } - _this->_impl_._has_bits_[0] |= cached_has_bits; + target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_isapproved(), target); } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateInviteResponseMessage) + return target; } -void AttachmentPointer::CopyFrom(const AttachmentPointer& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.AttachmentPointer) +size_t GroupUpdateInviteResponseMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateInviteResponseMessage) + size_t total_size = 0; + + // required bool isApproved = 1; + if (_internal_has_isapproved()) { + total_size += 1 + 1; + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateInviteResponseMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdateInviteResponseMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateInviteResponseMessage::GetClassData() const { return &_class_data_; } + + +void GroupUpdateInviteResponseMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateInviteResponseMessage) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_isapproved()) { + _this->_internal_set_isapproved(from._internal_isapproved()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void GroupUpdateInviteResponseMessage::CopyFrom(const GroupUpdateInviteResponseMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateInviteResponseMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool AttachmentPointer::IsInitialized() const { +bool GroupUpdateInviteResponseMessage::IsInitialized() const { if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } -void AttachmentPointer::InternalSwap(AttachmentPointer* other) { +void GroupUpdateInviteResponseMessage::InternalSwap(GroupUpdateInviteResponseMessage* other) { using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.contenttype_, lhs_arena, - &other->_impl_.contenttype_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.key_, lhs_arena, - &other->_impl_.key_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.thumbnail_, lhs_arena, - &other->_impl_.thumbnail_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.digest_, lhs_arena, - &other->_impl_.digest_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.filename_, lhs_arena, - &other->_impl_.filename_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.caption_, lhs_arena, - &other->_impl_.caption_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.url_, lhs_arena, - &other->_impl_.url_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(AttachmentPointer, _impl_.height_) - + sizeof(AttachmentPointer::_impl_.height_) - - PROTOBUF_FIELD_OFFSET(AttachmentPointer, _impl_.id_)>( - reinterpret_cast(&_impl_.id_), - reinterpret_cast(&other->_impl_.id_)); + swap(_impl_.isapproved_, other->_impl_.isapproved_); } -std::string AttachmentPointer::GetTypeName() const { - return "SessionProtos.AttachmentPointer"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateInviteResponseMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[25]); } - // =================================================================== -class SharedConfigMessage::_Internal { +class GroupUpdateDeleteMemberContentMessage::_Internal { public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_kind(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_seqno(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_data(HasBits* has_bits) { + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_adminsignature(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; - } }; -SharedConfigMessage::SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, +GroupUpdateDeleteMemberContentMessage::GroupUpdateDeleteMemberContentMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.SharedConfigMessage) + // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateDeleteMemberContentMessage) } -SharedConfigMessage::SharedConfigMessage(const SharedConfigMessage& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite() { - SharedConfigMessage* const _this = this; (void)_this; +GroupUpdateDeleteMemberContentMessage::GroupUpdateDeleteMemberContentMessage(const GroupUpdateDeleteMemberContentMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + GroupUpdateDeleteMemberContentMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.data_){} - , decltype(_impl_.seqno_){} - , decltype(_impl_.kind_){}}; + , decltype(_impl_.membersessionids_){from._impl_.membersessionids_} + , decltype(_impl_.messagehashes_){from._impl_.messagehashes_} + , decltype(_impl_.adminsignature_){}}; - _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.data_.InitDefault(); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.data_.Set("", GetArenaForAllocation()); + _impl_.adminsignature_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_data()) { - _this->_impl_.data_.Set(from._internal_data(), + if (from._internal_has_adminsignature()) { + _this->_impl_.adminsignature_.Set(from._internal_adminsignature(), _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.seqno_, &from._impl_.seqno_, - static_cast(reinterpret_cast(&_impl_.kind_) - - reinterpret_cast(&_impl_.seqno_)) + sizeof(_impl_.kind_)); - // @@protoc_insertion_point(copy_constructor:SessionProtos.SharedConfigMessage) + // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateDeleteMemberContentMessage) } -inline void SharedConfigMessage::SharedCtor( +inline void GroupUpdateDeleteMemberContentMessage::SharedCtor( ::_pb::Arena* arena, bool is_message_owned) { (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.data_){} - , decltype(_impl_.seqno_){int64_t{0}} - , decltype(_impl_.kind_){1} + , decltype(_impl_.membersessionids_){arena} + , decltype(_impl_.messagehashes_){arena} + , decltype(_impl_.adminsignature_){} }; - _impl_.data_.InitDefault(); + _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.data_.Set("", GetArenaForAllocation()); + _impl_.adminsignature_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -SharedConfigMessage::~SharedConfigMessage() { - // @@protoc_insertion_point(destructor:SessionProtos.SharedConfigMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena()) { +GroupUpdateDeleteMemberContentMessage::~GroupUpdateDeleteMemberContentMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateDeleteMemberContentMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } -inline void SharedConfigMessage::SharedDtor() { +inline void GroupUpdateDeleteMemberContentMessage::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.data_.Destroy(); + _impl_.membersessionids_.~RepeatedPtrField(); + _impl_.messagehashes_.~RepeatedPtrField(); + _impl_.adminsignature_.Destroy(); } -void SharedConfigMessage::SetCachedSize(int size) const { +void GroupUpdateDeleteMemberContentMessage::SetCachedSize(int size) const { _impl_._cached_size_.Set(size); } -void SharedConfigMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.SharedConfigMessage) +void GroupUpdateDeleteMemberContentMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateDeleteMemberContentMessage) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + _impl_.membersessionids_.Clear(); + _impl_.messagehashes_.Clear(); cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - _impl_.data_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000006u) { - _impl_.seqno_ = int64_t{0}; - _impl_.kind_ = 1; + _impl_.adminsignature_.ClearNonDefaultToEmpty(); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* SharedConfigMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +const char* GroupUpdateDeleteMemberContentMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.SharedConfigMessage.Kind kind = 1; + // repeated string memberSessionIds = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::SessionProtos::SharedConfigMessage_Kind_IsValid(val))) { - _internal_set_kind(static_cast<::SessionProtos::SharedConfigMessage_Kind>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_membersessionids(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds"); + #endif // !NDEBUG + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; - // required int64 seqno = 2; + // repeated string messageHashes = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - _Internal::set_has_seqno(&has_bits); - _impl_.seqno_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_messagehashes(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes"); + #endif // !NDEBUG + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; - // required bytes data = 3; + // optional bytes adminSignature = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_data(); + auto str = _internal_mutable_adminsignature(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else @@ -10985,7 +10663,7 @@ const char* SharedConfigMessage::_InternalParse(const char* ptr, ::_pbi::ParseCo } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields(), + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -10998,156 +10676,136 @@ const char* SharedConfigMessage::_InternalParse(const char* ptr, ::_pbi::ParseCo #undef CHK_ } -uint8_t* SharedConfigMessage::_InternalSerialize( +uint8_t* GroupUpdateDeleteMemberContentMessage::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.SharedConfigMessage) + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateDeleteMemberContentMessage) uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.SharedConfigMessage.Kind kind = 1; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 1, this->_internal_kind(), target); - } - - // required int64 seqno = 2; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_seqno(), target); + // repeated string memberSessionIds = 1; + for (int i = 0, n = this->_internal_membersessionids_size(); i < n; i++) { + const auto& s = this->_internal_membersessionids(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds"); + target = stream->WriteString(1, s, target); + } + + // repeated string messageHashes = 2; + for (int i = 0, n = this->_internal_messagehashes_size(); i < n; i++) { + const auto& s = this->_internal_messagehashes(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes"); + target = stream->WriteString(2, s, target); } - // required bytes data = 3; + cached_has_bits = _impl_._has_bits_[0]; + // optional bytes adminSignature = 3; if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( - 3, this->_internal_data(), target); + 3, this->_internal_adminsignature(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.SharedConfigMessage) + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateDeleteMemberContentMessage) return target; } -size_t SharedConfigMessage::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.SharedConfigMessage) +size_t GroupUpdateDeleteMemberContentMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateDeleteMemberContentMessage) size_t total_size = 0; - if (_internal_has_data()) { - // required bytes data = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_data()); - } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - if (_internal_has_seqno()) { - // required int64 seqno = 2; - total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seqno()); + // repeated string memberSessionIds = 1; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.membersessionids_.size()); + for (int i = 0, n = _impl_.membersessionids_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.membersessionids_.Get(i)); } - if (_internal_has_kind()) { - // required .SessionProtos.SharedConfigMessage.Kind kind = 1; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_kind()); + // repeated string messageHashes = 2; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.messagehashes_.size()); + for (int i = 0, n = _impl_.messagehashes_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.messagehashes_.Get(i)); } - return total_size; -} -size_t SharedConfigMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.SharedConfigMessage) - size_t total_size = 0; - - if (((_impl_._has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. - // required bytes data = 3; + // optional bytes adminSignature = 3; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_data()); - - // required int64 seqno = 2; - total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seqno()); - - // required .SessionProtos.SharedConfigMessage.Kind kind = 1; - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_kind()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); + this->_internal_adminsignature()); } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); - } - int cached_size = ::_pbi::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } -void SharedConfigMessage::CheckTypeAndMergeFrom( - const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::_pbi::DownCast( - &from)); -} +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateDeleteMemberContentMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + GroupUpdateDeleteMemberContentMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateDeleteMemberContentMessage::GetClassData() const { return &_class_data_; } -void SharedConfigMessage::MergeFrom(const SharedConfigMessage& from) { - SharedConfigMessage* const _this = this; - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.SharedConfigMessage) + +void GroupUpdateDeleteMemberContentMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateDeleteMemberContentMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { - if (cached_has_bits & 0x00000001u) { - _this->_internal_set_data(from._internal_data()); - } - if (cached_has_bits & 0x00000002u) { - _this->_impl_.seqno_ = from._impl_.seqno_; - } - if (cached_has_bits & 0x00000004u) { - _this->_impl_.kind_ = from._impl_.kind_; - } - _this->_impl_._has_bits_[0] |= cached_has_bits; + _this->_impl_.membersessionids_.MergeFrom(from._impl_.membersessionids_); + _this->_impl_.messagehashes_.MergeFrom(from._impl_.messagehashes_); + if (from._internal_has_adminsignature()) { + _this->_internal_set_adminsignature(from._internal_adminsignature()); } - _this->_internal_metadata_.MergeFrom(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } -void SharedConfigMessage::CopyFrom(const SharedConfigMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.SharedConfigMessage) +void GroupUpdateDeleteMemberContentMessage::CopyFrom(const GroupUpdateDeleteMemberContentMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateDeleteMemberContentMessage) if (&from == this) return; Clear(); MergeFrom(from); } -bool SharedConfigMessage::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; +bool GroupUpdateDeleteMemberContentMessage::IsInitialized() const { return true; } -void SharedConfigMessage::InternalSwap(SharedConfigMessage* other) { +void GroupUpdateDeleteMemberContentMessage::InternalSwap(GroupUpdateDeleteMemberContentMessage* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.membersessionids_.InternalSwap(&other->_impl_.membersessionids_); + _impl_.messagehashes_.InternalSwap(&other->_impl_.messagehashes_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.data_, lhs_arena, - &other->_impl_.data_, rhs_arena + &_impl_.adminsignature_, lhs_arena, + &other->_impl_.adminsignature_, rhs_arena ); - swap(_impl_.seqno_, other->_impl_.seqno_); - swap(_impl_.kind_, other->_impl_.kind_); } -std::string SharedConfigMessage::GetTypeName() const { - return "SessionProtos.SharedConfigMessage"; +::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateDeleteMemberContentMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[26]); } - // @@protoc_insertion_point(namespace_scope) } // namespace SessionProtos PROTOBUF_NAMESPACE_OPEN @@ -11167,18 +10825,6 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::MessageRequestResponse* Arena::CreateMaybeMessage< ::SessionProtos::MessageRequestResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::MessageRequestResponse >(arena); } -template<> PROTOBUF_NOINLINE ::SessionProtos::ProProof* -Arena::CreateMaybeMessage< ::SessionProtos::ProProof >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ProProof >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::ProConfig* -Arena::CreateMaybeMessage< ::SessionProtos::ProConfig >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ProConfig >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::ProMessageConfig* -Arena::CreateMaybeMessage< ::SessionProtos::ProMessageConfig >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ProMessageConfig >(arena); -} template<> PROTOBUF_NOINLINE ::SessionProtos::Content* Arena::CreateMaybeMessage< ::SessionProtos::Content >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::Content >(arena); @@ -11219,30 +10865,10 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::DataMessage_OpenGroupInvitation* Arena::CreateMaybeMessage< ::SessionProtos::DataMessage_OpenGroupInvitation >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::DataMessage_OpenGroupInvitation >(arena); } -template<> PROTOBUF_NOINLINE ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* -Arena::CreateMaybeMessage< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::DataMessage_ClosedGroupControlMessage* -Arena::CreateMaybeMessage< ::SessionProtos::DataMessage_ClosedGroupControlMessage >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::DataMessage_ClosedGroupControlMessage >(arena); -} template<> PROTOBUF_NOINLINE ::SessionProtos::DataMessage* Arena::CreateMaybeMessage< ::SessionProtos::DataMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::DataMessage >(arena); } -template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_ClosedGroup* -Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_ClosedGroup >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_ClosedGroup >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage_Contact* -Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage_Contact >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage_Contact >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::ConfigurationMessage* -Arena::CreateMaybeMessage< ::SessionProtos::ConfigurationMessage >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ConfigurationMessage >(arena); -} template<> PROTOBUF_NOINLINE ::SessionProtos::ReceiptMessage* Arena::CreateMaybeMessage< ::SessionProtos::ReceiptMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ReceiptMessage >(arena); @@ -11255,6 +10881,42 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::SharedConfigMessage* Arena::CreateMaybeMessage< ::SessionProtos::SharedConfigMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::SharedConfigMessage >(arena); } +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateInviteMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateInviteMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateInviteMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdatePromoteMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdatePromoteMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdatePromoteMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateInfoChangeMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateInfoChangeMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateInfoChangeMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateMemberChangeMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateMemberChangeMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateMemberChangeMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateMemberLeftMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateMemberLeftMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateMemberLeftMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateMemberLeftNotificationMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateMemberLeftNotificationMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateInviteResponseMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateInviteResponseMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateInviteResponseMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateDeleteMemberContentMessage* +Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateDeleteMemberContentMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateDeleteMemberContentMessage >(arena); +} PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index ee1c8b5e..faea8749 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -23,12 +23,15 @@ #include #include #include +#include #include #include -#include +#include +#include #include // IWYU pragma: export #include // IWYU pragma: export -#include +#include +#include // @@protoc_insertion_point(includes) #include #define PROTOBUF_INTERNAL_EXPORT_SessionProtos_2eproto @@ -42,6 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE struct TableStruct_SessionProtos_2eproto { static const uint32_t offsets[]; }; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_SessionProtos_2eproto; namespace SessionProtos { class AttachmentPointer; struct AttachmentPointerDefaultTypeInternal; @@ -49,15 +53,6 @@ extern AttachmentPointerDefaultTypeInternal _AttachmentPointer_default_instance_ class CallMessage; struct CallMessageDefaultTypeInternal; extern CallMessageDefaultTypeInternal _CallMessage_default_instance_; -class ConfigurationMessage; -struct ConfigurationMessageDefaultTypeInternal; -extern ConfigurationMessageDefaultTypeInternal _ConfigurationMessage_default_instance_; -class ConfigurationMessage_ClosedGroup; -struct ConfigurationMessage_ClosedGroupDefaultTypeInternal; -extern ConfigurationMessage_ClosedGroupDefaultTypeInternal _ConfigurationMessage_ClosedGroup_default_instance_; -class ConfigurationMessage_Contact; -struct ConfigurationMessage_ContactDefaultTypeInternal; -extern ConfigurationMessage_ContactDefaultTypeInternal _ConfigurationMessage_Contact_default_instance_; class Content; struct ContentDefaultTypeInternal; extern ContentDefaultTypeInternal _Content_default_instance_; @@ -67,12 +62,6 @@ extern DataExtractionNotificationDefaultTypeInternal _DataExtractionNotification class DataMessage; struct DataMessageDefaultTypeInternal; extern DataMessageDefaultTypeInternal _DataMessage_default_instance_; -class DataMessage_ClosedGroupControlMessage; -struct DataMessage_ClosedGroupControlMessageDefaultTypeInternal; -extern DataMessage_ClosedGroupControlMessageDefaultTypeInternal _DataMessage_ClosedGroupControlMessage_default_instance_; -class DataMessage_ClosedGroupControlMessage_KeyPairWrapper; -struct DataMessage_ClosedGroupControlMessage_KeyPairWrapperDefaultTypeInternal; -extern DataMessage_ClosedGroupControlMessage_KeyPairWrapperDefaultTypeInternal _DataMessage_ClosedGroupControlMessage_KeyPairWrapper_default_instance_; class DataMessage_OpenGroupInvitation; struct DataMessage_OpenGroupInvitationDefaultTypeInternal; extern DataMessage_OpenGroupInvitationDefaultTypeInternal _DataMessage_OpenGroupInvitation_default_instance_; @@ -91,6 +80,33 @@ extern DataMessage_ReactionDefaultTypeInternal _DataMessage_Reaction_default_ins class Envelope; struct EnvelopeDefaultTypeInternal; extern EnvelopeDefaultTypeInternal _Envelope_default_instance_; +class GroupUpdateDeleteMemberContentMessage; +struct GroupUpdateDeleteMemberContentMessageDefaultTypeInternal; +extern GroupUpdateDeleteMemberContentMessageDefaultTypeInternal _GroupUpdateDeleteMemberContentMessage_default_instance_; +class GroupUpdateInfoChangeMessage; +struct GroupUpdateInfoChangeMessageDefaultTypeInternal; +extern GroupUpdateInfoChangeMessageDefaultTypeInternal _GroupUpdateInfoChangeMessage_default_instance_; +class GroupUpdateInviteMessage; +struct GroupUpdateInviteMessageDefaultTypeInternal; +extern GroupUpdateInviteMessageDefaultTypeInternal _GroupUpdateInviteMessage_default_instance_; +class GroupUpdateInviteResponseMessage; +struct GroupUpdateInviteResponseMessageDefaultTypeInternal; +extern GroupUpdateInviteResponseMessageDefaultTypeInternal _GroupUpdateInviteResponseMessage_default_instance_; +class GroupUpdateMemberChangeMessage; +struct GroupUpdateMemberChangeMessageDefaultTypeInternal; +extern GroupUpdateMemberChangeMessageDefaultTypeInternal _GroupUpdateMemberChangeMessage_default_instance_; +class GroupUpdateMemberLeftMessage; +struct GroupUpdateMemberLeftMessageDefaultTypeInternal; +extern GroupUpdateMemberLeftMessageDefaultTypeInternal _GroupUpdateMemberLeftMessage_default_instance_; +class GroupUpdateMemberLeftNotificationMessage; +struct GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal; +extern GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal _GroupUpdateMemberLeftNotificationMessage_default_instance_; +class GroupUpdateMessage; +struct GroupUpdateMessageDefaultTypeInternal; +extern GroupUpdateMessageDefaultTypeInternal _GroupUpdateMessage_default_instance_; +class GroupUpdatePromoteMessage; +struct GroupUpdatePromoteMessageDefaultTypeInternal; +extern GroupUpdatePromoteMessageDefaultTypeInternal _GroupUpdatePromoteMessage_default_instance_; class KeyPair; struct KeyPairDefaultTypeInternal; extern KeyPairDefaultTypeInternal _KeyPair_default_instance_; @@ -100,15 +116,6 @@ extern LokiProfileDefaultTypeInternal _LokiProfile_default_instance_; class MessageRequestResponse; struct MessageRequestResponseDefaultTypeInternal; extern MessageRequestResponseDefaultTypeInternal _MessageRequestResponse_default_instance_; -class ProConfig; -struct ProConfigDefaultTypeInternal; -extern ProConfigDefaultTypeInternal _ProConfig_default_instance_; -class ProMessageConfig; -struct ProMessageConfigDefaultTypeInternal; -extern ProMessageConfigDefaultTypeInternal _ProMessageConfig_default_instance_; -class ProProof; -struct ProProofDefaultTypeInternal; -extern ProProofDefaultTypeInternal _ProProof_default_instance_; class ReceiptMessage; struct ReceiptMessageDefaultTypeInternal; extern ReceiptMessageDefaultTypeInternal _ReceiptMessage_default_instance_; @@ -125,26 +132,27 @@ extern UnsendRequestDefaultTypeInternal _UnsendRequest_default_instance_; PROTOBUF_NAMESPACE_OPEN template<> ::SessionProtos::AttachmentPointer* Arena::CreateMaybeMessage<::SessionProtos::AttachmentPointer>(Arena*); template<> ::SessionProtos::CallMessage* Arena::CreateMaybeMessage<::SessionProtos::CallMessage>(Arena*); -template<> ::SessionProtos::ConfigurationMessage* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage>(Arena*); -template<> ::SessionProtos::ConfigurationMessage_ClosedGroup* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_ClosedGroup>(Arena*); -template<> ::SessionProtos::ConfigurationMessage_Contact* Arena::CreateMaybeMessage<::SessionProtos::ConfigurationMessage_Contact>(Arena*); template<> ::SessionProtos::Content* Arena::CreateMaybeMessage<::SessionProtos::Content>(Arena*); template<> ::SessionProtos::DataExtractionNotification* Arena::CreateMaybeMessage<::SessionProtos::DataExtractionNotification>(Arena*); template<> ::SessionProtos::DataMessage* Arena::CreateMaybeMessage<::SessionProtos::DataMessage>(Arena*); -template<> ::SessionProtos::DataMessage_ClosedGroupControlMessage* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_ClosedGroupControlMessage>(Arena*); -template<> ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper>(Arena*); template<> ::SessionProtos::DataMessage_OpenGroupInvitation* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_OpenGroupInvitation>(Arena*); template<> ::SessionProtos::DataMessage_Preview* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_Preview>(Arena*); template<> ::SessionProtos::DataMessage_Quote* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_Quote>(Arena*); template<> ::SessionProtos::DataMessage_Quote_QuotedAttachment* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_Quote_QuotedAttachment>(Arena*); template<> ::SessionProtos::DataMessage_Reaction* Arena::CreateMaybeMessage<::SessionProtos::DataMessage_Reaction>(Arena*); template<> ::SessionProtos::Envelope* Arena::CreateMaybeMessage<::SessionProtos::Envelope>(Arena*); +template<> ::SessionProtos::GroupUpdateDeleteMemberContentMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateDeleteMemberContentMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateInfoChangeMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateInfoChangeMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateInviteMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateInviteMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateInviteResponseMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateInviteResponseMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateMemberChangeMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateMemberChangeMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateMemberLeftMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateMemberLeftMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateMemberLeftNotificationMessage>(Arena*); +template<> ::SessionProtos::GroupUpdateMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdateMessage>(Arena*); +template<> ::SessionProtos::GroupUpdatePromoteMessage* Arena::CreateMaybeMessage<::SessionProtos::GroupUpdatePromoteMessage>(Arena*); template<> ::SessionProtos::KeyPair* Arena::CreateMaybeMessage<::SessionProtos::KeyPair>(Arena*); template<> ::SessionProtos::LokiProfile* Arena::CreateMaybeMessage<::SessionProtos::LokiProfile>(Arena*); template<> ::SessionProtos::MessageRequestResponse* Arena::CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(Arena*); -template<> ::SessionProtos::ProConfig* Arena::CreateMaybeMessage<::SessionProtos::ProConfig>(Arena*); -template<> ::SessionProtos::ProMessageConfig* Arena::CreateMaybeMessage<::SessionProtos::ProMessageConfig>(Arena*); -template<> ::SessionProtos::ProProof* Arena::CreateMaybeMessage<::SessionProtos::ProProof>(Arena*); template<> ::SessionProtos::ReceiptMessage* Arena::CreateMaybeMessage<::SessionProtos::ReceiptMessage>(Arena*); template<> ::SessionProtos::SharedConfigMessage* Arena::CreateMaybeMessage<::SessionProtos::SharedConfigMessage>(Arena*); template<> ::SessionProtos::TypingMessage* Arena::CreateMaybeMessage<::SessionProtos::TypingMessage>(Arena*); @@ -161,16 +169,20 @@ constexpr Envelope_Type Envelope_Type_Type_MIN = Envelope_Type_SESSION_MESSAGE; constexpr Envelope_Type Envelope_Type_Type_MAX = Envelope_Type_CLOSED_GROUP_MESSAGE; constexpr int Envelope_Type_Type_ARRAYSIZE = Envelope_Type_Type_MAX + 1; -const std::string& Envelope_Type_Name(Envelope_Type value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Envelope_Type_descriptor(); template inline const std::string& Envelope_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function Envelope_Type_Name."); - return Envelope_Type_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + Envelope_Type_descriptor(), enum_t_value); +} +inline bool Envelope_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Envelope_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + Envelope_Type_descriptor(), name, value); } -bool Envelope_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Envelope_Type* value); enum TypingMessage_Action : int { TypingMessage_Action_STARTED = 0, TypingMessage_Action_STOPPED = 1 @@ -180,16 +192,44 @@ constexpr TypingMessage_Action TypingMessage_Action_Action_MIN = TypingMessage_A constexpr TypingMessage_Action TypingMessage_Action_Action_MAX = TypingMessage_Action_STOPPED; constexpr int TypingMessage_Action_Action_ARRAYSIZE = TypingMessage_Action_Action_MAX + 1; -const std::string& TypingMessage_Action_Name(TypingMessage_Action value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* TypingMessage_Action_descriptor(); template inline const std::string& TypingMessage_Action_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function TypingMessage_Action_Name."); - return TypingMessage_Action_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + TypingMessage_Action_descriptor(), enum_t_value); +} +inline bool TypingMessage_Action_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, TypingMessage_Action* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + TypingMessage_Action_descriptor(), name, value); +} +enum Content_ExpirationType : int { + Content_ExpirationType_UNKNOWN = 0, + Content_ExpirationType_DELETE_AFTER_READ = 1, + Content_ExpirationType_DELETE_AFTER_SEND = 2 +}; +bool Content_ExpirationType_IsValid(int value); +constexpr Content_ExpirationType Content_ExpirationType_ExpirationType_MIN = Content_ExpirationType_UNKNOWN; +constexpr Content_ExpirationType Content_ExpirationType_ExpirationType_MAX = Content_ExpirationType_DELETE_AFTER_SEND; +constexpr int Content_ExpirationType_ExpirationType_ARRAYSIZE = Content_ExpirationType_ExpirationType_MAX + 1; + +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Content_ExpirationType_descriptor(); +template +inline const std::string& Content_ExpirationType_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Content_ExpirationType_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + Content_ExpirationType_descriptor(), enum_t_value); +} +inline bool Content_ExpirationType_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Content_ExpirationType* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + Content_ExpirationType_descriptor(), name, value); } -bool TypingMessage_Action_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, TypingMessage_Action* value); enum CallMessage_Type : int { CallMessage_Type_PRE_OFFER = 6, CallMessage_Type_OFFER = 1, @@ -203,16 +243,20 @@ constexpr CallMessage_Type CallMessage_Type_Type_MIN = CallMessage_Type_OFFER; constexpr CallMessage_Type CallMessage_Type_Type_MAX = CallMessage_Type_PRE_OFFER; constexpr int CallMessage_Type_Type_ARRAYSIZE = CallMessage_Type_Type_MAX + 1; -const std::string& CallMessage_Type_Name(CallMessage_Type value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CallMessage_Type_descriptor(); template inline const std::string& CallMessage_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function CallMessage_Type_Name."); - return CallMessage_Type_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + CallMessage_Type_descriptor(), enum_t_value); +} +inline bool CallMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CallMessage_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + CallMessage_Type_descriptor(), name, value); } -bool CallMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CallMessage_Type* value); enum DataExtractionNotification_Type : int { DataExtractionNotification_Type_SCREENSHOT = 1, DataExtractionNotification_Type_MEDIA_SAVED = 2 @@ -222,16 +266,20 @@ constexpr DataExtractionNotification_Type DataExtractionNotification_Type_Type_M constexpr DataExtractionNotification_Type DataExtractionNotification_Type_Type_MAX = DataExtractionNotification_Type_MEDIA_SAVED; constexpr int DataExtractionNotification_Type_Type_ARRAYSIZE = DataExtractionNotification_Type_Type_MAX + 1; -const std::string& DataExtractionNotification_Type_Name(DataExtractionNotification_Type value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataExtractionNotification_Type_descriptor(); template inline const std::string& DataExtractionNotification_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataExtractionNotification_Type_Name."); - return DataExtractionNotification_Type_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + DataExtractionNotification_Type_descriptor(), enum_t_value); +} +inline bool DataExtractionNotification_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataExtractionNotification_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + DataExtractionNotification_Type_descriptor(), name, value); } -bool DataExtractionNotification_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataExtractionNotification_Type* value); enum DataMessage_Quote_QuotedAttachment_Flags : int { DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE = 1 }; @@ -240,16 +288,20 @@ constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttac constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX = DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE; constexpr int DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE = DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX + 1; -const std::string& DataMessage_Quote_QuotedAttachment_Flags_Name(DataMessage_Quote_QuotedAttachment_Flags value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Quote_QuotedAttachment_Flags_descriptor(); template inline const std::string& DataMessage_Quote_QuotedAttachment_Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataMessage_Quote_QuotedAttachment_Flags_Name."); - return DataMessage_Quote_QuotedAttachment_Flags_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + DataMessage_Quote_QuotedAttachment_Flags_descriptor(), enum_t_value); +} +inline bool DataMessage_Quote_QuotedAttachment_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Quote_QuotedAttachment_Flags* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + DataMessage_Quote_QuotedAttachment_Flags_descriptor(), name, value); } -bool DataMessage_Quote_QuotedAttachment_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Quote_QuotedAttachment_Flags* value); enum DataMessage_Reaction_Action : int { DataMessage_Reaction_Action_REACT = 0, DataMessage_Reaction_Action_REMOVE = 1 @@ -259,40 +311,20 @@ constexpr DataMessage_Reaction_Action DataMessage_Reaction_Action_Action_MIN = D constexpr DataMessage_Reaction_Action DataMessage_Reaction_Action_Action_MAX = DataMessage_Reaction_Action_REMOVE; constexpr int DataMessage_Reaction_Action_Action_ARRAYSIZE = DataMessage_Reaction_Action_Action_MAX + 1; -const std::string& DataMessage_Reaction_Action_Name(DataMessage_Reaction_Action value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Reaction_Action_descriptor(); template inline const std::string& DataMessage_Reaction_Action_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataMessage_Reaction_Action_Name."); - return DataMessage_Reaction_Action_Name(static_cast(enum_t_value)); -} -bool DataMessage_Reaction_Action_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Reaction_Action* value); -enum DataMessage_ClosedGroupControlMessage_Type : int { - DataMessage_ClosedGroupControlMessage_Type_NEW = 1, - DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR = 3, - DataMessage_ClosedGroupControlMessage_Type_NAME_CHANGE = 4, - DataMessage_ClosedGroupControlMessage_Type_MEMBERS_ADDED = 5, - DataMessage_ClosedGroupControlMessage_Type_MEMBERS_REMOVED = 6, - DataMessage_ClosedGroupControlMessage_Type_MEMBER_LEFT = 7, - DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR_REQUEST = 8 -}; -bool DataMessage_ClosedGroupControlMessage_Type_IsValid(int value); -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage_Type_Type_MIN = DataMessage_ClosedGroupControlMessage_Type_NEW; -constexpr DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage_Type_Type_MAX = DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR_REQUEST; -constexpr int DataMessage_ClosedGroupControlMessage_Type_Type_ARRAYSIZE = DataMessage_ClosedGroupControlMessage_Type_Type_MAX + 1; - -const std::string& DataMessage_ClosedGroupControlMessage_Type_Name(DataMessage_ClosedGroupControlMessage_Type value); -template -inline const std::string& DataMessage_ClosedGroupControlMessage_Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function DataMessage_ClosedGroupControlMessage_Type_Name."); - return DataMessage_ClosedGroupControlMessage_Type_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + DataMessage_Reaction_Action_descriptor(), enum_t_value); +} +inline bool DataMessage_Reaction_Action_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Reaction_Action* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + DataMessage_Reaction_Action_descriptor(), name, value); } -bool DataMessage_ClosedGroupControlMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_ClosedGroupControlMessage_Type* value); enum DataMessage_Flags : int { DataMessage_Flags_EXPIRATION_TIMER_UPDATE = 2 }; @@ -301,16 +333,20 @@ constexpr DataMessage_Flags DataMessage_Flags_Flags_MIN = DataMessage_Flags_EXPI constexpr DataMessage_Flags DataMessage_Flags_Flags_MAX = DataMessage_Flags_EXPIRATION_TIMER_UPDATE; constexpr int DataMessage_Flags_Flags_ARRAYSIZE = DataMessage_Flags_Flags_MAX + 1; -const std::string& DataMessage_Flags_Name(DataMessage_Flags value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Flags_descriptor(); template inline const std::string& DataMessage_Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataMessage_Flags_Name."); - return DataMessage_Flags_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + DataMessage_Flags_descriptor(), enum_t_value); +} +inline bool DataMessage_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Flags* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + DataMessage_Flags_descriptor(), name, value); } -bool DataMessage_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Flags* value); enum ReceiptMessage_Type : int { ReceiptMessage_Type_DELIVERY = 0, ReceiptMessage_Type_READ = 1 @@ -320,16 +356,20 @@ constexpr ReceiptMessage_Type ReceiptMessage_Type_Type_MIN = ReceiptMessage_Type constexpr ReceiptMessage_Type ReceiptMessage_Type_Type_MAX = ReceiptMessage_Type_READ; constexpr int ReceiptMessage_Type_Type_ARRAYSIZE = ReceiptMessage_Type_Type_MAX + 1; -const std::string& ReceiptMessage_Type_Name(ReceiptMessage_Type value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ReceiptMessage_Type_descriptor(); template inline const std::string& ReceiptMessage_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function ReceiptMessage_Type_Name."); - return ReceiptMessage_Type_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + ReceiptMessage_Type_descriptor(), enum_t_value); +} +inline bool ReceiptMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceiptMessage_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + ReceiptMessage_Type_descriptor(), name, value); } -bool ReceiptMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceiptMessage_Type* value); enum AttachmentPointer_Flags : int { AttachmentPointer_Flags_VOICE_MESSAGE = 1 }; @@ -338,16 +378,20 @@ constexpr AttachmentPointer_Flags AttachmentPointer_Flags_Flags_MIN = Attachment constexpr AttachmentPointer_Flags AttachmentPointer_Flags_Flags_MAX = AttachmentPointer_Flags_VOICE_MESSAGE; constexpr int AttachmentPointer_Flags_Flags_ARRAYSIZE = AttachmentPointer_Flags_Flags_MAX + 1; -const std::string& AttachmentPointer_Flags_Name(AttachmentPointer_Flags value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttachmentPointer_Flags_descriptor(); template inline const std::string& AttachmentPointer_Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function AttachmentPointer_Flags_Name."); - return AttachmentPointer_Flags_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + AttachmentPointer_Flags_descriptor(), enum_t_value); +} +inline bool AttachmentPointer_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttachmentPointer_Flags* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + AttachmentPointer_Flags_descriptor(), name, value); } -bool AttachmentPointer_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttachmentPointer_Flags* value); enum SharedConfigMessage_Kind : int { SharedConfigMessage_Kind_USER_PROFILE = 1, SharedConfigMessage_Kind_CONTACTS = 2, @@ -359,20 +403,72 @@ constexpr SharedConfigMessage_Kind SharedConfigMessage_Kind_Kind_MIN = SharedCon constexpr SharedConfigMessage_Kind SharedConfigMessage_Kind_Kind_MAX = SharedConfigMessage_Kind_USER_GROUPS; constexpr int SharedConfigMessage_Kind_Kind_ARRAYSIZE = SharedConfigMessage_Kind_Kind_MAX + 1; -const std::string& SharedConfigMessage_Kind_Name(SharedConfigMessage_Kind value); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* SharedConfigMessage_Kind_descriptor(); template inline const std::string& SharedConfigMessage_Kind_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function SharedConfigMessage_Kind_Name."); - return SharedConfigMessage_Kind_Name(static_cast(enum_t_value)); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + SharedConfigMessage_Kind_descriptor(), enum_t_value); +} +inline bool SharedConfigMessage_Kind_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SharedConfigMessage_Kind* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + SharedConfigMessage_Kind_descriptor(), name, value); +} +enum GroupUpdateInfoChangeMessage_Type : int { + GroupUpdateInfoChangeMessage_Type_NAME = 1, + GroupUpdateInfoChangeMessage_Type_AVATAR = 2, + GroupUpdateInfoChangeMessage_Type_DISAPPEARING_MESSAGES = 3 +}; +bool GroupUpdateInfoChangeMessage_Type_IsValid(int value); +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage_Type_Type_MIN = GroupUpdateInfoChangeMessage_Type_NAME; +constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage_Type_Type_MAX = GroupUpdateInfoChangeMessage_Type_DISAPPEARING_MESSAGES; +constexpr int GroupUpdateInfoChangeMessage_Type_Type_ARRAYSIZE = GroupUpdateInfoChangeMessage_Type_Type_MAX + 1; + +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateInfoChangeMessage_Type_descriptor(); +template +inline const std::string& GroupUpdateInfoChangeMessage_Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function GroupUpdateInfoChangeMessage_Type_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + GroupUpdateInfoChangeMessage_Type_descriptor(), enum_t_value); +} +inline bool GroupUpdateInfoChangeMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateInfoChangeMessage_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + GroupUpdateInfoChangeMessage_Type_descriptor(), name, value); +} +enum GroupUpdateMemberChangeMessage_Type : int { + GroupUpdateMemberChangeMessage_Type_ADDED = 1, + GroupUpdateMemberChangeMessage_Type_REMOVED = 2, + GroupUpdateMemberChangeMessage_Type_PROMOTED = 3 +}; +bool GroupUpdateMemberChangeMessage_Type_IsValid(int value); +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage_Type_Type_MIN = GroupUpdateMemberChangeMessage_Type_ADDED; +constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage_Type_Type_MAX = GroupUpdateMemberChangeMessage_Type_PROMOTED; +constexpr int GroupUpdateMemberChangeMessage_Type_Type_ARRAYSIZE = GroupUpdateMemberChangeMessage_Type_Type_MAX + 1; + +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateMemberChangeMessage_Type_descriptor(); +template +inline const std::string& GroupUpdateMemberChangeMessage_Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function GroupUpdateMemberChangeMessage_Type_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + GroupUpdateMemberChangeMessage_Type_descriptor(), enum_t_value); +} +inline bool GroupUpdateMemberChangeMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateMemberChangeMessage_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + GroupUpdateMemberChangeMessage_Type_descriptor(), name, value); } -bool SharedConfigMessage_Kind_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SharedConfigMessage_Kind* value); // =================================================================== class Envelope final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.Envelope) */ { + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.Envelope) */ { public: inline Envelope() : Envelope(nullptr) {} ~Envelope() override; @@ -402,13 +498,22 @@ class Envelope final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } static const Envelope& default_instance() { return *internal_default_instance(); } @@ -446,9 +551,15 @@ class Envelope final : Envelope* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Envelope& from); - void MergeFrom(const Envelope& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Envelope& from) { + Envelope::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -461,7 +572,7 @@ class Envelope final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const final; void InternalSwap(Envelope* other); private: @@ -474,7 +585,10 @@ class Envelope final : bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- @@ -492,6 +606,10 @@ class Envelope final : Envelope_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = Envelope_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return Envelope_Type_descriptor(); + } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -628,7 +746,7 @@ class Envelope final : // ------------------------------------------------------------------- class TypingMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.TypingMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.TypingMessage) */ { public: inline TypingMessage() : TypingMessage(nullptr) {} ~TypingMessage() override; @@ -658,13 +776,22 @@ class TypingMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } static const TypingMessage& default_instance() { return *internal_default_instance(); } @@ -702,9 +829,15 @@ class TypingMessage final : TypingMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const TypingMessage& from); - void MergeFrom(const TypingMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const TypingMessage& from) { + TypingMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -717,7 +850,7 @@ class TypingMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const final; void InternalSwap(TypingMessage* other); private: @@ -730,7 +863,10 @@ class TypingMessage final : bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- @@ -748,6 +884,10 @@ class TypingMessage final : TypingMessage_Action_Action_MAX; static constexpr int Action_ARRAYSIZE = TypingMessage_Action_Action_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Action_descriptor() { + return TypingMessage_Action_descriptor(); + } template static inline const std::string& Action_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -814,7 +954,7 @@ class TypingMessage final : // ------------------------------------------------------------------- class UnsendRequest final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.UnsendRequest) */ { + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.UnsendRequest) */ { public: inline UnsendRequest() : UnsendRequest(nullptr) {} ~UnsendRequest() override; @@ -844,13 +984,22 @@ class UnsendRequest final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } static const UnsendRequest& default_instance() { return *internal_default_instance(); } @@ -888,9 +1037,15 @@ class UnsendRequest final : UnsendRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const UnsendRequest& from); - void MergeFrom(const UnsendRequest& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const UnsendRequest& from) { + UnsendRequest::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -903,7 +1058,7 @@ class UnsendRequest final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const final; void InternalSwap(UnsendRequest* other); private: @@ -916,7 +1071,10 @@ class UnsendRequest final : bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- @@ -979,7 +1137,7 @@ class UnsendRequest final : // ------------------------------------------------------------------- class MessageRequestResponse final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.MessageRequestResponse) */ { + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.MessageRequestResponse) */ { public: inline MessageRequestResponse() : MessageRequestResponse(nullptr) {} ~MessageRequestResponse() override; @@ -1009,13 +1167,22 @@ class MessageRequestResponse final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } static const MessageRequestResponse& default_instance() { return *internal_default_instance(); } @@ -1053,9 +1220,15 @@ class MessageRequestResponse final : MessageRequestResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const MessageRequestResponse& from); - void MergeFrom(const MessageRequestResponse& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const MessageRequestResponse& from) { + MessageRequestResponse::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1068,7 +1241,7 @@ class MessageRequestResponse final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const final; void InternalSwap(MessageRequestResponse* other); private: @@ -1081,7 +1254,10 @@ class MessageRequestResponse final : bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- @@ -1160,24 +1336,24 @@ class MessageRequestResponse final : }; // ------------------------------------------------------------------- -class ProProof final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProProof) */ { +class Content final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.Content) */ { public: - inline ProProof() : ProProof(nullptr) {} - ~ProProof() override; - explicit PROTOBUF_CONSTEXPR ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline Content() : Content(nullptr) {} + ~Content() override; + explicit PROTOBUF_CONSTEXPR Content(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ProProof(const ProProof& from); - ProProof(ProProof&& from) noexcept - : ProProof() { + Content(const Content& from); + Content(Content&& from) noexcept + : Content() { *this = ::std::move(from); } - inline ProProof& operator=(const ProProof& from) { + inline Content& operator=(const Content& from) { CopyFrom(from); return *this; } - inline ProProof& operator=(ProProof&& from) noexcept { + inline Content& operator=(Content&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1191,27 +1367,36 @@ class ProProof final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ProProof& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Content& default_instance() { return *internal_default_instance(); } - static inline const ProProof* internal_default_instance() { - return reinterpret_cast( - &_ProProof_default_instance_); + static inline const Content* internal_default_instance() { + return reinterpret_cast( + &_Content_default_instance_); } static constexpr int kIndexInFileMessages = 4; - friend void swap(ProProof& a, ProProof& b) { + friend void swap(Content& a, Content& b) { a.Swap(&b); } - inline void Swap(ProProof* other) { + inline void Swap(Content* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1224,7 +1409,7 @@ class ProProof final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ProProof* other) { + void UnsafeArenaSwap(Content* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1232,12 +1417,18 @@ class ProProof final : // implements Message ---------------------------------------------- - ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + Content* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Content& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Content& from) { + Content::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ProProof& from); - void MergeFrom(const ProProof& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1250,154 +1441,301 @@ class ProProof final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ProProof* other); + void SetCachedSize(int size) const final; + void InternalSwap(Content* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ProProof"; + return "SessionProtos.Content"; } protected: - explicit ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef Content_ExpirationType ExpirationType; + static constexpr ExpirationType UNKNOWN = + Content_ExpirationType_UNKNOWN; + static constexpr ExpirationType DELETE_AFTER_READ = + Content_ExpirationType_DELETE_AFTER_READ; + static constexpr ExpirationType DELETE_AFTER_SEND = + Content_ExpirationType_DELETE_AFTER_SEND; + static inline bool ExpirationType_IsValid(int value) { + return Content_ExpirationType_IsValid(value); + } + static constexpr ExpirationType ExpirationType_MIN = + Content_ExpirationType_ExpirationType_MIN; + static constexpr ExpirationType ExpirationType_MAX = + Content_ExpirationType_ExpirationType_MAX; + static constexpr int ExpirationType_ARRAYSIZE = + Content_ExpirationType_ExpirationType_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + ExpirationType_descriptor() { + return Content_ExpirationType_descriptor(); + } + template + static inline const std::string& ExpirationType_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function ExpirationType_Name."); + return Content_ExpirationType_Name(enum_t_value); + } + static inline bool ExpirationType_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + ExpirationType* value) { + return Content_ExpirationType_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kGenIndexHashFieldNumber = 2, - kRotatingPublicKeyFieldNumber = 3, - kSigFieldNumber = 5, - kExpiryUnixTsFieldNumber = 4, - kVersionFieldNumber = 1, + kDataMessageFieldNumber = 1, + kCallMessageFieldNumber = 3, + kReceiptMessageFieldNumber = 5, + kTypingMessageFieldNumber = 6, + kDataExtractionNotificationFieldNumber = 8, + kUnsendRequestFieldNumber = 9, + kMessageRequestResponseFieldNumber = 10, + kSharedConfigMessageFieldNumber = 11, + kExpirationTypeFieldNumber = 12, + kExpirationTimerFieldNumber = 13, + kSigTimestampFieldNumber = 15, }; - // required bytes genIndexHash = 2; - bool has_genindexhash() const; + // optional .SessionProtos.DataMessage dataMessage = 1; + bool has_datamessage() const; private: - bool _internal_has_genindexhash() const; + bool _internal_has_datamessage() const; public: - void clear_genindexhash(); - const std::string& genindexhash() const; - template - void set_genindexhash(ArgT0&& arg0, ArgT... args); - std::string* mutable_genindexhash(); - PROTOBUF_NODISCARD std::string* release_genindexhash(); - void set_allocated_genindexhash(std::string* genindexhash); + void clear_datamessage(); + const ::SessionProtos::DataMessage& datamessage() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage* release_datamessage(); + ::SessionProtos::DataMessage* mutable_datamessage(); + void set_allocated_datamessage(::SessionProtos::DataMessage* datamessage); private: - const std::string& _internal_genindexhash() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); - std::string* _internal_mutable_genindexhash(); + const ::SessionProtos::DataMessage& _internal_datamessage() const; + ::SessionProtos::DataMessage* _internal_mutable_datamessage(); public: + void unsafe_arena_set_allocated_datamessage( + ::SessionProtos::DataMessage* datamessage); + ::SessionProtos::DataMessage* unsafe_arena_release_datamessage(); - // required bytes rotatingPublicKey = 3; - bool has_rotatingpublickey() const; + // optional .SessionProtos.CallMessage callMessage = 3; + bool has_callmessage() const; private: - bool _internal_has_rotatingpublickey() const; + bool _internal_has_callmessage() const; public: - void clear_rotatingpublickey(); - const std::string& rotatingpublickey() const; - template - void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_rotatingpublickey(); - PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); - void set_allocated_rotatingpublickey(std::string* rotatingpublickey); + void clear_callmessage(); + const ::SessionProtos::CallMessage& callmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::CallMessage* release_callmessage(); + ::SessionProtos::CallMessage* mutable_callmessage(); + void set_allocated_callmessage(::SessionProtos::CallMessage* callmessage); + private: + const ::SessionProtos::CallMessage& _internal_callmessage() const; + ::SessionProtos::CallMessage* _internal_mutable_callmessage(); + public: + void unsafe_arena_set_allocated_callmessage( + ::SessionProtos::CallMessage* callmessage); + ::SessionProtos::CallMessage* unsafe_arena_release_callmessage(); + + // optional .SessionProtos.ReceiptMessage receiptMessage = 5; + bool has_receiptmessage() const; + private: + bool _internal_has_receiptmessage() const; + public: + void clear_receiptmessage(); + const ::SessionProtos::ReceiptMessage& receiptmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::ReceiptMessage* release_receiptmessage(); + ::SessionProtos::ReceiptMessage* mutable_receiptmessage(); + void set_allocated_receiptmessage(::SessionProtos::ReceiptMessage* receiptmessage); private: - const std::string& _internal_rotatingpublickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); - std::string* _internal_mutable_rotatingpublickey(); + const ::SessionProtos::ReceiptMessage& _internal_receiptmessage() const; + ::SessionProtos::ReceiptMessage* _internal_mutable_receiptmessage(); public: + void unsafe_arena_set_allocated_receiptmessage( + ::SessionProtos::ReceiptMessage* receiptmessage); + ::SessionProtos::ReceiptMessage* unsafe_arena_release_receiptmessage(); - // required bytes sig = 5; - bool has_sig() const; + // optional .SessionProtos.TypingMessage typingMessage = 6; + bool has_typingmessage() const; private: - bool _internal_has_sig() const; + bool _internal_has_typingmessage() const; public: - void clear_sig(); - const std::string& sig() const; - template - void set_sig(ArgT0&& arg0, ArgT... args); - std::string* mutable_sig(); - PROTOBUF_NODISCARD std::string* release_sig(); - void set_allocated_sig(std::string* sig); + void clear_typingmessage(); + const ::SessionProtos::TypingMessage& typingmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::TypingMessage* release_typingmessage(); + ::SessionProtos::TypingMessage* mutable_typingmessage(); + void set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage); + private: + const ::SessionProtos::TypingMessage& _internal_typingmessage() const; + ::SessionProtos::TypingMessage* _internal_mutable_typingmessage(); + public: + void unsafe_arena_set_allocated_typingmessage( + ::SessionProtos::TypingMessage* typingmessage); + ::SessionProtos::TypingMessage* unsafe_arena_release_typingmessage(); + + // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; + bool has_dataextractionnotification() const; + private: + bool _internal_has_dataextractionnotification() const; + public: + void clear_dataextractionnotification(); + const ::SessionProtos::DataExtractionNotification& dataextractionnotification() const; + PROTOBUF_NODISCARD ::SessionProtos::DataExtractionNotification* release_dataextractionnotification(); + ::SessionProtos::DataExtractionNotification* mutable_dataextractionnotification(); + void set_allocated_dataextractionnotification(::SessionProtos::DataExtractionNotification* dataextractionnotification); + private: + const ::SessionProtos::DataExtractionNotification& _internal_dataextractionnotification() const; + ::SessionProtos::DataExtractionNotification* _internal_mutable_dataextractionnotification(); + public: + void unsafe_arena_set_allocated_dataextractionnotification( + ::SessionProtos::DataExtractionNotification* dataextractionnotification); + ::SessionProtos::DataExtractionNotification* unsafe_arena_release_dataextractionnotification(); + + // optional .SessionProtos.UnsendRequest unsendRequest = 9; + bool has_unsendrequest() const; + private: + bool _internal_has_unsendrequest() const; + public: + void clear_unsendrequest(); + const ::SessionProtos::UnsendRequest& unsendrequest() const; + PROTOBUF_NODISCARD ::SessionProtos::UnsendRequest* release_unsendrequest(); + ::SessionProtos::UnsendRequest* mutable_unsendrequest(); + void set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest); + private: + const ::SessionProtos::UnsendRequest& _internal_unsendrequest() const; + ::SessionProtos::UnsendRequest* _internal_mutable_unsendrequest(); + public: + void unsafe_arena_set_allocated_unsendrequest( + ::SessionProtos::UnsendRequest* unsendrequest); + ::SessionProtos::UnsendRequest* unsafe_arena_release_unsendrequest(); + + // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; + bool has_messagerequestresponse() const; + private: + bool _internal_has_messagerequestresponse() const; + public: + void clear_messagerequestresponse(); + const ::SessionProtos::MessageRequestResponse& messagerequestresponse() const; + PROTOBUF_NODISCARD ::SessionProtos::MessageRequestResponse* release_messagerequestresponse(); + ::SessionProtos::MessageRequestResponse* mutable_messagerequestresponse(); + void set_allocated_messagerequestresponse(::SessionProtos::MessageRequestResponse* messagerequestresponse); + private: + const ::SessionProtos::MessageRequestResponse& _internal_messagerequestresponse() const; + ::SessionProtos::MessageRequestResponse* _internal_mutable_messagerequestresponse(); + public: + void unsafe_arena_set_allocated_messagerequestresponse( + ::SessionProtos::MessageRequestResponse* messagerequestresponse); + ::SessionProtos::MessageRequestResponse* unsafe_arena_release_messagerequestresponse(); + + // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; + bool has_sharedconfigmessage() const; + private: + bool _internal_has_sharedconfigmessage() const; + public: + void clear_sharedconfigmessage(); + const ::SessionProtos::SharedConfigMessage& sharedconfigmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::SharedConfigMessage* release_sharedconfigmessage(); + ::SessionProtos::SharedConfigMessage* mutable_sharedconfigmessage(); + void set_allocated_sharedconfigmessage(::SessionProtos::SharedConfigMessage* sharedconfigmessage); + private: + const ::SessionProtos::SharedConfigMessage& _internal_sharedconfigmessage() const; + ::SessionProtos::SharedConfigMessage* _internal_mutable_sharedconfigmessage(); + public: + void unsafe_arena_set_allocated_sharedconfigmessage( + ::SessionProtos::SharedConfigMessage* sharedconfigmessage); + ::SessionProtos::SharedConfigMessage* unsafe_arena_release_sharedconfigmessage(); + + // optional .SessionProtos.Content.ExpirationType expirationType = 12; + bool has_expirationtype() const; + private: + bool _internal_has_expirationtype() const; + public: + void clear_expirationtype(); + ::SessionProtos::Content_ExpirationType expirationtype() const; + void set_expirationtype(::SessionProtos::Content_ExpirationType value); private: - const std::string& _internal_sig() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); - std::string* _internal_mutable_sig(); + ::SessionProtos::Content_ExpirationType _internal_expirationtype() const; + void _internal_set_expirationtype(::SessionProtos::Content_ExpirationType value); public: - // required uint64 expiryUnixTs = 4; - bool has_expiryunixts() const; + // optional uint32 expirationTimer = 13; + bool has_expirationtimer() const; private: - bool _internal_has_expiryunixts() const; + bool _internal_has_expirationtimer() const; public: - void clear_expiryunixts(); - uint64_t expiryunixts() const; - void set_expiryunixts(uint64_t value); + void clear_expirationtimer(); + uint32_t expirationtimer() const; + void set_expirationtimer(uint32_t value); private: - uint64_t _internal_expiryunixts() const; - void _internal_set_expiryunixts(uint64_t value); + uint32_t _internal_expirationtimer() const; + void _internal_set_expirationtimer(uint32_t value); public: - // required uint32 version = 1; - bool has_version() const; + // optional uint64 sigTimestamp = 15; + bool has_sigtimestamp() const; private: - bool _internal_has_version() const; + bool _internal_has_sigtimestamp() const; public: - void clear_version(); - uint32_t version() const; - void set_version(uint32_t value); + void clear_sigtimestamp(); + uint64_t sigtimestamp() const; + void set_sigtimestamp(uint64_t value); private: - uint32_t _internal_version() const; - void _internal_set_version(uint32_t value); + uint64_t _internal_sigtimestamp() const; + void _internal_set_sigtimestamp(uint64_t value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ProProof) + // @@protoc_insertion_point(class_scope:SessionProtos.Content) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; - uint64_t expiryunixts_; - uint32_t version_; + ::SessionProtos::DataMessage* datamessage_; + ::SessionProtos::CallMessage* callmessage_; + ::SessionProtos::ReceiptMessage* receiptmessage_; + ::SessionProtos::TypingMessage* typingmessage_; + ::SessionProtos::DataExtractionNotification* dataextractionnotification_; + ::SessionProtos::UnsendRequest* unsendrequest_; + ::SessionProtos::MessageRequestResponse* messagerequestresponse_; + ::SessionProtos::SharedConfigMessage* sharedconfigmessage_; + int expirationtype_; + uint32_t expirationtimer_; + uint64_t sigtimestamp_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ProConfig final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProConfig) */ { +class CallMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.CallMessage) */ { public: - inline ProConfig() : ProConfig(nullptr) {} - ~ProConfig() override; - explicit PROTOBUF_CONSTEXPR ProConfig(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline CallMessage() : CallMessage(nullptr) {} + ~CallMessage() override; + explicit PROTOBUF_CONSTEXPR CallMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ProConfig(const ProConfig& from); - ProConfig(ProConfig&& from) noexcept - : ProConfig() { + CallMessage(const CallMessage& from); + CallMessage(CallMessage&& from) noexcept + : CallMessage() { *this = ::std::move(from); } - inline ProConfig& operator=(const ProConfig& from) { + inline CallMessage& operator=(const CallMessage& from) { CopyFrom(from); return *this; } - inline ProConfig& operator=(ProConfig&& from) noexcept { + inline CallMessage& operator=(CallMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1411,27 +1749,36 @@ class ProConfig final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ProConfig& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const CallMessage& default_instance() { return *internal_default_instance(); } - static inline const ProConfig* internal_default_instance() { - return reinterpret_cast( - &_ProConfig_default_instance_); + static inline const CallMessage* internal_default_instance() { + return reinterpret_cast( + &_CallMessage_default_instance_); } static constexpr int kIndexInFileMessages = 5; - friend void swap(ProConfig& a, ProConfig& b) { + friend void swap(CallMessage& a, CallMessage& b) { a.Swap(&b); } - inline void Swap(ProConfig* other) { + inline void Swap(CallMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1444,7 +1791,7 @@ class ProConfig final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ProConfig* other) { + void UnsafeArenaSwap(CallMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1452,12 +1799,18 @@ class ProConfig final : // implements Message ---------------------------------------------- - ProConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + CallMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const CallMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const CallMessage& from) { + CallMessage::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ProConfig& from); - void MergeFrom(const ProConfig& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1470,66 +1823,175 @@ class ProConfig final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ProConfig* other); + void SetCachedSize(int size) const final; + void InternalSwap(CallMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ProConfig"; + return "SessionProtos.CallMessage"; } protected: - explicit ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef CallMessage_Type Type; + static constexpr Type PRE_OFFER = + CallMessage_Type_PRE_OFFER; + static constexpr Type OFFER = + CallMessage_Type_OFFER; + static constexpr Type ANSWER = + CallMessage_Type_ANSWER; + static constexpr Type PROVISIONAL_ANSWER = + CallMessage_Type_PROVISIONAL_ANSWER; + static constexpr Type ICE_CANDIDATES = + CallMessage_Type_ICE_CANDIDATES; + static constexpr Type END_CALL = + CallMessage_Type_END_CALL; + static inline bool Type_IsValid(int value) { + return CallMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + CallMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + CallMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + CallMessage_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return CallMessage_Type_descriptor(); + } + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return CallMessage_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return CallMessage_Type_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kRotatingPrivKeyFieldNumber = 1, - kProofFieldNumber = 2, + kSdpsFieldNumber = 2, + kSdpMLineIndexesFieldNumber = 3, + kSdpMidsFieldNumber = 4, + kUuidFieldNumber = 5, + kTypeFieldNumber = 1, }; - // required bytes rotatingPrivKey = 1; - bool has_rotatingprivkey() const; + // repeated string sdps = 2; + int sdps_size() const; + private: + int _internal_sdps_size() const; + public: + void clear_sdps(); + const std::string& sdps(int index) const; + std::string* mutable_sdps(int index); + void set_sdps(int index, const std::string& value); + void set_sdps(int index, std::string&& value); + void set_sdps(int index, const char* value); + void set_sdps(int index, const char* value, size_t size); + std::string* add_sdps(); + void add_sdps(const std::string& value); + void add_sdps(std::string&& value); + void add_sdps(const char* value); + void add_sdps(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdps() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdps(); + private: + const std::string& _internal_sdps(int index) const; + std::string* _internal_add_sdps(); + public: + + // repeated uint32 sdpMLineIndexes = 3; + int sdpmlineindexes_size() const; + private: + int _internal_sdpmlineindexes_size() const; + public: + void clear_sdpmlineindexes(); + private: + uint32_t _internal_sdpmlineindexes(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& + _internal_sdpmlineindexes() const; + void _internal_add_sdpmlineindexes(uint32_t value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* + _internal_mutable_sdpmlineindexes(); + public: + uint32_t sdpmlineindexes(int index) const; + void set_sdpmlineindexes(int index, uint32_t value); + void add_sdpmlineindexes(uint32_t value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& + sdpmlineindexes() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* + mutable_sdpmlineindexes(); + + // repeated string sdpMids = 4; + int sdpmids_size() const; + private: + int _internal_sdpmids_size() const; + public: + void clear_sdpmids(); + const std::string& sdpmids(int index) const; + std::string* mutable_sdpmids(int index); + void set_sdpmids(int index, const std::string& value); + void set_sdpmids(int index, std::string&& value); + void set_sdpmids(int index, const char* value); + void set_sdpmids(int index, const char* value, size_t size); + std::string* add_sdpmids(); + void add_sdpmids(const std::string& value); + void add_sdpmids(std::string&& value); + void add_sdpmids(const char* value); + void add_sdpmids(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdpmids() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdpmids(); + private: + const std::string& _internal_sdpmids(int index) const; + std::string* _internal_add_sdpmids(); + public: + + // required string uuid = 5; + bool has_uuid() const; private: - bool _internal_has_rotatingprivkey() const; + bool _internal_has_uuid() const; public: - void clear_rotatingprivkey(); - const std::string& rotatingprivkey() const; + void clear_uuid(); + const std::string& uuid() const; template - void set_rotatingprivkey(ArgT0&& arg0, ArgT... args); - std::string* mutable_rotatingprivkey(); - PROTOBUF_NODISCARD std::string* release_rotatingprivkey(); - void set_allocated_rotatingprivkey(std::string* rotatingprivkey); + void set_uuid(ArgT0&& arg0, ArgT... args); + std::string* mutable_uuid(); + PROTOBUF_NODISCARD std::string* release_uuid(); + void set_allocated_uuid(std::string* uuid); private: - const std::string& _internal_rotatingprivkey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingprivkey(const std::string& value); - std::string* _internal_mutable_rotatingprivkey(); + const std::string& _internal_uuid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_uuid(const std::string& value); + std::string* _internal_mutable_uuid(); public: - // required .SessionProtos.ProProof proof = 2; - bool has_proof() const; + // required .SessionProtos.CallMessage.Type type = 1; + bool has_type() const; private: - bool _internal_has_proof() const; + bool _internal_has_type() const; public: - void clear_proof(); - const ::SessionProtos::ProProof& proof() const; - PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); - ::SessionProtos::ProProof* mutable_proof(); - void set_allocated_proof(::SessionProtos::ProProof* proof); + void clear_type(); + ::SessionProtos::CallMessage_Type type() const; + void set_type(::SessionProtos::CallMessage_Type value); private: - const ::SessionProtos::ProProof& _internal_proof() const; - ::SessionProtos::ProProof* _internal_mutable_proof(); + ::SessionProtos::CallMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::CallMessage_Type value); public: - void unsafe_arena_set_allocated_proof( - ::SessionProtos::ProProof* proof); - ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // @@protoc_insertion_point(class_scope:SessionProtos.ProConfig) + // @@protoc_insertion_point(class_scope:SessionProtos.CallMessage) private: class _Internal; @@ -1542,32 +2004,35 @@ class ProConfig final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingprivkey_; - ::SessionProtos::ProProof* proof_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdps_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t > sdpmlineindexes_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdpmids_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr uuid_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ProMessageConfig final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProMessageConfig) */ { +class KeyPair final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.KeyPair) */ { public: - inline ProMessageConfig() : ProMessageConfig(nullptr) {} - ~ProMessageConfig() override; - explicit PROTOBUF_CONSTEXPR ProMessageConfig(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline KeyPair() : KeyPair(nullptr) {} + ~KeyPair() override; + explicit PROTOBUF_CONSTEXPR KeyPair(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ProMessageConfig(const ProMessageConfig& from); - ProMessageConfig(ProMessageConfig&& from) noexcept - : ProMessageConfig() { + KeyPair(const KeyPair& from); + KeyPair(KeyPair&& from) noexcept + : KeyPair() { *this = ::std::move(from); } - inline ProMessageConfig& operator=(const ProMessageConfig& from) { + inline KeyPair& operator=(const KeyPair& from) { CopyFrom(from); return *this; } - inline ProMessageConfig& operator=(ProMessageConfig&& from) noexcept { + inline KeyPair& operator=(KeyPair&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1581,27 +2046,36 @@ class ProMessageConfig final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ProMessageConfig& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const KeyPair& default_instance() { return *internal_default_instance(); } - static inline const ProMessageConfig* internal_default_instance() { - return reinterpret_cast( - &_ProMessageConfig_default_instance_); + static inline const KeyPair* internal_default_instance() { + return reinterpret_cast( + &_KeyPair_default_instance_); } static constexpr int kIndexInFileMessages = 6; - friend void swap(ProMessageConfig& a, ProMessageConfig& b) { + friend void swap(KeyPair& a, KeyPair& b) { a.Swap(&b); } - inline void Swap(ProMessageConfig* other) { + inline void Swap(KeyPair* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1614,7 +2088,7 @@ class ProMessageConfig final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ProMessageConfig* other) { + void UnsafeArenaSwap(KeyPair* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1622,12 +2096,18 @@ class ProMessageConfig final : // implements Message ---------------------------------------------- - ProMessageConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + KeyPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const KeyPair& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const KeyPair& from) { + KeyPair::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ProMessageConfig& from); - void MergeFrom(const ProMessageConfig& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1640,61 +2120,69 @@ class ProMessageConfig final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ProMessageConfig* other); + void SetCachedSize(int size) const final; + void InternalSwap(KeyPair* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ProMessageConfig"; + return "SessionProtos.KeyPair"; } protected: - explicit ProMessageConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kProofFieldNumber = 1, - kFlagsFieldNumber = 2, + kPublicKeyFieldNumber = 1, + kPrivateKeyFieldNumber = 2, }; - // required .SessionProtos.ProProof proof = 1; - bool has_proof() const; + // required bytes publicKey = 1; + bool has_publickey() const; private: - bool _internal_has_proof() const; + bool _internal_has_publickey() const; public: - void clear_proof(); - const ::SessionProtos::ProProof& proof() const; - PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); - ::SessionProtos::ProProof* mutable_proof(); - void set_allocated_proof(::SessionProtos::ProProof* proof); + void clear_publickey(); + const std::string& publickey() const; + template + void set_publickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_publickey(); + PROTOBUF_NODISCARD std::string* release_publickey(); + void set_allocated_publickey(std::string* publickey); private: - const ::SessionProtos::ProProof& _internal_proof() const; - ::SessionProtos::ProProof* _internal_mutable_proof(); + const std::string& _internal_publickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); + std::string* _internal_mutable_publickey(); public: - void unsafe_arena_set_allocated_proof( - ::SessionProtos::ProProof* proof); - ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // required uint32 flags = 2; - bool has_flags() const; + // required bytes privateKey = 2; + bool has_privatekey() const; private: - bool _internal_has_flags() const; + bool _internal_has_privatekey() const; public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); + void clear_privatekey(); + const std::string& privatekey() const; + template + void set_privatekey(ArgT0&& arg0, ArgT... args); + std::string* mutable_privatekey(); + PROTOBUF_NODISCARD std::string* release_privatekey(); + void set_allocated_privatekey(std::string* privatekey); private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); + const std::string& _internal_privatekey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_privatekey(const std::string& value); + std::string* _internal_mutable_privatekey(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ProMessageConfig) + // @@protoc_insertion_point(class_scope:SessionProtos.KeyPair) private: class _Internal; @@ -1707,32 +2195,32 @@ class ProMessageConfig final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::SessionProtos::ProProof* proof_; - uint32_t flags_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr privatekey_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class Content final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.Content) */ { +class DataExtractionNotification final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataExtractionNotification) */ { public: - inline Content() : Content(nullptr) {} - ~Content() override; - explicit PROTOBUF_CONSTEXPR Content(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataExtractionNotification() : DataExtractionNotification(nullptr) {} + ~DataExtractionNotification() override; + explicit PROTOBUF_CONSTEXPR DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - Content(const Content& from); - Content(Content&& from) noexcept - : Content() { + DataExtractionNotification(const DataExtractionNotification& from); + DataExtractionNotification(DataExtractionNotification&& from) noexcept + : DataExtractionNotification() { *this = ::std::move(from); } - inline Content& operator=(const Content& from) { + inline DataExtractionNotification& operator=(const DataExtractionNotification& from) { CopyFrom(from); return *this; } - inline Content& operator=(Content&& from) noexcept { + inline DataExtractionNotification& operator=(DataExtractionNotification&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -1746,27 +2234,36 @@ class Content final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const Content& default_instance() { - return *internal_default_instance(); + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); } - static inline const Content* internal_default_instance() { - return reinterpret_cast( - &_Content_default_instance_); + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataExtractionNotification& default_instance() { + return *internal_default_instance(); + } + static inline const DataExtractionNotification* internal_default_instance() { + return reinterpret_cast( + &_DataExtractionNotification_default_instance_); } static constexpr int kIndexInFileMessages = 7; - friend void swap(Content& a, Content& b) { + friend void swap(DataExtractionNotification& a, DataExtractionNotification& b) { a.Swap(&b); } - inline void Swap(Content* other) { + inline void Swap(DataExtractionNotification* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -1779,7 +2276,7 @@ class Content final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(Content* other) { + void UnsafeArenaSwap(DataExtractionNotification* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -1787,12 +2284,18 @@ class Content final : // implements Message ---------------------------------------------- - Content* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataExtractionNotification* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const Content& from); - void MergeFrom(const Content& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataExtractionNotification& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataExtractionNotification& from) { + DataExtractionNotification::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1805,218 +2308,89 @@ class Content final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(Content* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataExtractionNotification* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.Content"; + return "SessionProtos.DataExtractionNotification"; } protected: - explicit Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef DataExtractionNotification_Type Type; + static constexpr Type SCREENSHOT = + DataExtractionNotification_Type_SCREENSHOT; + static constexpr Type MEDIA_SAVED = + DataExtractionNotification_Type_MEDIA_SAVED; + static inline bool Type_IsValid(int value) { + return DataExtractionNotification_Type_IsValid(value); + } + static constexpr Type Type_MIN = + DataExtractionNotification_Type_Type_MIN; + static constexpr Type Type_MAX = + DataExtractionNotification_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + DataExtractionNotification_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return DataExtractionNotification_Type_descriptor(); + } + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return DataExtractionNotification_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return DataExtractionNotification_Type_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kDataMessageFieldNumber = 1, - kCallMessageFieldNumber = 3, - kReceiptMessageFieldNumber = 5, - kTypingMessageFieldNumber = 6, - kConfigurationMessageFieldNumber = 7, - kDataExtractionNotificationFieldNumber = 8, - kUnsendRequestFieldNumber = 9, - kMessageRequestResponseFieldNumber = 10, - kSharedConfigMessageFieldNumber = 11, - kProMessageConfigFieldNumber = 12, + kTimestampFieldNumber = 2, + kTypeFieldNumber = 1, }; - // optional .SessionProtos.DataMessage dataMessage = 1; - bool has_datamessage() const; - private: - bool _internal_has_datamessage() const; - public: - void clear_datamessage(); - const ::SessionProtos::DataMessage& datamessage() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage* release_datamessage(); - ::SessionProtos::DataMessage* mutable_datamessage(); - void set_allocated_datamessage(::SessionProtos::DataMessage* datamessage); - private: - const ::SessionProtos::DataMessage& _internal_datamessage() const; - ::SessionProtos::DataMessage* _internal_mutable_datamessage(); - public: - void unsafe_arena_set_allocated_datamessage( - ::SessionProtos::DataMessage* datamessage); - ::SessionProtos::DataMessage* unsafe_arena_release_datamessage(); - - // optional .SessionProtos.CallMessage callMessage = 3; - bool has_callmessage() const; - private: - bool _internal_has_callmessage() const; - public: - void clear_callmessage(); - const ::SessionProtos::CallMessage& callmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::CallMessage* release_callmessage(); - ::SessionProtos::CallMessage* mutable_callmessage(); - void set_allocated_callmessage(::SessionProtos::CallMessage* callmessage); - private: - const ::SessionProtos::CallMessage& _internal_callmessage() const; - ::SessionProtos::CallMessage* _internal_mutable_callmessage(); - public: - void unsafe_arena_set_allocated_callmessage( - ::SessionProtos::CallMessage* callmessage); - ::SessionProtos::CallMessage* unsafe_arena_release_callmessage(); - - // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - bool has_receiptmessage() const; - private: - bool _internal_has_receiptmessage() const; - public: - void clear_receiptmessage(); - const ::SessionProtos::ReceiptMessage& receiptmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::ReceiptMessage* release_receiptmessage(); - ::SessionProtos::ReceiptMessage* mutable_receiptmessage(); - void set_allocated_receiptmessage(::SessionProtos::ReceiptMessage* receiptmessage); - private: - const ::SessionProtos::ReceiptMessage& _internal_receiptmessage() const; - ::SessionProtos::ReceiptMessage* _internal_mutable_receiptmessage(); - public: - void unsafe_arena_set_allocated_receiptmessage( - ::SessionProtos::ReceiptMessage* receiptmessage); - ::SessionProtos::ReceiptMessage* unsafe_arena_release_receiptmessage(); - - // optional .SessionProtos.TypingMessage typingMessage = 6; - bool has_typingmessage() const; - private: - bool _internal_has_typingmessage() const; - public: - void clear_typingmessage(); - const ::SessionProtos::TypingMessage& typingmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::TypingMessage* release_typingmessage(); - ::SessionProtos::TypingMessage* mutable_typingmessage(); - void set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage); - private: - const ::SessionProtos::TypingMessage& _internal_typingmessage() const; - ::SessionProtos::TypingMessage* _internal_mutable_typingmessage(); - public: - void unsafe_arena_set_allocated_typingmessage( - ::SessionProtos::TypingMessage* typingmessage); - ::SessionProtos::TypingMessage* unsafe_arena_release_typingmessage(); - - // optional .SessionProtos.ConfigurationMessage configurationMessage = 7; - bool has_configurationmessage() const; - private: - bool _internal_has_configurationmessage() const; - public: - void clear_configurationmessage(); - const ::SessionProtos::ConfigurationMessage& configurationmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::ConfigurationMessage* release_configurationmessage(); - ::SessionProtos::ConfigurationMessage* mutable_configurationmessage(); - void set_allocated_configurationmessage(::SessionProtos::ConfigurationMessage* configurationmessage); - private: - const ::SessionProtos::ConfigurationMessage& _internal_configurationmessage() const; - ::SessionProtos::ConfigurationMessage* _internal_mutable_configurationmessage(); - public: - void unsafe_arena_set_allocated_configurationmessage( - ::SessionProtos::ConfigurationMessage* configurationmessage); - ::SessionProtos::ConfigurationMessage* unsafe_arena_release_configurationmessage(); - - // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - bool has_dataextractionnotification() const; - private: - bool _internal_has_dataextractionnotification() const; - public: - void clear_dataextractionnotification(); - const ::SessionProtos::DataExtractionNotification& dataextractionnotification() const; - PROTOBUF_NODISCARD ::SessionProtos::DataExtractionNotification* release_dataextractionnotification(); - ::SessionProtos::DataExtractionNotification* mutable_dataextractionnotification(); - void set_allocated_dataextractionnotification(::SessionProtos::DataExtractionNotification* dataextractionnotification); - private: - const ::SessionProtos::DataExtractionNotification& _internal_dataextractionnotification() const; - ::SessionProtos::DataExtractionNotification* _internal_mutable_dataextractionnotification(); - public: - void unsafe_arena_set_allocated_dataextractionnotification( - ::SessionProtos::DataExtractionNotification* dataextractionnotification); - ::SessionProtos::DataExtractionNotification* unsafe_arena_release_dataextractionnotification(); - - // optional .SessionProtos.UnsendRequest unsendRequest = 9; - bool has_unsendrequest() const; - private: - bool _internal_has_unsendrequest() const; - public: - void clear_unsendrequest(); - const ::SessionProtos::UnsendRequest& unsendrequest() const; - PROTOBUF_NODISCARD ::SessionProtos::UnsendRequest* release_unsendrequest(); - ::SessionProtos::UnsendRequest* mutable_unsendrequest(); - void set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest); - private: - const ::SessionProtos::UnsendRequest& _internal_unsendrequest() const; - ::SessionProtos::UnsendRequest* _internal_mutable_unsendrequest(); - public: - void unsafe_arena_set_allocated_unsendrequest( - ::SessionProtos::UnsendRequest* unsendrequest); - ::SessionProtos::UnsendRequest* unsafe_arena_release_unsendrequest(); - - // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - bool has_messagerequestresponse() const; - private: - bool _internal_has_messagerequestresponse() const; - public: - void clear_messagerequestresponse(); - const ::SessionProtos::MessageRequestResponse& messagerequestresponse() const; - PROTOBUF_NODISCARD ::SessionProtos::MessageRequestResponse* release_messagerequestresponse(); - ::SessionProtos::MessageRequestResponse* mutable_messagerequestresponse(); - void set_allocated_messagerequestresponse(::SessionProtos::MessageRequestResponse* messagerequestresponse); - private: - const ::SessionProtos::MessageRequestResponse& _internal_messagerequestresponse() const; - ::SessionProtos::MessageRequestResponse* _internal_mutable_messagerequestresponse(); - public: - void unsafe_arena_set_allocated_messagerequestresponse( - ::SessionProtos::MessageRequestResponse* messagerequestresponse); - ::SessionProtos::MessageRequestResponse* unsafe_arena_release_messagerequestresponse(); - - // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - bool has_sharedconfigmessage() const; + // optional uint64 timestamp = 2; + bool has_timestamp() const; private: - bool _internal_has_sharedconfigmessage() const; + bool _internal_has_timestamp() const; public: - void clear_sharedconfigmessage(); - const ::SessionProtos::SharedConfigMessage& sharedconfigmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::SharedConfigMessage* release_sharedconfigmessage(); - ::SessionProtos::SharedConfigMessage* mutable_sharedconfigmessage(); - void set_allocated_sharedconfigmessage(::SessionProtos::SharedConfigMessage* sharedconfigmessage); + void clear_timestamp(); + uint64_t timestamp() const; + void set_timestamp(uint64_t value); private: - const ::SessionProtos::SharedConfigMessage& _internal_sharedconfigmessage() const; - ::SessionProtos::SharedConfigMessage* _internal_mutable_sharedconfigmessage(); + uint64_t _internal_timestamp() const; + void _internal_set_timestamp(uint64_t value); public: - void unsafe_arena_set_allocated_sharedconfigmessage( - ::SessionProtos::SharedConfigMessage* sharedconfigmessage); - ::SessionProtos::SharedConfigMessage* unsafe_arena_release_sharedconfigmessage(); - // optional .SessionProtos.ProMessageConfig proMessageConfig = 12; - bool has_promessageconfig() const; + // required .SessionProtos.DataExtractionNotification.Type type = 1; + bool has_type() const; private: - bool _internal_has_promessageconfig() const; + bool _internal_has_type() const; public: - void clear_promessageconfig(); - const ::SessionProtos::ProMessageConfig& promessageconfig() const; - PROTOBUF_NODISCARD ::SessionProtos::ProMessageConfig* release_promessageconfig(); - ::SessionProtos::ProMessageConfig* mutable_promessageconfig(); - void set_allocated_promessageconfig(::SessionProtos::ProMessageConfig* promessageconfig); + void clear_type(); + ::SessionProtos::DataExtractionNotification_Type type() const; + void set_type(::SessionProtos::DataExtractionNotification_Type value); private: - const ::SessionProtos::ProMessageConfig& _internal_promessageconfig() const; - ::SessionProtos::ProMessageConfig* _internal_mutable_promessageconfig(); + ::SessionProtos::DataExtractionNotification_Type _internal_type() const; + void _internal_set_type(::SessionProtos::DataExtractionNotification_Type value); public: - void unsafe_arena_set_allocated_promessageconfig( - ::SessionProtos::ProMessageConfig* promessageconfig); - ::SessionProtos::ProMessageConfig* unsafe_arena_release_promessageconfig(); - // @@protoc_insertion_point(class_scope:SessionProtos.Content) + // @@protoc_insertion_point(class_scope:SessionProtos.DataExtractionNotification) private: class _Internal; @@ -2026,40 +2400,32 @@ class Content final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::SessionProtos::DataMessage* datamessage_; - ::SessionProtos::CallMessage* callmessage_; - ::SessionProtos::ReceiptMessage* receiptmessage_; - ::SessionProtos::TypingMessage* typingmessage_; - ::SessionProtos::ConfigurationMessage* configurationmessage_; - ::SessionProtos::DataExtractionNotification* dataextractionnotification_; - ::SessionProtos::UnsendRequest* unsendrequest_; - ::SessionProtos::MessageRequestResponse* messagerequestresponse_; - ::SessionProtos::SharedConfigMessage* sharedconfigmessage_; - ::SessionProtos::ProMessageConfig* promessageconfig_; + uint64_t timestamp_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class CallMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.CallMessage) */ { +class LokiProfile final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.LokiProfile) */ { public: - inline CallMessage() : CallMessage(nullptr) {} - ~CallMessage() override; - explicit PROTOBUF_CONSTEXPR CallMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline LokiProfile() : LokiProfile(nullptr) {} + ~LokiProfile() override; + explicit PROTOBUF_CONSTEXPR LokiProfile(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - CallMessage(const CallMessage& from); - CallMessage(CallMessage&& from) noexcept - : CallMessage() { + LokiProfile(const LokiProfile& from); + LokiProfile(LokiProfile&& from) noexcept + : LokiProfile() { *this = ::std::move(from); } - inline CallMessage& operator=(const CallMessage& from) { + inline LokiProfile& operator=(const LokiProfile& from) { CopyFrom(from); return *this; } - inline CallMessage& operator=(CallMessage&& from) noexcept { + inline LokiProfile& operator=(LokiProfile&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2073,27 +2439,36 @@ class CallMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const CallMessage& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const LokiProfile& default_instance() { return *internal_default_instance(); } - static inline const CallMessage* internal_default_instance() { - return reinterpret_cast( - &_CallMessage_default_instance_); + static inline const LokiProfile* internal_default_instance() { + return reinterpret_cast( + &_LokiProfile_default_instance_); } static constexpr int kIndexInFileMessages = 8; - friend void swap(CallMessage& a, CallMessage& b) { + friend void swap(LokiProfile& a, LokiProfile& b) { a.Swap(&b); } - inline void Swap(CallMessage* other) { + inline void Swap(LokiProfile* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2106,7 +2481,7 @@ class CallMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(CallMessage* other) { + void UnsafeArenaSwap(LokiProfile* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2114,12 +2489,18 @@ class CallMessage final : // implements Message ---------------------------------------------- - CallMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + LokiProfile* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const CallMessage& from); - void MergeFrom(const CallMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const LokiProfile& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const LokiProfile& from) { + LokiProfile::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2132,209 +2513,104 @@ class CallMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(CallMessage* other); + void SetCachedSize(int size) const final; + void InternalSwap(LokiProfile* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.CallMessage"; + return "SessionProtos.LokiProfile"; } protected: - explicit CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - // nested types ---------------------------------------------------- + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - typedef CallMessage_Type Type; - static constexpr Type PRE_OFFER = - CallMessage_Type_PRE_OFFER; - static constexpr Type OFFER = - CallMessage_Type_OFFER; - static constexpr Type ANSWER = - CallMessage_Type_ANSWER; - static constexpr Type PROVISIONAL_ANSWER = - CallMessage_Type_PROVISIONAL_ANSWER; - static constexpr Type ICE_CANDIDATES = - CallMessage_Type_ICE_CANDIDATES; - static constexpr Type END_CALL = - CallMessage_Type_END_CALL; - static inline bool Type_IsValid(int value) { - return CallMessage_Type_IsValid(value); - } - static constexpr Type Type_MIN = - CallMessage_Type_Type_MIN; - static constexpr Type Type_MAX = - CallMessage_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - CallMessage_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return CallMessage_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return CallMessage_Type_Parse(name, value); - } + // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kSdpsFieldNumber = 2, - kSdpMLineIndexesFieldNumber = 3, - kSdpMidsFieldNumber = 4, - kUuidFieldNumber = 5, - kTypeFieldNumber = 1, + kDisplayNameFieldNumber = 1, + kProfilePictureFieldNumber = 2, }; - // repeated string sdps = 2; - int sdps_size() const; - private: - int _internal_sdps_size() const; - public: - void clear_sdps(); - const std::string& sdps(int index) const; - std::string* mutable_sdps(int index); - void set_sdps(int index, const std::string& value); - void set_sdps(int index, std::string&& value); - void set_sdps(int index, const char* value); - void set_sdps(int index, const char* value, size_t size); - std::string* add_sdps(); - void add_sdps(const std::string& value); - void add_sdps(std::string&& value); - void add_sdps(const char* value); - void add_sdps(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdps() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdps(); - private: - const std::string& _internal_sdps(int index) const; - std::string* _internal_add_sdps(); - public: - - // repeated uint32 sdpMLineIndexes = 3; - int sdpmlineindexes_size() const; - private: - int _internal_sdpmlineindexes_size() const; - public: - void clear_sdpmlineindexes(); - private: - uint32_t _internal_sdpmlineindexes(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& - _internal_sdpmlineindexes() const; - void _internal_add_sdpmlineindexes(uint32_t value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* - _internal_mutable_sdpmlineindexes(); - public: - uint32_t sdpmlineindexes(int index) const; - void set_sdpmlineindexes(int index, uint32_t value); - void add_sdpmlineindexes(uint32_t value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >& - sdpmlineindexes() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t >* - mutable_sdpmlineindexes(); - - // repeated string sdpMids = 4; - int sdpmids_size() const; - private: - int _internal_sdpmids_size() const; - public: - void clear_sdpmids(); - const std::string& sdpmids(int index) const; - std::string* mutable_sdpmids(int index); - void set_sdpmids(int index, const std::string& value); - void set_sdpmids(int index, std::string&& value); - void set_sdpmids(int index, const char* value); - void set_sdpmids(int index, const char* value, size_t size); - std::string* add_sdpmids(); - void add_sdpmids(const std::string& value); - void add_sdpmids(std::string&& value); - void add_sdpmids(const char* value); - void add_sdpmids(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& sdpmids() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_sdpmids(); - private: - const std::string& _internal_sdpmids(int index) const; - std::string* _internal_add_sdpmids(); - public: - - // required string uuid = 5; - bool has_uuid() const; + // optional string displayName = 1; + bool has_displayname() const; private: - bool _internal_has_uuid() const; + bool _internal_has_displayname() const; public: - void clear_uuid(); - const std::string& uuid() const; + void clear_displayname(); + const std::string& displayname() const; template - void set_uuid(ArgT0&& arg0, ArgT... args); - std::string* mutable_uuid(); - PROTOBUF_NODISCARD std::string* release_uuid(); - void set_allocated_uuid(std::string* uuid); + void set_displayname(ArgT0&& arg0, ArgT... args); + std::string* mutable_displayname(); + PROTOBUF_NODISCARD std::string* release_displayname(); + void set_allocated_displayname(std::string* displayname); private: - const std::string& _internal_uuid() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_uuid(const std::string& value); - std::string* _internal_mutable_uuid(); + const std::string& _internal_displayname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); + std::string* _internal_mutable_displayname(); public: - // required .SessionProtos.CallMessage.Type type = 1; - bool has_type() const; + // optional string profilePicture = 2; + bool has_profilepicture() const; private: - bool _internal_has_type() const; + bool _internal_has_profilepicture() const; public: - void clear_type(); - ::SessionProtos::CallMessage_Type type() const; - void set_type(::SessionProtos::CallMessage_Type value); + void clear_profilepicture(); + const std::string& profilepicture() const; + template + void set_profilepicture(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilepicture(); + PROTOBUF_NODISCARD std::string* release_profilepicture(); + void set_allocated_profilepicture(std::string* profilepicture); private: - ::SessionProtos::CallMessage_Type _internal_type() const; - void _internal_set_type(::SessionProtos::CallMessage_Type value); + const std::string& _internal_profilepicture() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); + std::string* _internal_mutable_profilepicture(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.CallMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.LokiProfile) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdps_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint32_t > sdpmlineindexes_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField sdpmids_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr uuid_; - int type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class KeyPair final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.KeyPair) */ { +class DataMessage_Quote_QuotedAttachment final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote.QuotedAttachment) */ { public: - inline KeyPair() : KeyPair(nullptr) {} - ~KeyPair() override; - explicit PROTOBUF_CONSTEXPR KeyPair(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Quote_QuotedAttachment() : DataMessage_Quote_QuotedAttachment(nullptr) {} + ~DataMessage_Quote_QuotedAttachment() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - KeyPair(const KeyPair& from); - KeyPair(KeyPair&& from) noexcept - : KeyPair() { + DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from); + DataMessage_Quote_QuotedAttachment(DataMessage_Quote_QuotedAttachment&& from) noexcept + : DataMessage_Quote_QuotedAttachment() { *this = ::std::move(from); } - inline KeyPair& operator=(const KeyPair& from) { + inline DataMessage_Quote_QuotedAttachment& operator=(const DataMessage_Quote_QuotedAttachment& from) { CopyFrom(from); return *this; } - inline KeyPair& operator=(KeyPair&& from) noexcept { + inline DataMessage_Quote_QuotedAttachment& operator=(DataMessage_Quote_QuotedAttachment&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2348,27 +2624,36 @@ class KeyPair final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const KeyPair& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataMessage_Quote_QuotedAttachment& default_instance() { return *internal_default_instance(); } - static inline const KeyPair* internal_default_instance() { - return reinterpret_cast( - &_KeyPair_default_instance_); + static inline const DataMessage_Quote_QuotedAttachment* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Quote_QuotedAttachment_default_instance_); } static constexpr int kIndexInFileMessages = 9; - friend void swap(KeyPair& a, KeyPair& b) { + friend void swap(DataMessage_Quote_QuotedAttachment& a, DataMessage_Quote_QuotedAttachment& b) { a.Swap(&b); } - inline void Swap(KeyPair* other) { + inline void Swap(DataMessage_Quote_QuotedAttachment* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2381,7 +2666,7 @@ class KeyPair final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(KeyPair* other) { + void UnsafeArenaSwap(DataMessage_Quote_QuotedAttachment* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2389,12 +2674,18 @@ class KeyPair final : // implements Message ---------------------------------------------- - KeyPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Quote_QuotedAttachment* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const KeyPair& from); - void MergeFrom(const KeyPair& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataMessage_Quote_QuotedAttachment& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataMessage_Quote_QuotedAttachment& from) { + DataMessage_Quote_QuotedAttachment::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2407,104 +2698,167 @@ class KeyPair final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(KeyPair* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataMessage_Quote_QuotedAttachment* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.KeyPair"; + return "SessionProtos.DataMessage.Quote.QuotedAttachment"; } protected: - explicit KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - // nested types ---------------------------------------------------- + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - // accessors ------------------------------------------------------- + // nested types ---------------------------------------------------- - enum : int { - kPublicKeyFieldNumber = 1, - kPrivateKeyFieldNumber = 2, + typedef DataMessage_Quote_QuotedAttachment_Flags Flags; + static constexpr Flags VOICE_MESSAGE = + DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE; + static inline bool Flags_IsValid(int value) { + return DataMessage_Quote_QuotedAttachment_Flags_IsValid(value); + } + static constexpr Flags Flags_MIN = + DataMessage_Quote_QuotedAttachment_Flags_Flags_MIN; + static constexpr Flags Flags_MAX = + DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX; + static constexpr int Flags_ARRAYSIZE = + DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Flags_descriptor() { + return DataMessage_Quote_QuotedAttachment_Flags_descriptor(); + } + template + static inline const std::string& Flags_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Flags_Name."); + return DataMessage_Quote_QuotedAttachment_Flags_Name(enum_t_value); + } + static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Flags* value) { + return DataMessage_Quote_QuotedAttachment_Flags_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + enum : int { + kContentTypeFieldNumber = 1, + kFileNameFieldNumber = 2, + kThumbnailFieldNumber = 3, + kFlagsFieldNumber = 4, }; - // required bytes publicKey = 1; - bool has_publickey() const; + // optional string contentType = 1; + bool has_contenttype() const; private: - bool _internal_has_publickey() const; + bool _internal_has_contenttype() const; public: - void clear_publickey(); - const std::string& publickey() const; + void clear_contenttype(); + const std::string& contenttype() const; template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); + void set_contenttype(ArgT0&& arg0, ArgT... args); + std::string* mutable_contenttype(); + PROTOBUF_NODISCARD std::string* release_contenttype(); + void set_allocated_contenttype(std::string* contenttype); private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); + const std::string& _internal_contenttype() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); + std::string* _internal_mutable_contenttype(); public: - // required bytes privateKey = 2; - bool has_privatekey() const; + // optional string fileName = 2; + bool has_filename() const; private: - bool _internal_has_privatekey() const; + bool _internal_has_filename() const; public: - void clear_privatekey(); - const std::string& privatekey() const; + void clear_filename(); + const std::string& filename() const; template - void set_privatekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_privatekey(); - PROTOBUF_NODISCARD std::string* release_privatekey(); - void set_allocated_privatekey(std::string* privatekey); + void set_filename(ArgT0&& arg0, ArgT... args); + std::string* mutable_filename(); + PROTOBUF_NODISCARD std::string* release_filename(); + void set_allocated_filename(std::string* filename); private: - const std::string& _internal_privatekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_privatekey(const std::string& value); - std::string* _internal_mutable_privatekey(); + const std::string& _internal_filename() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); + std::string* _internal_mutable_filename(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.KeyPair) + // optional .SessionProtos.AttachmentPointer thumbnail = 3; + bool has_thumbnail() const; + private: + bool _internal_has_thumbnail() const; + public: + void clear_thumbnail(); + const ::SessionProtos::AttachmentPointer& thumbnail() const; + PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_thumbnail(); + ::SessionProtos::AttachmentPointer* mutable_thumbnail(); + void set_allocated_thumbnail(::SessionProtos::AttachmentPointer* thumbnail); + private: + const ::SessionProtos::AttachmentPointer& _internal_thumbnail() const; + ::SessionProtos::AttachmentPointer* _internal_mutable_thumbnail(); + public: + void unsafe_arena_set_allocated_thumbnail( + ::SessionProtos::AttachmentPointer* thumbnail); + ::SessionProtos::AttachmentPointer* unsafe_arena_release_thumbnail(); + + // optional uint32 flags = 4; + bool has_flags() const; + private: + bool _internal_has_flags() const; + public: + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); + private: + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote.QuotedAttachment) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr privatekey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; + ::SessionProtos::AttachmentPointer* thumbnail_; + uint32_t flags_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataExtractionNotification final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataExtractionNotification) */ { +class DataMessage_Quote final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote) */ { public: - inline DataExtractionNotification() : DataExtractionNotification(nullptr) {} - ~DataExtractionNotification() override; - explicit PROTOBUF_CONSTEXPR DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Quote() : DataMessage_Quote(nullptr) {} + ~DataMessage_Quote() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataExtractionNotification(const DataExtractionNotification& from); - DataExtractionNotification(DataExtractionNotification&& from) noexcept - : DataExtractionNotification() { + DataMessage_Quote(const DataMessage_Quote& from); + DataMessage_Quote(DataMessage_Quote&& from) noexcept + : DataMessage_Quote() { *this = ::std::move(from); } - inline DataExtractionNotification& operator=(const DataExtractionNotification& from) { + inline DataMessage_Quote& operator=(const DataMessage_Quote& from) { CopyFrom(from); return *this; } - inline DataExtractionNotification& operator=(DataExtractionNotification&& from) noexcept { + inline DataMessage_Quote& operator=(DataMessage_Quote&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2518,27 +2872,36 @@ class DataExtractionNotification final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataExtractionNotification& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataMessage_Quote& default_instance() { return *internal_default_instance(); } - static inline const DataExtractionNotification* internal_default_instance() { - return reinterpret_cast( - &_DataExtractionNotification_default_instance_); + static inline const DataMessage_Quote* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Quote_default_instance_); } static constexpr int kIndexInFileMessages = 10; - friend void swap(DataExtractionNotification& a, DataExtractionNotification& b) { + friend void swap(DataMessage_Quote& a, DataMessage_Quote& b) { a.Swap(&b); } - inline void Swap(DataExtractionNotification* other) { + inline void Swap(DataMessage_Quote* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2551,7 +2914,7 @@ class DataExtractionNotification final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataExtractionNotification* other) { + void UnsafeArenaSwap(DataMessage_Quote* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2559,12 +2922,18 @@ class DataExtractionNotification final : // implements Message ---------------------------------------------- - DataExtractionNotification* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Quote* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataExtractionNotification& from); - void MergeFrom(const DataExtractionNotification& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataMessage_Quote& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataMessage_Quote& from) { + DataMessage_Quote::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2577,117 +2946,144 @@ class DataExtractionNotification final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataExtractionNotification* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataMessage_Quote* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataExtractionNotification"; + return "SessionProtos.DataMessage.Quote"; } protected: - explicit DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- - typedef DataExtractionNotification_Type Type; - static constexpr Type SCREENSHOT = - DataExtractionNotification_Type_SCREENSHOT; - static constexpr Type MEDIA_SAVED = - DataExtractionNotification_Type_MEDIA_SAVED; - static inline bool Type_IsValid(int value) { - return DataExtractionNotification_Type_IsValid(value); - } - static constexpr Type Type_MIN = - DataExtractionNotification_Type_Type_MIN; - static constexpr Type Type_MAX = - DataExtractionNotification_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - DataExtractionNotification_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return DataExtractionNotification_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return DataExtractionNotification_Type_Parse(name, value); - } + typedef DataMessage_Quote_QuotedAttachment QuotedAttachment; // accessors ------------------------------------------------------- enum : int { - kTimestampFieldNumber = 2, - kTypeFieldNumber = 1, + kAttachmentsFieldNumber = 4, + kAuthorFieldNumber = 2, + kTextFieldNumber = 3, + kIdFieldNumber = 1, }; - // optional uint64 timestamp = 2; - bool has_timestamp() const; + // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; + int attachments_size() const; private: - bool _internal_has_timestamp() const; + int _internal_attachments_size() const; public: - void clear_timestamp(); - uint64_t timestamp() const; - void set_timestamp(uint64_t value); + void clear_attachments(); + ::SessionProtos::DataMessage_Quote_QuotedAttachment* mutable_attachments(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >* + mutable_attachments(); private: - uint64_t _internal_timestamp() const; - void _internal_set_timestamp(uint64_t value); + const ::SessionProtos::DataMessage_Quote_QuotedAttachment& _internal_attachments(int index) const; + ::SessionProtos::DataMessage_Quote_QuotedAttachment* _internal_add_attachments(); public: + const ::SessionProtos::DataMessage_Quote_QuotedAttachment& attachments(int index) const; + ::SessionProtos::DataMessage_Quote_QuotedAttachment* add_attachments(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >& + attachments() const; - // required .SessionProtos.DataExtractionNotification.Type type = 1; - bool has_type() const; + // required string author = 2; + bool has_author() const; private: - bool _internal_has_type() const; + bool _internal_has_author() const; public: - void clear_type(); - ::SessionProtos::DataExtractionNotification_Type type() const; - void set_type(::SessionProtos::DataExtractionNotification_Type value); + void clear_author(); + const std::string& author() const; + template + void set_author(ArgT0&& arg0, ArgT... args); + std::string* mutable_author(); + PROTOBUF_NODISCARD std::string* release_author(); + void set_allocated_author(std::string* author); private: - ::SessionProtos::DataExtractionNotification_Type _internal_type() const; - void _internal_set_type(::SessionProtos::DataExtractionNotification_Type value); + const std::string& _internal_author() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); + std::string* _internal_mutable_author(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataExtractionNotification) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; + // optional string text = 3; + bool has_text() const; + private: + bool _internal_has_text() const; + public: + void clear_text(); + const std::string& text() const; + template + void set_text(ArgT0&& arg0, ArgT... args); + std::string* mutable_text(); + PROTOBUF_NODISCARD std::string* release_text(); + void set_allocated_text(std::string* text); + private: + const std::string& _internal_text() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_text(const std::string& value); + std::string* _internal_mutable_text(); + public: + + // required uint64 id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + uint64_t id() const; + void set_id(uint64_t value); + private: + uint64_t _internal_id() const; + void _internal_set_id(uint64_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - uint64_t timestamp_; - int type_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment > attachments_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_; + uint64_t id_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class LokiProfile final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.LokiProfile) */ { +class DataMessage_Preview final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Preview) */ { public: - inline LokiProfile() : LokiProfile(nullptr) {} - ~LokiProfile() override; - explicit PROTOBUF_CONSTEXPR LokiProfile(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Preview() : DataMessage_Preview(nullptr) {} + ~DataMessage_Preview() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - LokiProfile(const LokiProfile& from); - LokiProfile(LokiProfile&& from) noexcept - : LokiProfile() { + DataMessage_Preview(const DataMessage_Preview& from); + DataMessage_Preview(DataMessage_Preview&& from) noexcept + : DataMessage_Preview() { *this = ::std::move(from); } - inline LokiProfile& operator=(const LokiProfile& from) { + inline DataMessage_Preview& operator=(const DataMessage_Preview& from) { CopyFrom(from); return *this; } - inline LokiProfile& operator=(LokiProfile&& from) noexcept { + inline DataMessage_Preview& operator=(DataMessage_Preview&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2701,27 +3097,36 @@ class LokiProfile final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const LokiProfile& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataMessage_Preview& default_instance() { return *internal_default_instance(); } - static inline const LokiProfile* internal_default_instance() { - return reinterpret_cast( - &_LokiProfile_default_instance_); + static inline const DataMessage_Preview* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Preview_default_instance_); } static constexpr int kIndexInFileMessages = 11; - friend void swap(LokiProfile& a, LokiProfile& b) { + friend void swap(DataMessage_Preview& a, DataMessage_Preview& b) { a.Swap(&b); } - inline void Swap(LokiProfile* other) { + inline void Swap(DataMessage_Preview* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2734,7 +3139,7 @@ class LokiProfile final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(LokiProfile* other) { + void UnsafeArenaSwap(DataMessage_Preview* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2742,12 +3147,18 @@ class LokiProfile final : // implements Message ---------------------------------------------- - LokiProfile* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Preview* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const LokiProfile& from); - void MergeFrom(const LokiProfile& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataMessage_Preview& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataMessage_Preview& from) { + DataMessage_Preview::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2760,66 +3171,88 @@ class LokiProfile final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(LokiProfile* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataMessage_Preview* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.LokiProfile"; + return "SessionProtos.DataMessage.Preview"; } protected: - explicit LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kDisplayNameFieldNumber = 1, - kProfilePictureFieldNumber = 2, + kUrlFieldNumber = 1, + kTitleFieldNumber = 2, + kImageFieldNumber = 3, }; - // optional string displayName = 1; - bool has_displayname() const; + // required string url = 1; + bool has_url() const; private: - bool _internal_has_displayname() const; + bool _internal_has_url() const; public: - void clear_displayname(); - const std::string& displayname() const; + void clear_url(); + const std::string& url() const; template - void set_displayname(ArgT0&& arg0, ArgT... args); - std::string* mutable_displayname(); - PROTOBUF_NODISCARD std::string* release_displayname(); - void set_allocated_displayname(std::string* displayname); + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); private: - const std::string& _internal_displayname() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); - std::string* _internal_mutable_displayname(); + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); public: - // optional string profilePicture = 2; - bool has_profilepicture() const; + // optional string title = 2; + bool has_title() const; private: - bool _internal_has_profilepicture() const; + bool _internal_has_title() const; public: - void clear_profilepicture(); - const std::string& profilepicture() const; + void clear_title(); + const std::string& title() const; template - void set_profilepicture(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilepicture(); - PROTOBUF_NODISCARD std::string* release_profilepicture(); - void set_allocated_profilepicture(std::string* profilepicture); + void set_title(ArgT0&& arg0, ArgT... args); + std::string* mutable_title(); + PROTOBUF_NODISCARD std::string* release_title(); + void set_allocated_title(std::string* title); private: - const std::string& _internal_profilepicture() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); - std::string* _internal_mutable_profilepicture(); + const std::string& _internal_title() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_title(const std::string& value); + std::string* _internal_mutable_title(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.LokiProfile) + // optional .SessionProtos.AttachmentPointer image = 3; + bool has_image() const; + private: + bool _internal_has_image() const; + public: + void clear_image(); + const ::SessionProtos::AttachmentPointer& image() const; + PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_image(); + ::SessionProtos::AttachmentPointer* mutable_image(); + void set_allocated_image(::SessionProtos::AttachmentPointer* image); + private: + const ::SessionProtos::AttachmentPointer& _internal_image() const; + ::SessionProtos::AttachmentPointer* _internal_mutable_image(); + public: + void unsafe_arena_set_allocated_image( + ::SessionProtos::AttachmentPointer* image); + ::SessionProtos::AttachmentPointer* unsafe_arena_release_image(); + + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Preview) private: class _Internal; @@ -2829,32 +3262,33 @@ class LokiProfile final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr title_; + ::SessionProtos::AttachmentPointer* image_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Quote_QuotedAttachment final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote.QuotedAttachment) */ { +class DataMessage_Reaction final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Reaction) */ { public: - inline DataMessage_Quote_QuotedAttachment() : DataMessage_Quote_QuotedAttachment(nullptr) {} - ~DataMessage_Quote_QuotedAttachment() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_Reaction() : DataMessage_Reaction(nullptr) {} + ~DataMessage_Reaction() override; + explicit PROTOBUF_CONSTEXPR DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from); - DataMessage_Quote_QuotedAttachment(DataMessage_Quote_QuotedAttachment&& from) noexcept - : DataMessage_Quote_QuotedAttachment() { + DataMessage_Reaction(const DataMessage_Reaction& from); + DataMessage_Reaction(DataMessage_Reaction&& from) noexcept + : DataMessage_Reaction() { *this = ::std::move(from); } - inline DataMessage_Quote_QuotedAttachment& operator=(const DataMessage_Quote_QuotedAttachment& from) { + inline DataMessage_Reaction& operator=(const DataMessage_Reaction& from) { CopyFrom(from); return *this; } - inline DataMessage_Quote_QuotedAttachment& operator=(DataMessage_Quote_QuotedAttachment&& from) noexcept { + inline DataMessage_Reaction& operator=(DataMessage_Reaction&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -2868,27 +3302,36 @@ class DataMessage_Quote_QuotedAttachment final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_Quote_QuotedAttachment& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataMessage_Reaction& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Quote_QuotedAttachment* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Quote_QuotedAttachment_default_instance_); + static inline const DataMessage_Reaction* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_Reaction_default_instance_); } static constexpr int kIndexInFileMessages = 12; - friend void swap(DataMessage_Quote_QuotedAttachment& a, DataMessage_Quote_QuotedAttachment& b) { + friend void swap(DataMessage_Reaction& a, DataMessage_Reaction& b) { a.Swap(&b); } - inline void Swap(DataMessage_Quote_QuotedAttachment* other) { + inline void Swap(DataMessage_Reaction* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -2901,7 +3344,7 @@ class DataMessage_Quote_QuotedAttachment final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Quote_QuotedAttachment* other) { + void UnsafeArenaSwap(DataMessage_Reaction* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -2909,12 +3352,18 @@ class DataMessage_Quote_QuotedAttachment final : // implements Message ---------------------------------------------- - DataMessage_Quote_QuotedAttachment* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_Reaction* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Quote_QuotedAttachment& from); - void MergeFrom(const DataMessage_Quote_QuotedAttachment& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataMessage_Reaction& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataMessage_Reaction& from) { + DataMessage_Reaction::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2927,160 +3376,167 @@ class DataMessage_Quote_QuotedAttachment final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Quote_QuotedAttachment* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataMessage_Reaction* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Quote.QuotedAttachment"; + return "SessionProtos.DataMessage.Reaction"; } protected: - explicit DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- - typedef DataMessage_Quote_QuotedAttachment_Flags Flags; - static constexpr Flags VOICE_MESSAGE = - DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE; - static inline bool Flags_IsValid(int value) { - return DataMessage_Quote_QuotedAttachment_Flags_IsValid(value); + typedef DataMessage_Reaction_Action Action; + static constexpr Action REACT = + DataMessage_Reaction_Action_REACT; + static constexpr Action REMOVE = + DataMessage_Reaction_Action_REMOVE; + static inline bool Action_IsValid(int value) { + return DataMessage_Reaction_Action_IsValid(value); + } + static constexpr Action Action_MIN = + DataMessage_Reaction_Action_Action_MIN; + static constexpr Action Action_MAX = + DataMessage_Reaction_Action_Action_MAX; + static constexpr int Action_ARRAYSIZE = + DataMessage_Reaction_Action_Action_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Action_descriptor() { + return DataMessage_Reaction_Action_descriptor(); } - static constexpr Flags Flags_MIN = - DataMessage_Quote_QuotedAttachment_Flags_Flags_MIN; - static constexpr Flags Flags_MAX = - DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX; - static constexpr int Flags_ARRAYSIZE = - DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE; template - static inline const std::string& Flags_Name(T enum_t_value) { - static_assert(::std::is_same::value || + static inline const std::string& Action_Name(T enum_t_value) { + static_assert(::std::is_same::value || ::std::is_integral::value, - "Incorrect type passed to function Flags_Name."); - return DataMessage_Quote_QuotedAttachment_Flags_Name(enum_t_value); + "Incorrect type passed to function Action_Name."); + return DataMessage_Reaction_Action_Name(enum_t_value); } - static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Flags* value) { - return DataMessage_Quote_QuotedAttachment_Flags_Parse(name, value); + static inline bool Action_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Action* value) { + return DataMessage_Reaction_Action_Parse(name, value); } // accessors ------------------------------------------------------- enum : int { - kContentTypeFieldNumber = 1, - kFileNameFieldNumber = 2, - kThumbnailFieldNumber = 3, - kFlagsFieldNumber = 4, + kAuthorFieldNumber = 2, + kEmojiFieldNumber = 3, + kIdFieldNumber = 1, + kActionFieldNumber = 4, }; - // optional string contentType = 1; - bool has_contenttype() const; + // required string author = 2; + bool has_author() const; private: - bool _internal_has_contenttype() const; + bool _internal_has_author() const; public: - void clear_contenttype(); - const std::string& contenttype() const; + void clear_author(); + const std::string& author() const; template - void set_contenttype(ArgT0&& arg0, ArgT... args); - std::string* mutable_contenttype(); - PROTOBUF_NODISCARD std::string* release_contenttype(); - void set_allocated_contenttype(std::string* contenttype); + void set_author(ArgT0&& arg0, ArgT... args); + std::string* mutable_author(); + PROTOBUF_NODISCARD std::string* release_author(); + void set_allocated_author(std::string* author); private: - const std::string& _internal_contenttype() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); - std::string* _internal_mutable_contenttype(); + const std::string& _internal_author() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); + std::string* _internal_mutable_author(); public: - // optional string fileName = 2; - bool has_filename() const; + // optional string emoji = 3; + bool has_emoji() const; private: - bool _internal_has_filename() const; + bool _internal_has_emoji() const; public: - void clear_filename(); - const std::string& filename() const; + void clear_emoji(); + const std::string& emoji() const; template - void set_filename(ArgT0&& arg0, ArgT... args); - std::string* mutable_filename(); - PROTOBUF_NODISCARD std::string* release_filename(); - void set_allocated_filename(std::string* filename); + void set_emoji(ArgT0&& arg0, ArgT... args); + std::string* mutable_emoji(); + PROTOBUF_NODISCARD std::string* release_emoji(); + void set_allocated_emoji(std::string* emoji); private: - const std::string& _internal_filename() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); - std::string* _internal_mutable_filename(); + const std::string& _internal_emoji() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_emoji(const std::string& value); + std::string* _internal_mutable_emoji(); public: - // optional .SessionProtos.AttachmentPointer thumbnail = 3; - bool has_thumbnail() const; + // required uint64 id = 1; + bool has_id() const; private: - bool _internal_has_thumbnail() const; + bool _internal_has_id() const; public: - void clear_thumbnail(); - const ::SessionProtos::AttachmentPointer& thumbnail() const; - PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_thumbnail(); - ::SessionProtos::AttachmentPointer* mutable_thumbnail(); - void set_allocated_thumbnail(::SessionProtos::AttachmentPointer* thumbnail); + void clear_id(); + uint64_t id() const; + void set_id(uint64_t value); private: - const ::SessionProtos::AttachmentPointer& _internal_thumbnail() const; - ::SessionProtos::AttachmentPointer* _internal_mutable_thumbnail(); + uint64_t _internal_id() const; + void _internal_set_id(uint64_t value); public: - void unsafe_arena_set_allocated_thumbnail( - ::SessionProtos::AttachmentPointer* thumbnail); - ::SessionProtos::AttachmentPointer* unsafe_arena_release_thumbnail(); - // optional uint32 flags = 4; - bool has_flags() const; + // required .SessionProtos.DataMessage.Reaction.Action action = 4; + bool has_action() const; private: - bool _internal_has_flags() const; + bool _internal_has_action() const; public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); + void clear_action(); + ::SessionProtos::DataMessage_Reaction_Action action() const; + void set_action(::SessionProtos::DataMessage_Reaction_Action value); private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); + ::SessionProtos::DataMessage_Reaction_Action _internal_action() const; + void _internal_set_action(::SessionProtos::DataMessage_Reaction_Action value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote.QuotedAttachment) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Reaction) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; - ::SessionProtos::AttachmentPointer* thumbnail_; - uint32_t flags_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr emoji_; + uint64_t id_; + int action_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Quote final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote) */ { +class DataMessage_OpenGroupInvitation final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.OpenGroupInvitation) */ { public: - inline DataMessage_Quote() : DataMessage_Quote(nullptr) {} - ~DataMessage_Quote() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage_OpenGroupInvitation() : DataMessage_OpenGroupInvitation(nullptr) {} + ~DataMessage_OpenGroupInvitation() override; + explicit PROTOBUF_CONSTEXPR DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Quote(const DataMessage_Quote& from); - DataMessage_Quote(DataMessage_Quote&& from) noexcept - : DataMessage_Quote() { + DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from); + DataMessage_OpenGroupInvitation(DataMessage_OpenGroupInvitation&& from) noexcept + : DataMessage_OpenGroupInvitation() { *this = ::std::move(from); } - inline DataMessage_Quote& operator=(const DataMessage_Quote& from) { + inline DataMessage_OpenGroupInvitation& operator=(const DataMessage_OpenGroupInvitation& from) { CopyFrom(from); return *this; } - inline DataMessage_Quote& operator=(DataMessage_Quote&& from) noexcept { + inline DataMessage_OpenGroupInvitation& operator=(DataMessage_OpenGroupInvitation&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3094,27 +3550,36 @@ class DataMessage_Quote final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_Quote& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataMessage_OpenGroupInvitation& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Quote* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Quote_default_instance_); + static inline const DataMessage_OpenGroupInvitation* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_OpenGroupInvitation_default_instance_); } static constexpr int kIndexInFileMessages = 13; - friend void swap(DataMessage_Quote& a, DataMessage_Quote& b) { + friend void swap(DataMessage_OpenGroupInvitation& a, DataMessage_OpenGroupInvitation& b) { a.Swap(&b); } - inline void Swap(DataMessage_Quote* other) { + inline void Swap(DataMessage_OpenGroupInvitation* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3127,7 +3592,7 @@ class DataMessage_Quote final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Quote* other) { + void UnsafeArenaSwap(DataMessage_OpenGroupInvitation* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3135,12 +3600,18 @@ class DataMessage_Quote final : // implements Message ---------------------------------------------- - DataMessage_Quote* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage_OpenGroupInvitation* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Quote& from); - void MergeFrom(const DataMessage_Quote& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataMessage_OpenGroupInvitation& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataMessage_OpenGroupInvitation& from) { + DataMessage_OpenGroupInvitation::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3153,101 +3624,69 @@ class DataMessage_Quote final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Quote* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataMessage_OpenGroupInvitation* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Quote"; + return "SessionProtos.DataMessage.OpenGroupInvitation"; } protected: - explicit DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - // nested types ---------------------------------------------------- + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - typedef DataMessage_Quote_QuotedAttachment QuotedAttachment; + // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kAttachmentsFieldNumber = 4, - kAuthorFieldNumber = 2, - kTextFieldNumber = 3, - kIdFieldNumber = 1, + kUrlFieldNumber = 1, + kNameFieldNumber = 3, }; - // repeated .SessionProtos.DataMessage.Quote.QuotedAttachment attachments = 4; - int attachments_size() const; - private: - int _internal_attachments_size() const; - public: - void clear_attachments(); - ::SessionProtos::DataMessage_Quote_QuotedAttachment* mutable_attachments(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >* - mutable_attachments(); - private: - const ::SessionProtos::DataMessage_Quote_QuotedAttachment& _internal_attachments(int index) const; - ::SessionProtos::DataMessage_Quote_QuotedAttachment* _internal_add_attachments(); - public: - const ::SessionProtos::DataMessage_Quote_QuotedAttachment& attachments(int index) const; - ::SessionProtos::DataMessage_Quote_QuotedAttachment* add_attachments(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment >& - attachments() const; - - // required string author = 2; - bool has_author() const; + // required string url = 1; + bool has_url() const; private: - bool _internal_has_author() const; + bool _internal_has_url() const; public: - void clear_author(); - const std::string& author() const; + void clear_url(); + const std::string& url() const; template - void set_author(ArgT0&& arg0, ArgT... args); - std::string* mutable_author(); - PROTOBUF_NODISCARD std::string* release_author(); - void set_allocated_author(std::string* author); + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); private: - const std::string& _internal_author() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); - std::string* _internal_mutable_author(); + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); public: - // optional string text = 3; - bool has_text() const; + // required string name = 3; + bool has_name() const; private: - bool _internal_has_text() const; + bool _internal_has_name() const; public: - void clear_text(); - const std::string& text() const; + void clear_name(); + const std::string& name() const; template - void set_text(ArgT0&& arg0, ArgT... args); - std::string* mutable_text(); - PROTOBUF_NODISCARD std::string* release_text(); - void set_allocated_text(std::string* text); - private: - const std::string& _internal_text() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_text(const std::string& value); - std::string* _internal_mutable_text(); - public: - - // required uint64 id = 1; - bool has_id() const; - private: - bool _internal_has_id() const; - public: - void clear_id(); - uint64_t id() const; - void set_id(uint64_t value); + void set_name(ArgT0&& arg0, ArgT... args); + std::string* mutable_name(); + PROTOBUF_NODISCARD std::string* release_name(); + void set_allocated_name(std::string* name); private: - uint64_t _internal_id() const; - void _internal_set_id(uint64_t value); + const std::string& _internal_name() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Quote) + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.OpenGroupInvitation) private: class _Internal; @@ -3260,34 +3699,32 @@ class DataMessage_Quote final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Quote_QuotedAttachment > attachments_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_; - uint64_t id_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_Preview final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Preview) */ { +class DataMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage) */ { public: - inline DataMessage_Preview() : DataMessage_Preview(nullptr) {} - ~DataMessage_Preview() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline DataMessage() : DataMessage(nullptr) {} + ~DataMessage() override; + explicit PROTOBUF_CONSTEXPR DataMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_Preview(const DataMessage_Preview& from); - DataMessage_Preview(DataMessage_Preview&& from) noexcept - : DataMessage_Preview() { + DataMessage(const DataMessage& from); + DataMessage(DataMessage&& from) noexcept + : DataMessage() { *this = ::std::move(from); } - inline DataMessage_Preview& operator=(const DataMessage_Preview& from) { + inline DataMessage& operator=(const DataMessage& from) { CopyFrom(from); return *this; } - inline DataMessage_Preview& operator=(DataMessage_Preview&& from) noexcept { + inline DataMessage& operator=(DataMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3301,27 +3738,36 @@ class DataMessage_Preview final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_Preview& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const DataMessage& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Preview* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Preview_default_instance_); + static inline const DataMessage* internal_default_instance() { + return reinterpret_cast( + &_DataMessage_default_instance_); } static constexpr int kIndexInFileMessages = 14; - friend void swap(DataMessage_Preview& a, DataMessage_Preview& b) { + friend void swap(DataMessage& a, DataMessage& b) { a.Swap(&b); } - inline void Swap(DataMessage_Preview* other) { + inline void Swap(DataMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3334,7 +3780,7 @@ class DataMessage_Preview final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Preview* other) { + void UnsafeArenaSwap(DataMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3342,12 +3788,18 @@ class DataMessage_Preview final : // implements Message ---------------------------------------------- - DataMessage_Preview* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + DataMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Preview& from); - void MergeFrom(const DataMessage_Preview& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const DataMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const DataMessage& from) { + DataMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3360,121 +3812,342 @@ class DataMessage_Preview final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Preview* other); + void SetCachedSize(int size) const final; + void InternalSwap(DataMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Preview"; + return "SessionProtos.DataMessage"; } protected: - explicit DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef DataMessage_Quote Quote; + typedef DataMessage_Preview Preview; + typedef DataMessage_Reaction Reaction; + typedef DataMessage_OpenGroupInvitation OpenGroupInvitation; + + typedef DataMessage_Flags Flags; + static constexpr Flags EXPIRATION_TIMER_UPDATE = + DataMessage_Flags_EXPIRATION_TIMER_UPDATE; + static inline bool Flags_IsValid(int value) { + return DataMessage_Flags_IsValid(value); + } + static constexpr Flags Flags_MIN = + DataMessage_Flags_Flags_MIN; + static constexpr Flags Flags_MAX = + DataMessage_Flags_Flags_MAX; + static constexpr int Flags_ARRAYSIZE = + DataMessage_Flags_Flags_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Flags_descriptor() { + return DataMessage_Flags_descriptor(); + } + template + static inline const std::string& Flags_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Flags_Name."); + return DataMessage_Flags_Name(enum_t_value); + } + static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Flags* value) { + return DataMessage_Flags_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kUrlFieldNumber = 1, - kTitleFieldNumber = 2, - kImageFieldNumber = 3, + kAttachmentsFieldNumber = 2, + kPreviewFieldNumber = 10, + kBodyFieldNumber = 1, + kProfileKeyFieldNumber = 6, + kSyncTargetFieldNumber = 105, + kQuoteFieldNumber = 8, + kReactionFieldNumber = 11, + kProfileFieldNumber = 101, + kOpenGroupInvitationFieldNumber = 102, + kGroupUpdateMessageFieldNumber = 120, + kTimestampFieldNumber = 7, + kFlagsFieldNumber = 4, + kBlocksCommunityMessageRequestsFieldNumber = 106, }; - // required string url = 1; - bool has_url() const; + // repeated .SessionProtos.AttachmentPointer attachments = 2; + int attachments_size() const; private: - bool _internal_has_url() const; + int _internal_attachments_size() const; public: - void clear_url(); - const std::string& url() const; - template - void set_url(ArgT0&& arg0, ArgT... args); - std::string* mutable_url(); - PROTOBUF_NODISCARD std::string* release_url(); - void set_allocated_url(std::string* url); + void clear_attachments(); + ::SessionProtos::AttachmentPointer* mutable_attachments(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >* + mutable_attachments(); private: - const std::string& _internal_url() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); - std::string* _internal_mutable_url(); + const ::SessionProtos::AttachmentPointer& _internal_attachments(int index) const; + ::SessionProtos::AttachmentPointer* _internal_add_attachments(); + public: + const ::SessionProtos::AttachmentPointer& attachments(int index) const; + ::SessionProtos::AttachmentPointer* add_attachments(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >& + attachments() const; + + // repeated .SessionProtos.DataMessage.Preview preview = 10; + int preview_size() const; + private: + int _internal_preview_size() const; + public: + void clear_preview(); + ::SessionProtos::DataMessage_Preview* mutable_preview(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >* + mutable_preview(); + private: + const ::SessionProtos::DataMessage_Preview& _internal_preview(int index) const; + ::SessionProtos::DataMessage_Preview* _internal_add_preview(); public: + const ::SessionProtos::DataMessage_Preview& preview(int index) const; + ::SessionProtos::DataMessage_Preview* add_preview(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >& + preview() const; - // optional string title = 2; - bool has_title() const; + // optional string body = 1; + bool has_body() const; private: - bool _internal_has_title() const; + bool _internal_has_body() const; public: - void clear_title(); - const std::string& title() const; + void clear_body(); + const std::string& body() const; template - void set_title(ArgT0&& arg0, ArgT... args); - std::string* mutable_title(); - PROTOBUF_NODISCARD std::string* release_title(); - void set_allocated_title(std::string* title); + void set_body(ArgT0&& arg0, ArgT... args); + std::string* mutable_body(); + PROTOBUF_NODISCARD std::string* release_body(); + void set_allocated_body(std::string* body); private: - const std::string& _internal_title() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_title(const std::string& value); - std::string* _internal_mutable_title(); + const std::string& _internal_body() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_body(const std::string& value); + std::string* _internal_mutable_body(); public: - // optional .SessionProtos.AttachmentPointer image = 3; - bool has_image() const; + // optional bytes profileKey = 6; + bool has_profilekey() const; private: - bool _internal_has_image() const; + bool _internal_has_profilekey() const; public: - void clear_image(); - const ::SessionProtos::AttachmentPointer& image() const; - PROTOBUF_NODISCARD ::SessionProtos::AttachmentPointer* release_image(); - ::SessionProtos::AttachmentPointer* mutable_image(); - void set_allocated_image(::SessionProtos::AttachmentPointer* image); + void clear_profilekey(); + const std::string& profilekey() const; + template + void set_profilekey(ArgT0&& arg0, ArgT... args); + std::string* mutable_profilekey(); + PROTOBUF_NODISCARD std::string* release_profilekey(); + void set_allocated_profilekey(std::string* profilekey); private: - const ::SessionProtos::AttachmentPointer& _internal_image() const; - ::SessionProtos::AttachmentPointer* _internal_mutable_image(); + const std::string& _internal_profilekey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); + std::string* _internal_mutable_profilekey(); public: - void unsafe_arena_set_allocated_image( - ::SessionProtos::AttachmentPointer* image); - ::SessionProtos::AttachmentPointer* unsafe_arena_release_image(); - - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Preview) - private: - class _Internal; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr title_; - ::SessionProtos::AttachmentPointer* image_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_SessionProtos_2eproto; -}; -// ------------------------------------------------------------------- + // optional string syncTarget = 105; + bool has_synctarget() const; + private: + bool _internal_has_synctarget() const; + public: + void clear_synctarget(); + const std::string& synctarget() const; + template + void set_synctarget(ArgT0&& arg0, ArgT... args); + std::string* mutable_synctarget(); + PROTOBUF_NODISCARD std::string* release_synctarget(); + void set_allocated_synctarget(std::string* synctarget); + private: + const std::string& _internal_synctarget() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_synctarget(const std::string& value); + std::string* _internal_mutable_synctarget(); + public: -class DataMessage_Reaction final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Reaction) */ { - public: - inline DataMessage_Reaction() : DataMessage_Reaction(nullptr) {} - ~DataMessage_Reaction() override; - explicit PROTOBUF_CONSTEXPR DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + // optional .SessionProtos.DataMessage.Quote quote = 8; + bool has_quote() const; + private: + bool _internal_has_quote() const; + public: + void clear_quote(); + const ::SessionProtos::DataMessage_Quote& quote() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Quote* release_quote(); + ::SessionProtos::DataMessage_Quote* mutable_quote(); + void set_allocated_quote(::SessionProtos::DataMessage_Quote* quote); + private: + const ::SessionProtos::DataMessage_Quote& _internal_quote() const; + ::SessionProtos::DataMessage_Quote* _internal_mutable_quote(); + public: + void unsafe_arena_set_allocated_quote( + ::SessionProtos::DataMessage_Quote* quote); + ::SessionProtos::DataMessage_Quote* unsafe_arena_release_quote(); - DataMessage_Reaction(const DataMessage_Reaction& from); - DataMessage_Reaction(DataMessage_Reaction&& from) noexcept - : DataMessage_Reaction() { + // optional .SessionProtos.DataMessage.Reaction reaction = 11; + bool has_reaction() const; + private: + bool _internal_has_reaction() const; + public: + void clear_reaction(); + const ::SessionProtos::DataMessage_Reaction& reaction() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Reaction* release_reaction(); + ::SessionProtos::DataMessage_Reaction* mutable_reaction(); + void set_allocated_reaction(::SessionProtos::DataMessage_Reaction* reaction); + private: + const ::SessionProtos::DataMessage_Reaction& _internal_reaction() const; + ::SessionProtos::DataMessage_Reaction* _internal_mutable_reaction(); + public: + void unsafe_arena_set_allocated_reaction( + ::SessionProtos::DataMessage_Reaction* reaction); + ::SessionProtos::DataMessage_Reaction* unsafe_arena_release_reaction(); + + // optional .SessionProtos.LokiProfile profile = 101; + bool has_profile() const; + private: + bool _internal_has_profile() const; + public: + void clear_profile(); + const ::SessionProtos::LokiProfile& profile() const; + PROTOBUF_NODISCARD ::SessionProtos::LokiProfile* release_profile(); + ::SessionProtos::LokiProfile* mutable_profile(); + void set_allocated_profile(::SessionProtos::LokiProfile* profile); + private: + const ::SessionProtos::LokiProfile& _internal_profile() const; + ::SessionProtos::LokiProfile* _internal_mutable_profile(); + public: + void unsafe_arena_set_allocated_profile( + ::SessionProtos::LokiProfile* profile); + ::SessionProtos::LokiProfile* unsafe_arena_release_profile(); + + // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; + bool has_opengroupinvitation() const; + private: + bool _internal_has_opengroupinvitation() const; + public: + void clear_opengroupinvitation(); + const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation() const; + PROTOBUF_NODISCARD ::SessionProtos::DataMessage_OpenGroupInvitation* release_opengroupinvitation(); + ::SessionProtos::DataMessage_OpenGroupInvitation* mutable_opengroupinvitation(); + void set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); + private: + const ::SessionProtos::DataMessage_OpenGroupInvitation& _internal_opengroupinvitation() const; + ::SessionProtos::DataMessage_OpenGroupInvitation* _internal_mutable_opengroupinvitation(); + public: + void unsafe_arena_set_allocated_opengroupinvitation( + ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); + ::SessionProtos::DataMessage_OpenGroupInvitation* unsafe_arena_release_opengroupinvitation(); + + // optional .SessionProtos.GroupUpdateMessage groupUpdateMessage = 120; + bool has_groupupdatemessage() const; + private: + bool _internal_has_groupupdatemessage() const; + public: + void clear_groupupdatemessage(); + const ::SessionProtos::GroupUpdateMessage& groupupdatemessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateMessage* release_groupupdatemessage(); + ::SessionProtos::GroupUpdateMessage* mutable_groupupdatemessage(); + void set_allocated_groupupdatemessage(::SessionProtos::GroupUpdateMessage* groupupdatemessage); + private: + const ::SessionProtos::GroupUpdateMessage& _internal_groupupdatemessage() const; + ::SessionProtos::GroupUpdateMessage* _internal_mutable_groupupdatemessage(); + public: + void unsafe_arena_set_allocated_groupupdatemessage( + ::SessionProtos::GroupUpdateMessage* groupupdatemessage); + ::SessionProtos::GroupUpdateMessage* unsafe_arena_release_groupupdatemessage(); + + // optional uint64 timestamp = 7; + bool has_timestamp() const; + private: + bool _internal_has_timestamp() const; + public: + void clear_timestamp(); + uint64_t timestamp() const; + void set_timestamp(uint64_t value); + private: + uint64_t _internal_timestamp() const; + void _internal_set_timestamp(uint64_t value); + public: + + // optional uint32 flags = 4; + bool has_flags() const; + private: + bool _internal_has_flags() const; + public: + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); + private: + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); + public: + + // optional bool blocksCommunityMessageRequests = 106; + bool has_blockscommunitymessagerequests() const; + private: + bool _internal_has_blockscommunitymessagerequests() const; + public: + void clear_blockscommunitymessagerequests(); + bool blockscommunitymessagerequests() const; + void set_blockscommunitymessagerequests(bool value); + private: + bool _internal_blockscommunitymessagerequests() const; + void _internal_set_blockscommunitymessagerequests(bool value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer > attachments_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview > preview_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr body_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr synctarget_; + ::SessionProtos::DataMessage_Quote* quote_; + ::SessionProtos::DataMessage_Reaction* reaction_; + ::SessionProtos::LokiProfile* profile_; + ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation_; + ::SessionProtos::GroupUpdateMessage* groupupdatemessage_; + uint64_t timestamp_; + uint32_t flags_; + bool blockscommunitymessagerequests_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + +class ReceiptMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ReceiptMessage) */ { + public: + inline ReceiptMessage() : ReceiptMessage(nullptr) {} + ~ReceiptMessage() override; + explicit PROTOBUF_CONSTEXPR ReceiptMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + ReceiptMessage(const ReceiptMessage& from); + ReceiptMessage(ReceiptMessage&& from) noexcept + : ReceiptMessage() { *this = ::std::move(from); } - inline DataMessage_Reaction& operator=(const DataMessage_Reaction& from) { + inline ReceiptMessage& operator=(const ReceiptMessage& from) { CopyFrom(from); return *this; } - inline DataMessage_Reaction& operator=(DataMessage_Reaction&& from) noexcept { + inline ReceiptMessage& operator=(ReceiptMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3488,27 +4161,36 @@ class DataMessage_Reaction final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_Reaction& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ReceiptMessage& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_Reaction* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_Reaction_default_instance_); + static inline const ReceiptMessage* internal_default_instance() { + return reinterpret_cast( + &_ReceiptMessage_default_instance_); } static constexpr int kIndexInFileMessages = 15; - friend void swap(DataMessage_Reaction& a, DataMessage_Reaction& b) { + friend void swap(ReceiptMessage& a, ReceiptMessage& b) { a.Swap(&b); } - inline void Swap(DataMessage_Reaction* other) { + inline void Swap(ReceiptMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3521,7 +4203,7 @@ class DataMessage_Reaction final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_Reaction* other) { + void UnsafeArenaSwap(ReceiptMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3529,12 +4211,18 @@ class DataMessage_Reaction final : // implements Message ---------------------------------------------- - DataMessage_Reaction* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + ReceiptMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_Reaction& from); - void MergeFrom(const DataMessage_Reaction& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const ReceiptMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const ReceiptMessage& from) { + ReceiptMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3547,160 +4235,133 @@ class DataMessage_Reaction final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_Reaction* other); + void SetCachedSize(int size) const final; + void InternalSwap(ReceiptMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.Reaction"; + return "SessionProtos.ReceiptMessage"; } protected: - explicit DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- - typedef DataMessage_Reaction_Action Action; - static constexpr Action REACT = - DataMessage_Reaction_Action_REACT; - static constexpr Action REMOVE = - DataMessage_Reaction_Action_REMOVE; - static inline bool Action_IsValid(int value) { - return DataMessage_Reaction_Action_IsValid(value); + typedef ReceiptMessage_Type Type; + static constexpr Type DELIVERY = + ReceiptMessage_Type_DELIVERY; + static constexpr Type READ = + ReceiptMessage_Type_READ; + static inline bool Type_IsValid(int value) { + return ReceiptMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + ReceiptMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + ReceiptMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + ReceiptMessage_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return ReceiptMessage_Type_descriptor(); } - static constexpr Action Action_MIN = - DataMessage_Reaction_Action_Action_MIN; - static constexpr Action Action_MAX = - DataMessage_Reaction_Action_Action_MAX; - static constexpr int Action_ARRAYSIZE = - DataMessage_Reaction_Action_Action_ARRAYSIZE; template - static inline const std::string& Action_Name(T enum_t_value) { - static_assert(::std::is_same::value || + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || ::std::is_integral::value, - "Incorrect type passed to function Action_Name."); - return DataMessage_Reaction_Action_Name(enum_t_value); + "Incorrect type passed to function Type_Name."); + return ReceiptMessage_Type_Name(enum_t_value); } - static inline bool Action_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Action* value) { - return DataMessage_Reaction_Action_Parse(name, value); + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return ReceiptMessage_Type_Parse(name, value); } // accessors ------------------------------------------------------- enum : int { - kAuthorFieldNumber = 2, - kEmojiFieldNumber = 3, - kIdFieldNumber = 1, - kActionFieldNumber = 4, + kTimestampFieldNumber = 2, + kTypeFieldNumber = 1, }; - // required string author = 2; - bool has_author() const; + // repeated uint64 timestamp = 2; + int timestamp_size() const; private: - bool _internal_has_author() const; + int _internal_timestamp_size() const; public: - void clear_author(); - const std::string& author() const; - template - void set_author(ArgT0&& arg0, ArgT... args); - std::string* mutable_author(); - PROTOBUF_NODISCARD std::string* release_author(); - void set_allocated_author(std::string* author); + void clear_timestamp(); private: - const std::string& _internal_author() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_author(const std::string& value); - std::string* _internal_mutable_author(); + uint64_t _internal_timestamp(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& + _internal_timestamp() const; + void _internal_add_timestamp(uint64_t value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* + _internal_mutable_timestamp(); public: + uint64_t timestamp(int index) const; + void set_timestamp(int index, uint64_t value); + void add_timestamp(uint64_t value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& + timestamp() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* + mutable_timestamp(); - // optional string emoji = 3; - bool has_emoji() const; + // required .SessionProtos.ReceiptMessage.Type type = 1; + bool has_type() const; private: - bool _internal_has_emoji() const; + bool _internal_has_type() const; public: - void clear_emoji(); - const std::string& emoji() const; - template - void set_emoji(ArgT0&& arg0, ArgT... args); - std::string* mutable_emoji(); - PROTOBUF_NODISCARD std::string* release_emoji(); - void set_allocated_emoji(std::string* emoji); - private: - const std::string& _internal_emoji() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_emoji(const std::string& value); - std::string* _internal_mutable_emoji(); - public: - - // required uint64 id = 1; - bool has_id() const; - private: - bool _internal_has_id() const; - public: - void clear_id(); - uint64_t id() const; - void set_id(uint64_t value); - private: - uint64_t _internal_id() const; - void _internal_set_id(uint64_t value); - public: - - // required .SessionProtos.DataMessage.Reaction.Action action = 4; - bool has_action() const; - private: - bool _internal_has_action() const; - public: - void clear_action(); - ::SessionProtos::DataMessage_Reaction_Action action() const; - void set_action(::SessionProtos::DataMessage_Reaction_Action value); + void clear_type(); + ::SessionProtos::ReceiptMessage_Type type() const; + void set_type(::SessionProtos::ReceiptMessage_Type value); private: - ::SessionProtos::DataMessage_Reaction_Action _internal_action() const; - void _internal_set_action(::SessionProtos::DataMessage_Reaction_Action value); + ::SessionProtos::ReceiptMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::ReceiptMessage_Type value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.Reaction) + // @@protoc_insertion_point(class_scope:SessionProtos.ReceiptMessage) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr author_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr emoji_; - uint64_t id_; - int action_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t > timestamp_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_OpenGroupInvitation final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.OpenGroupInvitation) */ { +class AttachmentPointer final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.AttachmentPointer) */ { public: - inline DataMessage_OpenGroupInvitation() : DataMessage_OpenGroupInvitation(nullptr) {} - ~DataMessage_OpenGroupInvitation() override; - explicit PROTOBUF_CONSTEXPR DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline AttachmentPointer() : AttachmentPointer(nullptr) {} + ~AttachmentPointer() override; + explicit PROTOBUF_CONSTEXPR AttachmentPointer(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from); - DataMessage_OpenGroupInvitation(DataMessage_OpenGroupInvitation&& from) noexcept - : DataMessage_OpenGroupInvitation() { + AttachmentPointer(const AttachmentPointer& from); + AttachmentPointer(AttachmentPointer&& from) noexcept + : AttachmentPointer() { *this = ::std::move(from); } - inline DataMessage_OpenGroupInvitation& operator=(const DataMessage_OpenGroupInvitation& from) { + inline AttachmentPointer& operator=(const AttachmentPointer& from) { CopyFrom(from); return *this; } - inline DataMessage_OpenGroupInvitation& operator=(DataMessage_OpenGroupInvitation&& from) noexcept { + inline AttachmentPointer& operator=(AttachmentPointer&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3714,27 +4375,36 @@ class DataMessage_OpenGroupInvitation final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_OpenGroupInvitation& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const AttachmentPointer& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_OpenGroupInvitation* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_OpenGroupInvitation_default_instance_); + static inline const AttachmentPointer* internal_default_instance() { + return reinterpret_cast( + &_AttachmentPointer_default_instance_); } static constexpr int kIndexInFileMessages = 16; - friend void swap(DataMessage_OpenGroupInvitation& a, DataMessage_OpenGroupInvitation& b) { + friend void swap(AttachmentPointer& a, AttachmentPointer& b) { a.Swap(&b); } - inline void Swap(DataMessage_OpenGroupInvitation* other) { + inline void Swap(AttachmentPointer* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3747,7 +4417,7 @@ class DataMessage_OpenGroupInvitation final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_OpenGroupInvitation* other) { + void UnsafeArenaSwap(AttachmentPointer* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3755,12 +4425,18 @@ class DataMessage_OpenGroupInvitation final : // implements Message ---------------------------------------------- - DataMessage_OpenGroupInvitation* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + AttachmentPointer* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_OpenGroupInvitation& from); - void MergeFrom(const DataMessage_OpenGroupInvitation& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const AttachmentPointer& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const AttachmentPointer& from) { + AttachmentPointer::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3773,30 +4449,179 @@ class DataMessage_OpenGroupInvitation final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_OpenGroupInvitation* other); + void SetCachedSize(int size) const final; + void InternalSwap(AttachmentPointer* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.OpenGroupInvitation"; + return "SessionProtos.AttachmentPointer"; } protected: - explicit DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef AttachmentPointer_Flags Flags; + static constexpr Flags VOICE_MESSAGE = + AttachmentPointer_Flags_VOICE_MESSAGE; + static inline bool Flags_IsValid(int value) { + return AttachmentPointer_Flags_IsValid(value); + } + static constexpr Flags Flags_MIN = + AttachmentPointer_Flags_Flags_MIN; + static constexpr Flags Flags_MAX = + AttachmentPointer_Flags_Flags_MAX; + static constexpr int Flags_ARRAYSIZE = + AttachmentPointer_Flags_Flags_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Flags_descriptor() { + return AttachmentPointer_Flags_descriptor(); + } + template + static inline const std::string& Flags_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Flags_Name."); + return AttachmentPointer_Flags_Name(enum_t_value); + } + static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Flags* value) { + return AttachmentPointer_Flags_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kUrlFieldNumber = 1, - kNameFieldNumber = 3, + kContentTypeFieldNumber = 2, + kKeyFieldNumber = 3, + kThumbnailFieldNumber = 5, + kDigestFieldNumber = 6, + kFileNameFieldNumber = 7, + kCaptionFieldNumber = 11, + kUrlFieldNumber = 101, + kIdFieldNumber = 1, + kSizeFieldNumber = 4, + kFlagsFieldNumber = 8, + kWidthFieldNumber = 9, + kHeightFieldNumber = 10, }; - // required string url = 1; + // optional string contentType = 2; + bool has_contenttype() const; + private: + bool _internal_has_contenttype() const; + public: + void clear_contenttype(); + const std::string& contenttype() const; + template + void set_contenttype(ArgT0&& arg0, ArgT... args); + std::string* mutable_contenttype(); + PROTOBUF_NODISCARD std::string* release_contenttype(); + void set_allocated_contenttype(std::string* contenttype); + private: + const std::string& _internal_contenttype() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); + std::string* _internal_mutable_contenttype(); + public: + + // optional bytes key = 3; + bool has_key() const; + private: + bool _internal_has_key() const; + public: + void clear_key(); + const std::string& key() const; + template + void set_key(ArgT0&& arg0, ArgT... args); + std::string* mutable_key(); + PROTOBUF_NODISCARD std::string* release_key(); + void set_allocated_key(std::string* key); + private: + const std::string& _internal_key() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_key(const std::string& value); + std::string* _internal_mutable_key(); + public: + + // optional bytes thumbnail = 5; + bool has_thumbnail() const; + private: + bool _internal_has_thumbnail() const; + public: + void clear_thumbnail(); + const std::string& thumbnail() const; + template + void set_thumbnail(ArgT0&& arg0, ArgT... args); + std::string* mutable_thumbnail(); + PROTOBUF_NODISCARD std::string* release_thumbnail(); + void set_allocated_thumbnail(std::string* thumbnail); + private: + const std::string& _internal_thumbnail() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_thumbnail(const std::string& value); + std::string* _internal_mutable_thumbnail(); + public: + + // optional bytes digest = 6; + bool has_digest() const; + private: + bool _internal_has_digest() const; + public: + void clear_digest(); + const std::string& digest() const; + template + void set_digest(ArgT0&& arg0, ArgT... args); + std::string* mutable_digest(); + PROTOBUF_NODISCARD std::string* release_digest(); + void set_allocated_digest(std::string* digest); + private: + const std::string& _internal_digest() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_digest(const std::string& value); + std::string* _internal_mutable_digest(); + public: + + // optional string fileName = 7; + bool has_filename() const; + private: + bool _internal_has_filename() const; + public: + void clear_filename(); + const std::string& filename() const; + template + void set_filename(ArgT0&& arg0, ArgT... args); + std::string* mutable_filename(); + PROTOBUF_NODISCARD std::string* release_filename(); + void set_allocated_filename(std::string* filename); + private: + const std::string& _internal_filename() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); + std::string* _internal_mutable_filename(); + public: + + // optional string caption = 11; + bool has_caption() const; + private: + bool _internal_has_caption() const; + public: + void clear_caption(); + const std::string& caption() const; + template + void set_caption(ArgT0&& arg0, ArgT... args); + std::string* mutable_caption(); + PROTOBUF_NODISCARD std::string* release_caption(); + void set_allocated_caption(std::string* caption); + private: + const std::string& _internal_caption() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_caption(const std::string& value); + std::string* _internal_mutable_caption(); + public: + + // optional string url = 101; bool has_url() const; private: bool _internal_has_url() const; @@ -3814,63 +4639,117 @@ class DataMessage_OpenGroupInvitation final : std::string* _internal_mutable_url(); public: - // required string name = 3; - bool has_name() const; + // required fixed64 id = 1; + bool has_id() const; private: - bool _internal_has_name() const; + bool _internal_has_id() const; public: - void clear_name(); - const std::string& name() const; - template - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); + void clear_id(); + uint64_t id() const; + void set_id(uint64_t value); private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); + uint64_t _internal_id() const; + void _internal_set_id(uint64_t value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.OpenGroupInvitation) + // optional uint32 size = 4; + bool has_size() const; + private: + bool _internal_has_size() const; + public: + void clear_size(); + uint32_t size() const; + void set_size(uint32_t value); + private: + uint32_t _internal_size() const; + void _internal_set_size(uint32_t value); + public: + + // optional uint32 flags = 8; + bool has_flags() const; + private: + bool _internal_has_flags() const; + public: + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); + private: + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); + public: + + // optional uint32 width = 9; + bool has_width() const; + private: + bool _internal_has_width() const; + public: + void clear_width(); + uint32_t width() const; + void set_width(uint32_t value); + private: + uint32_t _internal_width() const; + void _internal_set_width(uint32_t value); + public: + + // optional uint32 height = 10; + bool has_height() const; + private: + bool _internal_has_height() const; + public: + void clear_height(); + uint32_t height() const; + void set_height(uint32_t value); + private: + uint32_t _internal_height() const; + void _internal_set_height(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.AttachmentPointer) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr key_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr thumbnail_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr digest_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr caption_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + uint64_t id_; + uint32_t size_; + uint32_t flags_; + uint32_t width_; + uint32_t height_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) */ { +class SharedConfigMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.SharedConfigMessage) */ { public: - inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper() : DataMessage_ClosedGroupControlMessage_KeyPairWrapper(nullptr) {} - ~DataMessage_ClosedGroupControlMessage_KeyPairWrapper() override; - explicit PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline SharedConfigMessage() : SharedConfigMessage(nullptr) {} + ~SharedConfigMessage() override; + explicit PROTOBUF_CONSTEXPR SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_ClosedGroupControlMessage_KeyPairWrapper(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); - DataMessage_ClosedGroupControlMessage_KeyPairWrapper(DataMessage_ClosedGroupControlMessage_KeyPairWrapper&& from) noexcept - : DataMessage_ClosedGroupControlMessage_KeyPairWrapper() { + SharedConfigMessage(const SharedConfigMessage& from); + SharedConfigMessage(SharedConfigMessage&& from) noexcept + : SharedConfigMessage() { *this = ::std::move(from); } - inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper& operator=(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from) { + inline SharedConfigMessage& operator=(const SharedConfigMessage& from) { CopyFrom(from); return *this; } - inline DataMessage_ClosedGroupControlMessage_KeyPairWrapper& operator=(DataMessage_ClosedGroupControlMessage_KeyPairWrapper&& from) noexcept { + inline SharedConfigMessage& operator=(SharedConfigMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -3884,27 +4763,36 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const SharedConfigMessage& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_ClosedGroupControlMessage_KeyPairWrapper* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_ClosedGroupControlMessage_KeyPairWrapper_default_instance_); + static inline const SharedConfigMessage* internal_default_instance() { + return reinterpret_cast( + &_SharedConfigMessage_default_instance_); } static constexpr int kIndexInFileMessages = 17; - friend void swap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper& a, DataMessage_ClosedGroupControlMessage_KeyPairWrapper& b) { + friend void swap(SharedConfigMessage& a, SharedConfigMessage& b) { a.Swap(&b); } - inline void Swap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { + inline void Swap(SharedConfigMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -3917,7 +4805,7 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other) { + void UnsafeArenaSwap(SharedConfigMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -3925,12 +4813,18 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : // implements Message ---------------------------------------------- - DataMessage_ClosedGroupControlMessage_KeyPairWrapper* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + SharedConfigMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const SharedConfigMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const SharedConfigMessage& from) { + SharedConfigMessage::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); - void MergeFrom(const DataMessage_ClosedGroupControlMessage_KeyPairWrapper& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3943,66 +4837,112 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_ClosedGroupControlMessage_KeyPairWrapper* other); + void SetCachedSize(int size) const final; + void InternalSwap(SharedConfigMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper"; + return "SessionProtos.SharedConfigMessage"; } protected: - explicit DataMessage_ClosedGroupControlMessage_KeyPairWrapper(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef SharedConfigMessage_Kind Kind; + static constexpr Kind USER_PROFILE = + SharedConfigMessage_Kind_USER_PROFILE; + static constexpr Kind CONTACTS = + SharedConfigMessage_Kind_CONTACTS; + static constexpr Kind CONVO_INFO_VOLATILE = + SharedConfigMessage_Kind_CONVO_INFO_VOLATILE; + static constexpr Kind USER_GROUPS = + SharedConfigMessage_Kind_USER_GROUPS; + static inline bool Kind_IsValid(int value) { + return SharedConfigMessage_Kind_IsValid(value); + } + static constexpr Kind Kind_MIN = + SharedConfigMessage_Kind_Kind_MIN; + static constexpr Kind Kind_MAX = + SharedConfigMessage_Kind_Kind_MAX; + static constexpr int Kind_ARRAYSIZE = + SharedConfigMessage_Kind_Kind_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Kind_descriptor() { + return SharedConfigMessage_Kind_descriptor(); + } + template + static inline const std::string& Kind_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Kind_Name."); + return SharedConfigMessage_Kind_Name(enum_t_value); + } + static inline bool Kind_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Kind* value) { + return SharedConfigMessage_Kind_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kPublicKeyFieldNumber = 1, - kEncryptedKeyPairFieldNumber = 2, + kDataFieldNumber = 3, + kSeqnoFieldNumber = 2, + kKindFieldNumber = 1, }; - // required bytes publicKey = 1; - bool has_publickey() const; + // required bytes data = 3; + bool has_data() const; private: - bool _internal_has_publickey() const; + bool _internal_has_data() const; public: - void clear_publickey(); - const std::string& publickey() const; + void clear_data(); + const std::string& data() const; template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); + void set_data(ArgT0&& arg0, ArgT... args); + std::string* mutable_data(); + PROTOBUF_NODISCARD std::string* release_data(); + void set_allocated_data(std::string* data); private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); + const std::string& _internal_data() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_data(const std::string& value); + std::string* _internal_mutable_data(); + public: + + // required int64 seqno = 2; + bool has_seqno() const; + private: + bool _internal_has_seqno() const; + public: + void clear_seqno(); + int64_t seqno() const; + void set_seqno(int64_t value); + private: + int64_t _internal_seqno() const; + void _internal_set_seqno(int64_t value); public: - // required bytes encryptedKeyPair = 2; - bool has_encryptedkeypair() const; + // required .SessionProtos.SharedConfigMessage.Kind kind = 1; + bool has_kind() const; private: - bool _internal_has_encryptedkeypair() const; + bool _internal_has_kind() const; public: - void clear_encryptedkeypair(); - const std::string& encryptedkeypair() const; - template - void set_encryptedkeypair(ArgT0&& arg0, ArgT... args); - std::string* mutable_encryptedkeypair(); - PROTOBUF_NODISCARD std::string* release_encryptedkeypair(); - void set_allocated_encryptedkeypair(std::string* encryptedkeypair); + void clear_kind(); + ::SessionProtos::SharedConfigMessage_Kind kind() const; + void set_kind(::SessionProtos::SharedConfigMessage_Kind value); private: - const std::string& _internal_encryptedkeypair() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_encryptedkeypair(const std::string& value); - std::string* _internal_mutable_encryptedkeypair(); + ::SessionProtos::SharedConfigMessage_Kind _internal_kind() const; + void _internal_set_kind(::SessionProtos::SharedConfigMessage_Kind value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper) + // @@protoc_insertion_point(class_scope:SessionProtos.SharedConfigMessage) private: class _Internal; @@ -4015,32 +4955,33 @@ class DataMessage_ClosedGroupControlMessage_KeyPairWrapper final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr encryptedkeypair_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr data_; + int64_t seqno_; + int kind_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage_ClosedGroupControlMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.ClosedGroupControlMessage) */ { +class GroupUpdateMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMessage) */ { public: - inline DataMessage_ClosedGroupControlMessage() : DataMessage_ClosedGroupControlMessage(nullptr) {} - ~DataMessage_ClosedGroupControlMessage() override; - explicit PROTOBUF_CONSTEXPR DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateMessage() : GroupUpdateMessage(nullptr) {} + ~GroupUpdateMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdateMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage_ClosedGroupControlMessage(const DataMessage_ClosedGroupControlMessage& from); - DataMessage_ClosedGroupControlMessage(DataMessage_ClosedGroupControlMessage&& from) noexcept - : DataMessage_ClosedGroupControlMessage() { + GroupUpdateMessage(const GroupUpdateMessage& from); + GroupUpdateMessage(GroupUpdateMessage&& from) noexcept + : GroupUpdateMessage() { *this = ::std::move(from); } - inline DataMessage_ClosedGroupControlMessage& operator=(const DataMessage_ClosedGroupControlMessage& from) { + inline GroupUpdateMessage& operator=(const GroupUpdateMessage& from) { CopyFrom(from); return *this; } - inline DataMessage_ClosedGroupControlMessage& operator=(DataMessage_ClosedGroupControlMessage&& from) noexcept { + inline GroupUpdateMessage& operator=(GroupUpdateMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -4054,27 +4995,36 @@ class DataMessage_ClosedGroupControlMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage_ClosedGroupControlMessage& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateMessage& default_instance() { return *internal_default_instance(); } - static inline const DataMessage_ClosedGroupControlMessage* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_ClosedGroupControlMessage_default_instance_); + static inline const GroupUpdateMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateMessage_default_instance_); } static constexpr int kIndexInFileMessages = 18; - friend void swap(DataMessage_ClosedGroupControlMessage& a, DataMessage_ClosedGroupControlMessage& b) { + friend void swap(GroupUpdateMessage& a, GroupUpdateMessage& b) { a.Swap(&b); } - inline void Swap(DataMessage_ClosedGroupControlMessage* other) { + inline void Swap(GroupUpdateMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -4087,7 +5037,7 @@ class DataMessage_ClosedGroupControlMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage_ClosedGroupControlMessage* other) { + void UnsafeArenaSwap(GroupUpdateMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -4095,12 +5045,18 @@ class DataMessage_ClosedGroupControlMessage final : // implements Message ---------------------------------------------- - DataMessage_ClosedGroupControlMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdateMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdateMessage& from) { + GroupUpdateMessage::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage_ClosedGroupControlMessage& from); - void MergeFrom(const DataMessage_ClosedGroupControlMessage& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4113,220 +5069,183 @@ class DataMessage_ClosedGroupControlMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage_ClosedGroupControlMessage* other); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdateMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage.ClosedGroupControlMessage"; + return "SessionProtos.GroupUpdateMessage"; } protected: - explicit DataMessage_ClosedGroupControlMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - // nested types ---------------------------------------------------- + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - typedef DataMessage_ClosedGroupControlMessage_KeyPairWrapper KeyPairWrapper; - - typedef DataMessage_ClosedGroupControlMessage_Type Type; - static constexpr Type NEW = - DataMessage_ClosedGroupControlMessage_Type_NEW; - static constexpr Type ENCRYPTION_KEY_PAIR = - DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR; - static constexpr Type NAME_CHANGE = - DataMessage_ClosedGroupControlMessage_Type_NAME_CHANGE; - static constexpr Type MEMBERS_ADDED = - DataMessage_ClosedGroupControlMessage_Type_MEMBERS_ADDED; - static constexpr Type MEMBERS_REMOVED = - DataMessage_ClosedGroupControlMessage_Type_MEMBERS_REMOVED; - static constexpr Type MEMBER_LEFT = - DataMessage_ClosedGroupControlMessage_Type_MEMBER_LEFT; - static constexpr Type ENCRYPTION_KEY_PAIR_REQUEST = - DataMessage_ClosedGroupControlMessage_Type_ENCRYPTION_KEY_PAIR_REQUEST; - static inline bool Type_IsValid(int value) { - return DataMessage_ClosedGroupControlMessage_Type_IsValid(value); - } - static constexpr Type Type_MIN = - DataMessage_ClosedGroupControlMessage_Type_Type_MIN; - static constexpr Type Type_MAX = - DataMessage_ClosedGroupControlMessage_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - DataMessage_ClosedGroupControlMessage_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return DataMessage_ClosedGroupControlMessage_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return DataMessage_ClosedGroupControlMessage_Type_Parse(name, value); - } + // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kMembersFieldNumber = 5, - kAdminsFieldNumber = 6, - kWrappersFieldNumber = 7, - kPublicKeyFieldNumber = 2, - kNameFieldNumber = 3, - kEncryptionKeyPairFieldNumber = 4, - kExpirationTimerFieldNumber = 8, - kTypeFieldNumber = 1, + kInviteMessageFieldNumber = 1, + kInfoChangeMessageFieldNumber = 2, + kMemberChangeMessageFieldNumber = 3, + kPromoteMessageFieldNumber = 4, + kMemberLeftMessageFieldNumber = 5, + kInviteResponseFieldNumber = 6, + kDeleteMemberContentFieldNumber = 7, + kMemberLeftNotificationMessageFieldNumber = 8, }; - // repeated bytes members = 5; - int members_size() const; - private: - int _internal_members_size() const; - public: - void clear_members(); - const std::string& members(int index) const; - std::string* mutable_members(int index); - void set_members(int index, const std::string& value); - void set_members(int index, std::string&& value); - void set_members(int index, const char* value); - void set_members(int index, const void* value, size_t size); - std::string* add_members(); - void add_members(const std::string& value); - void add_members(std::string&& value); - void add_members(const char* value); - void add_members(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& members() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_members(); - private: - const std::string& _internal_members(int index) const; - std::string* _internal_add_members(); - public: - - // repeated bytes admins = 6; - int admins_size() const; - private: - int _internal_admins_size() const; - public: - void clear_admins(); - const std::string& admins(int index) const; - std::string* mutable_admins(int index); - void set_admins(int index, const std::string& value); - void set_admins(int index, std::string&& value); - void set_admins(int index, const char* value); - void set_admins(int index, const void* value, size_t size); - std::string* add_admins(); - void add_admins(const std::string& value); - void add_admins(std::string&& value); - void add_admins(const char* value); - void add_admins(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& admins() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_admins(); - private: - const std::string& _internal_admins(int index) const; - std::string* _internal_add_admins(); - public: - - // repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; - int wrappers_size() const; - private: - int _internal_wrappers_size() const; - public: - void clear_wrappers(); - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* mutable_wrappers(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >* - mutable_wrappers(); - private: - const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& _internal_wrappers(int index) const; - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* _internal_add_wrappers(); - public: - const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& wrappers(int index) const; - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* add_wrappers(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >& - wrappers() const; - - // optional bytes publicKey = 2; - bool has_publickey() const; + // optional .SessionProtos.GroupUpdateInviteMessage inviteMessage = 1; + bool has_invitemessage() const; private: - bool _internal_has_publickey() const; + bool _internal_has_invitemessage() const; public: - void clear_publickey(); - const std::string& publickey() const; - template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); + void clear_invitemessage(); + const ::SessionProtos::GroupUpdateInviteMessage& invitemessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateInviteMessage* release_invitemessage(); + ::SessionProtos::GroupUpdateInviteMessage* mutable_invitemessage(); + void set_allocated_invitemessage(::SessionProtos::GroupUpdateInviteMessage* invitemessage); private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); + const ::SessionProtos::GroupUpdateInviteMessage& _internal_invitemessage() const; + ::SessionProtos::GroupUpdateInviteMessage* _internal_mutable_invitemessage(); public: + void unsafe_arena_set_allocated_invitemessage( + ::SessionProtos::GroupUpdateInviteMessage* invitemessage); + ::SessionProtos::GroupUpdateInviteMessage* unsafe_arena_release_invitemessage(); - // optional string name = 3; - bool has_name() const; + // optional .SessionProtos.GroupUpdateInfoChangeMessage infoChangeMessage = 2; + bool has_infochangemessage() const; private: - bool _internal_has_name() const; + bool _internal_has_infochangemessage() const; public: - void clear_name(); - const std::string& name() const; - template - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); + void clear_infochangemessage(); + const ::SessionProtos::GroupUpdateInfoChangeMessage& infochangemessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateInfoChangeMessage* release_infochangemessage(); + ::SessionProtos::GroupUpdateInfoChangeMessage* mutable_infochangemessage(); + void set_allocated_infochangemessage(::SessionProtos::GroupUpdateInfoChangeMessage* infochangemessage); private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); + const ::SessionProtos::GroupUpdateInfoChangeMessage& _internal_infochangemessage() const; + ::SessionProtos::GroupUpdateInfoChangeMessage* _internal_mutable_infochangemessage(); public: + void unsafe_arena_set_allocated_infochangemessage( + ::SessionProtos::GroupUpdateInfoChangeMessage* infochangemessage); + ::SessionProtos::GroupUpdateInfoChangeMessage* unsafe_arena_release_infochangemessage(); - // optional .SessionProtos.KeyPair encryptionKeyPair = 4; - bool has_encryptionkeypair() const; + // optional .SessionProtos.GroupUpdateMemberChangeMessage memberChangeMessage = 3; + bool has_memberchangemessage() const; private: - bool _internal_has_encryptionkeypair() const; + bool _internal_has_memberchangemessage() const; public: - void clear_encryptionkeypair(); - const ::SessionProtos::KeyPair& encryptionkeypair() const; - PROTOBUF_NODISCARD ::SessionProtos::KeyPair* release_encryptionkeypair(); - ::SessionProtos::KeyPair* mutable_encryptionkeypair(); - void set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair); + void clear_memberchangemessage(); + const ::SessionProtos::GroupUpdateMemberChangeMessage& memberchangemessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateMemberChangeMessage* release_memberchangemessage(); + ::SessionProtos::GroupUpdateMemberChangeMessage* mutable_memberchangemessage(); + void set_allocated_memberchangemessage(::SessionProtos::GroupUpdateMemberChangeMessage* memberchangemessage); private: - const ::SessionProtos::KeyPair& _internal_encryptionkeypair() const; - ::SessionProtos::KeyPair* _internal_mutable_encryptionkeypair(); + const ::SessionProtos::GroupUpdateMemberChangeMessage& _internal_memberchangemessage() const; + ::SessionProtos::GroupUpdateMemberChangeMessage* _internal_mutable_memberchangemessage(); public: - void unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair); - ::SessionProtos::KeyPair* unsafe_arena_release_encryptionkeypair(); + void unsafe_arena_set_allocated_memberchangemessage( + ::SessionProtos::GroupUpdateMemberChangeMessage* memberchangemessage); + ::SessionProtos::GroupUpdateMemberChangeMessage* unsafe_arena_release_memberchangemessage(); - // optional uint32 expirationTimer = 8; - bool has_expirationtimer() const; + // optional .SessionProtos.GroupUpdatePromoteMessage promoteMessage = 4; + bool has_promotemessage() const; private: - bool _internal_has_expirationtimer() const; + bool _internal_has_promotemessage() const; public: - void clear_expirationtimer(); - uint32_t expirationtimer() const; - void set_expirationtimer(uint32_t value); + void clear_promotemessage(); + const ::SessionProtos::GroupUpdatePromoteMessage& promotemessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdatePromoteMessage* release_promotemessage(); + ::SessionProtos::GroupUpdatePromoteMessage* mutable_promotemessage(); + void set_allocated_promotemessage(::SessionProtos::GroupUpdatePromoteMessage* promotemessage); private: - uint32_t _internal_expirationtimer() const; - void _internal_set_expirationtimer(uint32_t value); + const ::SessionProtos::GroupUpdatePromoteMessage& _internal_promotemessage() const; + ::SessionProtos::GroupUpdatePromoteMessage* _internal_mutable_promotemessage(); public: + void unsafe_arena_set_allocated_promotemessage( + ::SessionProtos::GroupUpdatePromoteMessage* promotemessage); + ::SessionProtos::GroupUpdatePromoteMessage* unsafe_arena_release_promotemessage(); - // required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; - bool has_type() const; + // optional .SessionProtos.GroupUpdateMemberLeftMessage memberLeftMessage = 5; + bool has_memberleftmessage() const; private: - bool _internal_has_type() const; + bool _internal_has_memberleftmessage() const; public: - void clear_type(); - ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type type() const; - void set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value); + void clear_memberleftmessage(); + const ::SessionProtos::GroupUpdateMemberLeftMessage& memberleftmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateMemberLeftMessage* release_memberleftmessage(); + ::SessionProtos::GroupUpdateMemberLeftMessage* mutable_memberleftmessage(); + void set_allocated_memberleftmessage(::SessionProtos::GroupUpdateMemberLeftMessage* memberleftmessage); + private: + const ::SessionProtos::GroupUpdateMemberLeftMessage& _internal_memberleftmessage() const; + ::SessionProtos::GroupUpdateMemberLeftMessage* _internal_mutable_memberleftmessage(); + public: + void unsafe_arena_set_allocated_memberleftmessage( + ::SessionProtos::GroupUpdateMemberLeftMessage* memberleftmessage); + ::SessionProtos::GroupUpdateMemberLeftMessage* unsafe_arena_release_memberleftmessage(); + + // optional .SessionProtos.GroupUpdateInviteResponseMessage inviteResponse = 6; + bool has_inviteresponse() const; + private: + bool _internal_has_inviteresponse() const; + public: + void clear_inviteresponse(); + const ::SessionProtos::GroupUpdateInviteResponseMessage& inviteresponse() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateInviteResponseMessage* release_inviteresponse(); + ::SessionProtos::GroupUpdateInviteResponseMessage* mutable_inviteresponse(); + void set_allocated_inviteresponse(::SessionProtos::GroupUpdateInviteResponseMessage* inviteresponse); + private: + const ::SessionProtos::GroupUpdateInviteResponseMessage& _internal_inviteresponse() const; + ::SessionProtos::GroupUpdateInviteResponseMessage* _internal_mutable_inviteresponse(); + public: + void unsafe_arena_set_allocated_inviteresponse( + ::SessionProtos::GroupUpdateInviteResponseMessage* inviteresponse); + ::SessionProtos::GroupUpdateInviteResponseMessage* unsafe_arena_release_inviteresponse(); + + // optional .SessionProtos.GroupUpdateDeleteMemberContentMessage deleteMemberContent = 7; + bool has_deletemembercontent() const; + private: + bool _internal_has_deletemembercontent() const; + public: + void clear_deletemembercontent(); + const ::SessionProtos::GroupUpdateDeleteMemberContentMessage& deletemembercontent() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateDeleteMemberContentMessage* release_deletemembercontent(); + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* mutable_deletemembercontent(); + void set_allocated_deletemembercontent(::SessionProtos::GroupUpdateDeleteMemberContentMessage* deletemembercontent); + private: + const ::SessionProtos::GroupUpdateDeleteMemberContentMessage& _internal_deletemembercontent() const; + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* _internal_mutable_deletemembercontent(); + public: + void unsafe_arena_set_allocated_deletemembercontent( + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* deletemembercontent); + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* unsafe_arena_release_deletemembercontent(); + + // optional .SessionProtos.GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8; + bool has_memberleftnotificationmessage() const; + private: + bool _internal_has_memberleftnotificationmessage() const; + public: + void clear_memberleftnotificationmessage(); + const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage& memberleftnotificationmessage() const; + PROTOBUF_NODISCARD ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* release_memberleftnotificationmessage(); + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* mutable_memberleftnotificationmessage(); + void set_allocated_memberleftnotificationmessage(::SessionProtos::GroupUpdateMemberLeftNotificationMessage* memberleftnotificationmessage); private: - ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type _internal_type() const; - void _internal_set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value); + const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage& _internal_memberleftnotificationmessage() const; + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* _internal_mutable_memberleftnotificationmessage(); public: + void unsafe_arena_set_allocated_memberleftnotificationmessage( + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* memberleftnotificationmessage); + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* unsafe_arena_release_memberleftnotificationmessage(); - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage.ClosedGroupControlMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateMessage) private: class _Internal; @@ -4336,38 +5255,38 @@ class DataMessage_ClosedGroupControlMessage final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField members_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField admins_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper > wrappers_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::SessionProtos::KeyPair* encryptionkeypair_; - uint32_t expirationtimer_; - int type_; + ::SessionProtos::GroupUpdateInviteMessage* invitemessage_; + ::SessionProtos::GroupUpdateInfoChangeMessage* infochangemessage_; + ::SessionProtos::GroupUpdateMemberChangeMessage* memberchangemessage_; + ::SessionProtos::GroupUpdatePromoteMessage* promotemessage_; + ::SessionProtos::GroupUpdateMemberLeftMessage* memberleftmessage_; + ::SessionProtos::GroupUpdateInviteResponseMessage* inviteresponse_; + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* deletemembercontent_; + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* memberleftnotificationmessage_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class DataMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage) */ { +class GroupUpdateInviteMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInviteMessage) */ { public: - inline DataMessage() : DataMessage(nullptr) {} - ~DataMessage() override; - explicit PROTOBUF_CONSTEXPR DataMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateInviteMessage() : GroupUpdateInviteMessage(nullptr) {} + ~GroupUpdateInviteMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdateInviteMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - DataMessage(const DataMessage& from); - DataMessage(DataMessage&& from) noexcept - : DataMessage() { + GroupUpdateInviteMessage(const GroupUpdateInviteMessage& from); + GroupUpdateInviteMessage(GroupUpdateInviteMessage&& from) noexcept + : GroupUpdateInviteMessage() { *this = ::std::move(from); } - inline DataMessage& operator=(const DataMessage& from) { + inline GroupUpdateInviteMessage& operator=(const GroupUpdateInviteMessage& from) { CopyFrom(from); return *this; } - inline DataMessage& operator=(DataMessage&& from) noexcept { + inline GroupUpdateInviteMessage& operator=(GroupUpdateInviteMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -4381,27 +5300,36 @@ class DataMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const DataMessage& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateInviteMessage& default_instance() { return *internal_default_instance(); } - static inline const DataMessage* internal_default_instance() { - return reinterpret_cast( - &_DataMessage_default_instance_); + static inline const GroupUpdateInviteMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateInviteMessage_default_instance_); } static constexpr int kIndexInFileMessages = 19; - friend void swap(DataMessage& a, DataMessage& b) { + friend void swap(GroupUpdateInviteMessage& a, GroupUpdateInviteMessage& b) { a.Swap(&b); } - inline void Swap(DataMessage* other) { + inline void Swap(GroupUpdateInviteMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -4414,7 +5342,7 @@ class DataMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(DataMessage* other) { + void UnsafeArenaSwap(GroupUpdateInviteMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -4422,12 +5350,18 @@ class DataMessage final : // implements Message ---------------------------------------------- - DataMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateInviteMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const DataMessage& from); - void MergeFrom(const DataMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdateInviteMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdateInviteMessage& from) { + GroupUpdateInviteMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4440,351 +5374,147 @@ class DataMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(DataMessage* other); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdateInviteMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.DataMessage"; + return "SessionProtos.GroupUpdateInviteMessage"; } protected: - explicit DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateInviteMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; - - // nested types ---------------------------------------------------- + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - typedef DataMessage_Quote Quote; - typedef DataMessage_Preview Preview; - typedef DataMessage_Reaction Reaction; - typedef DataMessage_OpenGroupInvitation OpenGroupInvitation; - typedef DataMessage_ClosedGroupControlMessage ClosedGroupControlMessage; + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - typedef DataMessage_Flags Flags; - static constexpr Flags EXPIRATION_TIMER_UPDATE = - DataMessage_Flags_EXPIRATION_TIMER_UPDATE; - static inline bool Flags_IsValid(int value) { - return DataMessage_Flags_IsValid(value); - } - static constexpr Flags Flags_MIN = - DataMessage_Flags_Flags_MIN; - static constexpr Flags Flags_MAX = - DataMessage_Flags_Flags_MAX; - static constexpr int Flags_ARRAYSIZE = - DataMessage_Flags_Flags_ARRAYSIZE; - template - static inline const std::string& Flags_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Flags_Name."); - return DataMessage_Flags_Name(enum_t_value); - } - static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Flags* value) { - return DataMessage_Flags_Parse(name, value); - } + // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kAttachmentsFieldNumber = 2, - kPreviewFieldNumber = 10, - kBodyFieldNumber = 1, - kProfileKeyFieldNumber = 6, - kSyncTargetFieldNumber = 105, - kQuoteFieldNumber = 8, - kReactionFieldNumber = 11, - kProfileFieldNumber = 101, - kOpenGroupInvitationFieldNumber = 102, - kClosedGroupControlMessageFieldNumber = 104, - kFlagsFieldNumber = 4, - kExpireTimerFieldNumber = 5, - kTimestampFieldNumber = 7, - kBlocksCommunityMessageRequestsFieldNumber = 106, + kGroupSessionIdFieldNumber = 1, + kNameFieldNumber = 2, + kMemberAuthDataFieldNumber = 3, + kAdminSignatureFieldNumber = 4, }; - // repeated .SessionProtos.AttachmentPointer attachments = 2; - int attachments_size() const; - private: - int _internal_attachments_size() const; - public: - void clear_attachments(); - ::SessionProtos::AttachmentPointer* mutable_attachments(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >* - mutable_attachments(); - private: - const ::SessionProtos::AttachmentPointer& _internal_attachments(int index) const; - ::SessionProtos::AttachmentPointer* _internal_add_attachments(); - public: - const ::SessionProtos::AttachmentPointer& attachments(int index) const; - ::SessionProtos::AttachmentPointer* add_attachments(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer >& - attachments() const; - - // repeated .SessionProtos.DataMessage.Preview preview = 10; - int preview_size() const; + // required string groupSessionId = 1; + bool has_groupsessionid() const; private: - int _internal_preview_size() const; + bool _internal_has_groupsessionid() const; public: - void clear_preview(); - ::SessionProtos::DataMessage_Preview* mutable_preview(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >* - mutable_preview(); + void clear_groupsessionid(); + const std::string& groupsessionid() const; + template + void set_groupsessionid(ArgT0&& arg0, ArgT... args); + std::string* mutable_groupsessionid(); + PROTOBUF_NODISCARD std::string* release_groupsessionid(); + void set_allocated_groupsessionid(std::string* groupsessionid); private: - const ::SessionProtos::DataMessage_Preview& _internal_preview(int index) const; - ::SessionProtos::DataMessage_Preview* _internal_add_preview(); + const std::string& _internal_groupsessionid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_groupsessionid(const std::string& value); + std::string* _internal_mutable_groupsessionid(); public: - const ::SessionProtos::DataMessage_Preview& preview(int index) const; - ::SessionProtos::DataMessage_Preview* add_preview(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview >& - preview() const; - // optional string body = 1; - bool has_body() const; + // required string name = 2; + bool has_name() const; private: - bool _internal_has_body() const; + bool _internal_has_name() const; public: - void clear_body(); - const std::string& body() const; + void clear_name(); + const std::string& name() const; template - void set_body(ArgT0&& arg0, ArgT... args); - std::string* mutable_body(); - PROTOBUF_NODISCARD std::string* release_body(); - void set_allocated_body(std::string* body); + void set_name(ArgT0&& arg0, ArgT... args); + std::string* mutable_name(); + PROTOBUF_NODISCARD std::string* release_name(); + void set_allocated_name(std::string* name); private: - const std::string& _internal_body() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_body(const std::string& value); - std::string* _internal_mutable_body(); + const std::string& _internal_name() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); public: - // optional bytes profileKey = 6; - bool has_profilekey() const; + // required bytes memberAuthData = 3; + bool has_memberauthdata() const; private: - bool _internal_has_profilekey() const; + bool _internal_has_memberauthdata() const; public: - void clear_profilekey(); - const std::string& profilekey() const; + void clear_memberauthdata(); + const std::string& memberauthdata() const; template - void set_profilekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilekey(); - PROTOBUF_NODISCARD std::string* release_profilekey(); - void set_allocated_profilekey(std::string* profilekey); + void set_memberauthdata(ArgT0&& arg0, ArgT... args); + std::string* mutable_memberauthdata(); + PROTOBUF_NODISCARD std::string* release_memberauthdata(); + void set_allocated_memberauthdata(std::string* memberauthdata); private: - const std::string& _internal_profilekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); - std::string* _internal_mutable_profilekey(); + const std::string& _internal_memberauthdata() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_memberauthdata(const std::string& value); + std::string* _internal_mutable_memberauthdata(); public: - // optional string syncTarget = 105; - bool has_synctarget() const; + // required bytes adminSignature = 4; + bool has_adminsignature() const; private: - bool _internal_has_synctarget() const; + bool _internal_has_adminsignature() const; public: - void clear_synctarget(); - const std::string& synctarget() const; + void clear_adminsignature(); + const std::string& adminsignature() const; template - void set_synctarget(ArgT0&& arg0, ArgT... args); - std::string* mutable_synctarget(); - PROTOBUF_NODISCARD std::string* release_synctarget(); - void set_allocated_synctarget(std::string* synctarget); + void set_adminsignature(ArgT0&& arg0, ArgT... args); + std::string* mutable_adminsignature(); + PROTOBUF_NODISCARD std::string* release_adminsignature(); + void set_allocated_adminsignature(std::string* adminsignature); private: - const std::string& _internal_synctarget() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_synctarget(const std::string& value); - std::string* _internal_mutable_synctarget(); + const std::string& _internal_adminsignature() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_adminsignature(const std::string& value); + std::string* _internal_mutable_adminsignature(); public: - // optional .SessionProtos.DataMessage.Quote quote = 8; - bool has_quote() const; - private: - bool _internal_has_quote() const; - public: - void clear_quote(); - const ::SessionProtos::DataMessage_Quote& quote() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Quote* release_quote(); - ::SessionProtos::DataMessage_Quote* mutable_quote(); - void set_allocated_quote(::SessionProtos::DataMessage_Quote* quote); - private: - const ::SessionProtos::DataMessage_Quote& _internal_quote() const; - ::SessionProtos::DataMessage_Quote* _internal_mutable_quote(); - public: - void unsafe_arena_set_allocated_quote( - ::SessionProtos::DataMessage_Quote* quote); - ::SessionProtos::DataMessage_Quote* unsafe_arena_release_quote(); + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateInviteMessage) + private: + class _Internal; - // optional .SessionProtos.DataMessage.Reaction reaction = 11; - bool has_reaction() const; - private: - bool _internal_has_reaction() const; - public: - void clear_reaction(); - const ::SessionProtos::DataMessage_Reaction& reaction() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_Reaction* release_reaction(); - ::SessionProtos::DataMessage_Reaction* mutable_reaction(); - void set_allocated_reaction(::SessionProtos::DataMessage_Reaction* reaction); - private: - const ::SessionProtos::DataMessage_Reaction& _internal_reaction() const; - ::SessionProtos::DataMessage_Reaction* _internal_mutable_reaction(); - public: - void unsafe_arena_set_allocated_reaction( - ::SessionProtos::DataMessage_Reaction* reaction); - ::SessionProtos::DataMessage_Reaction* unsafe_arena_release_reaction(); + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; - // optional .SessionProtos.LokiProfile profile = 101; - bool has_profile() const; - private: - bool _internal_has_profile() const; - public: - void clear_profile(); - const ::SessionProtos::LokiProfile& profile() const; - PROTOBUF_NODISCARD ::SessionProtos::LokiProfile* release_profile(); - ::SessionProtos::LokiProfile* mutable_profile(); - void set_allocated_profile(::SessionProtos::LokiProfile* profile); - private: - const ::SessionProtos::LokiProfile& _internal_profile() const; - ::SessionProtos::LokiProfile* _internal_mutable_profile(); - public: - void unsafe_arena_set_allocated_profile( - ::SessionProtos::LokiProfile* profile); - ::SessionProtos::LokiProfile* unsafe_arena_release_profile(); + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr groupsessionid_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr memberauthdata_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr adminsignature_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- - // optional .SessionProtos.DataMessage.OpenGroupInvitation openGroupInvitation = 102; - bool has_opengroupinvitation() const; - private: - bool _internal_has_opengroupinvitation() const; - public: - void clear_opengroupinvitation(); - const ::SessionProtos::DataMessage_OpenGroupInvitation& opengroupinvitation() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_OpenGroupInvitation* release_opengroupinvitation(); - ::SessionProtos::DataMessage_OpenGroupInvitation* mutable_opengroupinvitation(); - void set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); - private: - const ::SessionProtos::DataMessage_OpenGroupInvitation& _internal_opengroupinvitation() const; - ::SessionProtos::DataMessage_OpenGroupInvitation* _internal_mutable_opengroupinvitation(); - public: - void unsafe_arena_set_allocated_opengroupinvitation( - ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation); - ::SessionProtos::DataMessage_OpenGroupInvitation* unsafe_arena_release_opengroupinvitation(); - - // optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; - bool has_closedgroupcontrolmessage() const; - private: - bool _internal_has_closedgroupcontrolmessage() const; - public: - void clear_closedgroupcontrolmessage(); - const ::SessionProtos::DataMessage_ClosedGroupControlMessage& closedgroupcontrolmessage() const; - PROTOBUF_NODISCARD ::SessionProtos::DataMessage_ClosedGroupControlMessage* release_closedgroupcontrolmessage(); - ::SessionProtos::DataMessage_ClosedGroupControlMessage* mutable_closedgroupcontrolmessage(); - void set_allocated_closedgroupcontrolmessage(::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage); - private: - const ::SessionProtos::DataMessage_ClosedGroupControlMessage& _internal_closedgroupcontrolmessage() const; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* _internal_mutable_closedgroupcontrolmessage(); - public: - void unsafe_arena_set_allocated_closedgroupcontrolmessage( - ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage); - ::SessionProtos::DataMessage_ClosedGroupControlMessage* unsafe_arena_release_closedgroupcontrolmessage(); - - // optional uint32 flags = 4; - bool has_flags() const; - private: - bool _internal_has_flags() const; - public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); - private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); - public: - - // optional uint32 expireTimer = 5; - bool has_expiretimer() const; - private: - bool _internal_has_expiretimer() const; - public: - void clear_expiretimer(); - uint32_t expiretimer() const; - void set_expiretimer(uint32_t value); - private: - uint32_t _internal_expiretimer() const; - void _internal_set_expiretimer(uint32_t value); - public: - - // optional uint64 timestamp = 7; - bool has_timestamp() const; - private: - bool _internal_has_timestamp() const; - public: - void clear_timestamp(); - uint64_t timestamp() const; - void set_timestamp(uint64_t value); - private: - uint64_t _internal_timestamp() const; - void _internal_set_timestamp(uint64_t value); - public: - - // optional bool blocksCommunityMessageRequests = 106; - bool has_blockscommunitymessagerequests() const; - private: - bool _internal_has_blockscommunitymessagerequests() const; - public: - void clear_blockscommunitymessagerequests(); - bool blockscommunitymessagerequests() const; - void set_blockscommunitymessagerequests(bool value); - private: - bool _internal_blockscommunitymessagerequests() const; - void _internal_set_blockscommunitymessagerequests(bool value); - public: - - // @@protoc_insertion_point(class_scope:SessionProtos.DataMessage) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::AttachmentPointer > attachments_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_Preview > preview_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr body_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr synctarget_; - ::SessionProtos::DataMessage_Quote* quote_; - ::SessionProtos::DataMessage_Reaction* reaction_; - ::SessionProtos::LokiProfile* profile_; - ::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation_; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage_; - uint32_t flags_; - uint32_t expiretimer_; - uint64_t timestamp_; - bool blockscommunitymessagerequests_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_SessionProtos_2eproto; -}; -// ------------------------------------------------------------------- - -class ConfigurationMessage_ClosedGroup final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.ClosedGroup) */ { +class GroupUpdatePromoteMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdatePromoteMessage) */ { public: - inline ConfigurationMessage_ClosedGroup() : ConfigurationMessage_ClosedGroup(nullptr) {} - ~ConfigurationMessage_ClosedGroup() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdatePromoteMessage() : GroupUpdatePromoteMessage(nullptr) {} + ~GroupUpdatePromoteMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdatePromoteMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage_ClosedGroup(const ConfigurationMessage_ClosedGroup& from); - ConfigurationMessage_ClosedGroup(ConfigurationMessage_ClosedGroup&& from) noexcept - : ConfigurationMessage_ClosedGroup() { + GroupUpdatePromoteMessage(const GroupUpdatePromoteMessage& from); + GroupUpdatePromoteMessage(GroupUpdatePromoteMessage&& from) noexcept + : GroupUpdatePromoteMessage() { *this = ::std::move(from); } - inline ConfigurationMessage_ClosedGroup& operator=(const ConfigurationMessage_ClosedGroup& from) { + inline GroupUpdatePromoteMessage& operator=(const GroupUpdatePromoteMessage& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage_ClosedGroup& operator=(ConfigurationMessage_ClosedGroup&& from) noexcept { + inline GroupUpdatePromoteMessage& operator=(GroupUpdatePromoteMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -4798,27 +5528,36 @@ class ConfigurationMessage_ClosedGroup final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ConfigurationMessage_ClosedGroup& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdatePromoteMessage& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage_ClosedGroup* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_ClosedGroup_default_instance_); + static inline const GroupUpdatePromoteMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdatePromoteMessage_default_instance_); } static constexpr int kIndexInFileMessages = 20; - friend void swap(ConfigurationMessage_ClosedGroup& a, ConfigurationMessage_ClosedGroup& b) { + friend void swap(GroupUpdatePromoteMessage& a, GroupUpdatePromoteMessage& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage_ClosedGroup* other) { + inline void Swap(GroupUpdatePromoteMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -4831,7 +5570,7 @@ class ConfigurationMessage_ClosedGroup final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage_ClosedGroup* other) { + void UnsafeArenaSwap(GroupUpdatePromoteMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -4839,12 +5578,18 @@ class ConfigurationMessage_ClosedGroup final : // implements Message ---------------------------------------------- - ConfigurationMessage_ClosedGroup* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdatePromoteMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdatePromoteMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdatePromoteMessage& from) { + GroupUpdatePromoteMessage::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage_ClosedGroup& from); - void MergeFrom(const ConfigurationMessage_ClosedGroup& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4857,100 +5602,51 @@ class ConfigurationMessage_ClosedGroup final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage_ClosedGroup* other); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdatePromoteMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage.ClosedGroup"; + return "SessionProtos.GroupUpdatePromoteMessage"; } protected: - explicit ConfigurationMessage_ClosedGroup(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdatePromoteMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kMembersFieldNumber = 4, - kAdminsFieldNumber = 5, - kPublicKeyFieldNumber = 1, + kGroupIdentitySeedFieldNumber = 1, kNameFieldNumber = 2, - kEncryptionKeyPairFieldNumber = 3, - kExpirationTimerFieldNumber = 6, }; - // repeated bytes members = 4; - int members_size() const; - private: - int _internal_members_size() const; - public: - void clear_members(); - const std::string& members(int index) const; - std::string* mutable_members(int index); - void set_members(int index, const std::string& value); - void set_members(int index, std::string&& value); - void set_members(int index, const char* value); - void set_members(int index, const void* value, size_t size); - std::string* add_members(); - void add_members(const std::string& value); - void add_members(std::string&& value); - void add_members(const char* value); - void add_members(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& members() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_members(); - private: - const std::string& _internal_members(int index) const; - std::string* _internal_add_members(); - public: - - // repeated bytes admins = 5; - int admins_size() const; - private: - int _internal_admins_size() const; - public: - void clear_admins(); - const std::string& admins(int index) const; - std::string* mutable_admins(int index); - void set_admins(int index, const std::string& value); - void set_admins(int index, std::string&& value); - void set_admins(int index, const char* value); - void set_admins(int index, const void* value, size_t size); - std::string* add_admins(); - void add_admins(const std::string& value); - void add_admins(std::string&& value); - void add_admins(const char* value); - void add_admins(const void* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& admins() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_admins(); - private: - const std::string& _internal_admins(int index) const; - std::string* _internal_add_admins(); - public: - - // optional bytes publicKey = 1; - bool has_publickey() const; + // required bytes groupIdentitySeed = 1; + bool has_groupidentityseed() const; private: - bool _internal_has_publickey() const; + bool _internal_has_groupidentityseed() const; public: - void clear_publickey(); - const std::string& publickey() const; + void clear_groupidentityseed(); + const std::string& groupidentityseed() const; template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); + void set_groupidentityseed(ArgT0&& arg0, ArgT... args); + std::string* mutable_groupidentityseed(); + PROTOBUF_NODISCARD std::string* release_groupidentityseed(); + void set_allocated_groupidentityseed(std::string* groupidentityseed); private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); + const std::string& _internal_groupidentityseed() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_groupidentityseed(const std::string& value); + std::string* _internal_mutable_groupidentityseed(); public: - // optional string name = 2; + // required string name = 2; bool has_name() const; private: bool _internal_has_name() const; @@ -4968,77 +5664,45 @@ class ConfigurationMessage_ClosedGroup final : std::string* _internal_mutable_name(); public: - // optional .SessionProtos.KeyPair encryptionKeyPair = 3; - bool has_encryptionkeypair() const; - private: - bool _internal_has_encryptionkeypair() const; - public: - void clear_encryptionkeypair(); - const ::SessionProtos::KeyPair& encryptionkeypair() const; - PROTOBUF_NODISCARD ::SessionProtos::KeyPair* release_encryptionkeypair(); - ::SessionProtos::KeyPair* mutable_encryptionkeypair(); - void set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair); - private: - const ::SessionProtos::KeyPair& _internal_encryptionkeypair() const; - ::SessionProtos::KeyPair* _internal_mutable_encryptionkeypair(); - public: - void unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair); - ::SessionProtos::KeyPair* unsafe_arena_release_encryptionkeypair(); - - // optional uint32 expirationTimer = 6; - bool has_expirationtimer() const; - private: - bool _internal_has_expirationtimer() const; - public: - void clear_expirationtimer(); - uint32_t expirationtimer() const; - void set_expirationtimer(uint32_t value); - private: - uint32_t _internal_expirationtimer() const; - void _internal_set_expirationtimer(uint32_t value); - public: - - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.ClosedGroup) + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdatePromoteMessage) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField members_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField admins_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr groupidentityseed_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::SessionProtos::KeyPair* encryptionkeypair_; - uint32_t expirationtimer_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ConfigurationMessage_Contact final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage.Contact) */ { +class GroupUpdateInfoChangeMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInfoChangeMessage) */ { public: - inline ConfigurationMessage_Contact() : ConfigurationMessage_Contact(nullptr) {} - ~ConfigurationMessage_Contact() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateInfoChangeMessage() : GroupUpdateInfoChangeMessage(nullptr) {} + ~GroupUpdateInfoChangeMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdateInfoChangeMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage_Contact(const ConfigurationMessage_Contact& from); - ConfigurationMessage_Contact(ConfigurationMessage_Contact&& from) noexcept - : ConfigurationMessage_Contact() { + GroupUpdateInfoChangeMessage(const GroupUpdateInfoChangeMessage& from); + GroupUpdateInfoChangeMessage(GroupUpdateInfoChangeMessage&& from) noexcept + : GroupUpdateInfoChangeMessage() { *this = ::std::move(from); } - inline ConfigurationMessage_Contact& operator=(const ConfigurationMessage_Contact& from) { + inline GroupUpdateInfoChangeMessage& operator=(const GroupUpdateInfoChangeMessage& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage_Contact& operator=(ConfigurationMessage_Contact&& from) noexcept { + inline GroupUpdateInfoChangeMessage& operator=(GroupUpdateInfoChangeMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5052,27 +5716,36 @@ class ConfigurationMessage_Contact final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ConfigurationMessage_Contact& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateInfoChangeMessage& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage_Contact* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_Contact_default_instance_); + static inline const GroupUpdateInfoChangeMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateInfoChangeMessage_default_instance_); } static constexpr int kIndexInFileMessages = 21; - friend void swap(ConfigurationMessage_Contact& a, ConfigurationMessage_Contact& b) { + friend void swap(GroupUpdateInfoChangeMessage& a, GroupUpdateInfoChangeMessage& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage_Contact* other) { + inline void Swap(GroupUpdateInfoChangeMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5085,7 +5758,7 @@ class ConfigurationMessage_Contact final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage_Contact* other) { + void UnsafeArenaSwap(GroupUpdateInfoChangeMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5093,12 +5766,18 @@ class ConfigurationMessage_Contact final : // implements Message ---------------------------------------------- - ConfigurationMessage_Contact* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateInfoChangeMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdateInfoChangeMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdateInfoChangeMessage& from) { + GroupUpdateInfoChangeMessage::MergeImpl(*this, from); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage_Contact& from); - void MergeFrom(const ConfigurationMessage_Contact& from); + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5111,146 +5790,129 @@ class ConfigurationMessage_Contact final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage_Contact* other); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdateInfoChangeMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage.Contact"; + return "SessionProtos.GroupUpdateInfoChangeMessage"; } protected: - explicit ConfigurationMessage_Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateInfoChangeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- + typedef GroupUpdateInfoChangeMessage_Type Type; + static constexpr Type NAME = + GroupUpdateInfoChangeMessage_Type_NAME; + static constexpr Type AVATAR = + GroupUpdateInfoChangeMessage_Type_AVATAR; + static constexpr Type DISAPPEARING_MESSAGES = + GroupUpdateInfoChangeMessage_Type_DISAPPEARING_MESSAGES; + static inline bool Type_IsValid(int value) { + return GroupUpdateInfoChangeMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + GroupUpdateInfoChangeMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + GroupUpdateInfoChangeMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + GroupUpdateInfoChangeMessage_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return GroupUpdateInfoChangeMessage_Type_descriptor(); + } + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return GroupUpdateInfoChangeMessage_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return GroupUpdateInfoChangeMessage_Type_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { - kPublicKeyFieldNumber = 1, - kNameFieldNumber = 2, - kProfilePictureFieldNumber = 3, - kProfileKeyFieldNumber = 4, - kIsApprovedFieldNumber = 5, - kIsBlockedFieldNumber = 6, - kDidApproveMeFieldNumber = 7, + kUpdatedNameFieldNumber = 2, + kAdminSignatureFieldNumber = 4, + kUpdatedExpirationFieldNumber = 3, + kTypeFieldNumber = 1, }; - // required bytes publicKey = 1; - bool has_publickey() const; - private: - bool _internal_has_publickey() const; - public: - void clear_publickey(); - const std::string& publickey() const; - template - void set_publickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_publickey(); - PROTOBUF_NODISCARD std::string* release_publickey(); - void set_allocated_publickey(std::string* publickey); - private: - const std::string& _internal_publickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_publickey(const std::string& value); - std::string* _internal_mutable_publickey(); - public: - - // required string name = 2; - bool has_name() const; - private: - bool _internal_has_name() const; - public: - void clear_name(); - const std::string& name() const; - template - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); + // optional string updatedName = 2; + bool has_updatedname() const; private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // optional string profilePicture = 3; - bool has_profilepicture() const; - private: - bool _internal_has_profilepicture() const; + bool _internal_has_updatedname() const; public: - void clear_profilepicture(); - const std::string& profilepicture() const; + void clear_updatedname(); + const std::string& updatedname() const; template - void set_profilepicture(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilepicture(); - PROTOBUF_NODISCARD std::string* release_profilepicture(); - void set_allocated_profilepicture(std::string* profilepicture); + void set_updatedname(ArgT0&& arg0, ArgT... args); + std::string* mutable_updatedname(); + PROTOBUF_NODISCARD std::string* release_updatedname(); + void set_allocated_updatedname(std::string* updatedname); private: - const std::string& _internal_profilepicture() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); - std::string* _internal_mutable_profilepicture(); + const std::string& _internal_updatedname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_updatedname(const std::string& value); + std::string* _internal_mutable_updatedname(); public: - // optional bytes profileKey = 4; - bool has_profilekey() const; + // required bytes adminSignature = 4; + bool has_adminsignature() const; private: - bool _internal_has_profilekey() const; + bool _internal_has_adminsignature() const; public: - void clear_profilekey(); - const std::string& profilekey() const; + void clear_adminsignature(); + const std::string& adminsignature() const; template - void set_profilekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilekey(); - PROTOBUF_NODISCARD std::string* release_profilekey(); - void set_allocated_profilekey(std::string* profilekey); - private: - const std::string& _internal_profilekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); - std::string* _internal_mutable_profilekey(); - public: - - // optional bool isApproved = 5; - bool has_isapproved() const; + void set_adminsignature(ArgT0&& arg0, ArgT... args); + std::string* mutable_adminsignature(); + PROTOBUF_NODISCARD std::string* release_adminsignature(); + void set_allocated_adminsignature(std::string* adminsignature); private: - bool _internal_has_isapproved() const; - public: - void clear_isapproved(); - bool isapproved() const; - void set_isapproved(bool value); - private: - bool _internal_isapproved() const; - void _internal_set_isapproved(bool value); + const std::string& _internal_adminsignature() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_adminsignature(const std::string& value); + std::string* _internal_mutable_adminsignature(); public: - // optional bool isBlocked = 6; - bool has_isblocked() const; + // optional uint32 updatedExpiration = 3; + bool has_updatedexpiration() const; private: - bool _internal_has_isblocked() const; + bool _internal_has_updatedexpiration() const; public: - void clear_isblocked(); - bool isblocked() const; - void set_isblocked(bool value); + void clear_updatedexpiration(); + uint32_t updatedexpiration() const; + void set_updatedexpiration(uint32_t value); private: - bool _internal_isblocked() const; - void _internal_set_isblocked(bool value); + uint32_t _internal_updatedexpiration() const; + void _internal_set_updatedexpiration(uint32_t value); public: - // optional bool didApproveMe = 7; - bool has_didapproveme() const; + // required .SessionProtos.GroupUpdateInfoChangeMessage.Type type = 1; + bool has_type() const; private: - bool _internal_has_didapproveme() const; + bool _internal_has_type() const; public: - void clear_didapproveme(); - bool didapproveme() const; - void set_didapproveme(bool value); + void clear_type(); + ::SessionProtos::GroupUpdateInfoChangeMessage_Type type() const; + void set_type(::SessionProtos::GroupUpdateInfoChangeMessage_Type value); private: - bool _internal_didapproveme() const; - void _internal_set_didapproveme(bool value); + ::SessionProtos::GroupUpdateInfoChangeMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::GroupUpdateInfoChangeMessage_Type value); public: - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage.Contact) + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateInfoChangeMessage) private: class _Internal; @@ -5263,37 +5925,34 @@ class ConfigurationMessage_Contact final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr publickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; - bool isapproved_; - bool isblocked_; - bool didapproveme_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr updatedname_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr adminsignature_; + uint32_t updatedexpiration_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ConfigurationMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ConfigurationMessage) */ { +class GroupUpdateMemberChangeMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberChangeMessage) */ { public: - inline ConfigurationMessage() : ConfigurationMessage(nullptr) {} - ~ConfigurationMessage() override; - explicit PROTOBUF_CONSTEXPR ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateMemberChangeMessage() : GroupUpdateMemberChangeMessage(nullptr) {} + ~GroupUpdateMemberChangeMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdateMemberChangeMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ConfigurationMessage(const ConfigurationMessage& from); - ConfigurationMessage(ConfigurationMessage&& from) noexcept - : ConfigurationMessage() { + GroupUpdateMemberChangeMessage(const GroupUpdateMemberChangeMessage& from); + GroupUpdateMemberChangeMessage(GroupUpdateMemberChangeMessage&& from) noexcept + : GroupUpdateMemberChangeMessage() { *this = ::std::move(from); } - inline ConfigurationMessage& operator=(const ConfigurationMessage& from) { + inline GroupUpdateMemberChangeMessage& operator=(const GroupUpdateMemberChangeMessage& from) { CopyFrom(from); return *this; } - inline ConfigurationMessage& operator=(ConfigurationMessage&& from) noexcept { + inline GroupUpdateMemberChangeMessage& operator=(GroupUpdateMemberChangeMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5307,27 +5966,36 @@ class ConfigurationMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ConfigurationMessage& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateMemberChangeMessage& default_instance() { return *internal_default_instance(); } - static inline const ConfigurationMessage* internal_default_instance() { - return reinterpret_cast( - &_ConfigurationMessage_default_instance_); + static inline const GroupUpdateMemberChangeMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateMemberChangeMessage_default_instance_); } static constexpr int kIndexInFileMessages = 22; - friend void swap(ConfigurationMessage& a, ConfigurationMessage& b) { + friend void swap(GroupUpdateMemberChangeMessage& a, GroupUpdateMemberChangeMessage& b) { a.Swap(&b); } - inline void Swap(ConfigurationMessage* other) { + inline void Swap(GroupUpdateMemberChangeMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5340,7 +6008,7 @@ class ConfigurationMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ConfigurationMessage* other) { + void UnsafeArenaSwap(GroupUpdateMemberChangeMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5348,12 +6016,18 @@ class ConfigurationMessage final : // implements Message ---------------------------------------------- - ConfigurationMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateMemberChangeMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ConfigurationMessage& from); - void MergeFrom(const ConfigurationMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdateMemberChangeMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdateMemberChangeMessage& from) { + GroupUpdateMemberChangeMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5366,210 +6040,174 @@ class ConfigurationMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ConfigurationMessage* other); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdateMemberChangeMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ConfigurationMessage"; + return "SessionProtos.GroupUpdateMemberChangeMessage"; } protected: - explicit ConfigurationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateMemberChangeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- - typedef ConfigurationMessage_ClosedGroup ClosedGroup; - typedef ConfigurationMessage_Contact Contact; + typedef GroupUpdateMemberChangeMessage_Type Type; + static constexpr Type ADDED = + GroupUpdateMemberChangeMessage_Type_ADDED; + static constexpr Type REMOVED = + GroupUpdateMemberChangeMessage_Type_REMOVED; + static constexpr Type PROMOTED = + GroupUpdateMemberChangeMessage_Type_PROMOTED; + static inline bool Type_IsValid(int value) { + return GroupUpdateMemberChangeMessage_Type_IsValid(value); + } + static constexpr Type Type_MIN = + GroupUpdateMemberChangeMessage_Type_Type_MIN; + static constexpr Type Type_MAX = + GroupUpdateMemberChangeMessage_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + GroupUpdateMemberChangeMessage_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return GroupUpdateMemberChangeMessage_Type_descriptor(); + } + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return GroupUpdateMemberChangeMessage_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return GroupUpdateMemberChangeMessage_Type_Parse(name, value); + } // accessors ------------------------------------------------------- enum : int { - kClosedGroupsFieldNumber = 1, - kOpenGroupsFieldNumber = 2, - kContactsFieldNumber = 6, - kDisplayNameFieldNumber = 3, - kProfilePictureFieldNumber = 4, - kProfileKeyFieldNumber = 5, - kProConfigFieldNumber = 7, + kMemberSessionIdsFieldNumber = 2, + kAdminSignatureFieldNumber = 4, + kHistorySharedFieldNumber = 3, + kTypeFieldNumber = 1, }; - // repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; - int closedgroups_size() const; + // repeated string memberSessionIds = 2; + int membersessionids_size() const; private: - int _internal_closedgroups_size() const; + int _internal_membersessionids_size() const; public: - void clear_closedgroups(); - ::SessionProtos::ConfigurationMessage_ClosedGroup* mutable_closedgroups(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >* - mutable_closedgroups(); + void clear_membersessionids(); + const std::string& membersessionids(int index) const; + std::string* mutable_membersessionids(int index); + void set_membersessionids(int index, const std::string& value); + void set_membersessionids(int index, std::string&& value); + void set_membersessionids(int index, const char* value); + void set_membersessionids(int index, const char* value, size_t size); + std::string* add_membersessionids(); + void add_membersessionids(const std::string& value); + void add_membersessionids(std::string&& value); + void add_membersessionids(const char* value); + void add_membersessionids(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& membersessionids() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_membersessionids(); private: - const ::SessionProtos::ConfigurationMessage_ClosedGroup& _internal_closedgroups(int index) const; - ::SessionProtos::ConfigurationMessage_ClosedGroup* _internal_add_closedgroups(); + const std::string& _internal_membersessionids(int index) const; + std::string* _internal_add_membersessionids(); public: - const ::SessionProtos::ConfigurationMessage_ClosedGroup& closedgroups(int index) const; - ::SessionProtos::ConfigurationMessage_ClosedGroup* add_closedgroups(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >& - closedgroups() const; - // repeated string openGroups = 2; - int opengroups_size() const; + // required bytes adminSignature = 4; + bool has_adminsignature() const; private: - int _internal_opengroups_size() const; + bool _internal_has_adminsignature() const; public: - void clear_opengroups(); - const std::string& opengroups(int index) const; - std::string* mutable_opengroups(int index); - void set_opengroups(int index, const std::string& value); - void set_opengroups(int index, std::string&& value); - void set_opengroups(int index, const char* value); - void set_opengroups(int index, const char* value, size_t size); - std::string* add_opengroups(); - void add_opengroups(const std::string& value); - void add_opengroups(std::string&& value); - void add_opengroups(const char* value); - void add_opengroups(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& opengroups() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_opengroups(); + void clear_adminsignature(); + const std::string& adminsignature() const; + template + void set_adminsignature(ArgT0&& arg0, ArgT... args); + std::string* mutable_adminsignature(); + PROTOBUF_NODISCARD std::string* release_adminsignature(); + void set_allocated_adminsignature(std::string* adminsignature); private: - const std::string& _internal_opengroups(int index) const; - std::string* _internal_add_opengroups(); + const std::string& _internal_adminsignature() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_adminsignature(const std::string& value); + std::string* _internal_mutable_adminsignature(); public: - // repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; - int contacts_size() const; + // optional bool historyShared = 3; + bool has_historyshared() const; private: - int _internal_contacts_size() const; + bool _internal_has_historyshared() const; public: - void clear_contacts(); - ::SessionProtos::ConfigurationMessage_Contact* mutable_contacts(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >* - mutable_contacts(); + void clear_historyshared(); + bool historyshared() const; + void set_historyshared(bool value); private: - const ::SessionProtos::ConfigurationMessage_Contact& _internal_contacts(int index) const; - ::SessionProtos::ConfigurationMessage_Contact* _internal_add_contacts(); + bool _internal_historyshared() const; + void _internal_set_historyshared(bool value); public: - const ::SessionProtos::ConfigurationMessage_Contact& contacts(int index) const; - ::SessionProtos::ConfigurationMessage_Contact* add_contacts(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >& - contacts() const; - // optional string displayName = 3; - bool has_displayname() const; + // required .SessionProtos.GroupUpdateMemberChangeMessage.Type type = 1; + bool has_type() const; private: - bool _internal_has_displayname() const; + bool _internal_has_type() const; public: - void clear_displayname(); - const std::string& displayname() const; - template - void set_displayname(ArgT0&& arg0, ArgT... args); - std::string* mutable_displayname(); - PROTOBUF_NODISCARD std::string* release_displayname(); - void set_allocated_displayname(std::string* displayname); - private: - const std::string& _internal_displayname() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_displayname(const std::string& value); - std::string* _internal_mutable_displayname(); - public: - - // optional string profilePicture = 4; - bool has_profilepicture() const; - private: - bool _internal_has_profilepicture() const; - public: - void clear_profilepicture(); - const std::string& profilepicture() const; - template - void set_profilepicture(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilepicture(); - PROTOBUF_NODISCARD std::string* release_profilepicture(); - void set_allocated_profilepicture(std::string* profilepicture); - private: - const std::string& _internal_profilepicture() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilepicture(const std::string& value); - std::string* _internal_mutable_profilepicture(); - public: - - // optional bytes profileKey = 5; - bool has_profilekey() const; - private: - bool _internal_has_profilekey() const; - public: - void clear_profilekey(); - const std::string& profilekey() const; - template - void set_profilekey(ArgT0&& arg0, ArgT... args); - std::string* mutable_profilekey(); - PROTOBUF_NODISCARD std::string* release_profilekey(); - void set_allocated_profilekey(std::string* profilekey); - private: - const std::string& _internal_profilekey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_profilekey(const std::string& value); - std::string* _internal_mutable_profilekey(); - public: - - // optional .SessionProtos.ProConfig proConfig = 7; - bool has_proconfig() const; - private: - bool _internal_has_proconfig() const; - public: - void clear_proconfig(); - const ::SessionProtos::ProConfig& proconfig() const; - PROTOBUF_NODISCARD ::SessionProtos::ProConfig* release_proconfig(); - ::SessionProtos::ProConfig* mutable_proconfig(); - void set_allocated_proconfig(::SessionProtos::ProConfig* proconfig); + void clear_type(); + ::SessionProtos::GroupUpdateMemberChangeMessage_Type type() const; + void set_type(::SessionProtos::GroupUpdateMemberChangeMessage_Type value); private: - const ::SessionProtos::ProConfig& _internal_proconfig() const; - ::SessionProtos::ProConfig* _internal_mutable_proconfig(); + ::SessionProtos::GroupUpdateMemberChangeMessage_Type _internal_type() const; + void _internal_set_type(::SessionProtos::GroupUpdateMemberChangeMessage_Type value); public: - void unsafe_arena_set_allocated_proconfig( - ::SessionProtos::ProConfig* proconfig); - ::SessionProtos::ProConfig* unsafe_arena_release_proconfig(); - // @@protoc_insertion_point(class_scope:SessionProtos.ConfigurationMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateMemberChangeMessage) private: class _Internal; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup > closedgroups_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField opengroups_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact > contacts_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr displayname_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilepicture_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr profilekey_; - ::SessionProtos::ProConfig* proconfig_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField membersessionids_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr adminsignature_; + bool historyshared_; + int type_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class ReceiptMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ReceiptMessage) */ { +class GroupUpdateMemberLeftMessage final : + public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberLeftMessage) */ { public: - inline ReceiptMessage() : ReceiptMessage(nullptr) {} - ~ReceiptMessage() override; - explicit PROTOBUF_CONSTEXPR ReceiptMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateMemberLeftMessage() : GroupUpdateMemberLeftMessage(nullptr) {} + explicit PROTOBUF_CONSTEXPR GroupUpdateMemberLeftMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ReceiptMessage(const ReceiptMessage& from); - ReceiptMessage(ReceiptMessage&& from) noexcept - : ReceiptMessage() { + GroupUpdateMemberLeftMessage(const GroupUpdateMemberLeftMessage& from); + GroupUpdateMemberLeftMessage(GroupUpdateMemberLeftMessage&& from) noexcept + : GroupUpdateMemberLeftMessage() { *this = ::std::move(from); } - inline ReceiptMessage& operator=(const ReceiptMessage& from) { + inline GroupUpdateMemberLeftMessage& operator=(const GroupUpdateMemberLeftMessage& from) { CopyFrom(from); return *this; } - inline ReceiptMessage& operator=(ReceiptMessage&& from) noexcept { + inline GroupUpdateMemberLeftMessage& operator=(GroupUpdateMemberLeftMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5583,27 +6221,36 @@ class ReceiptMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const ReceiptMessage& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateMemberLeftMessage& default_instance() { return *internal_default_instance(); } - static inline const ReceiptMessage* internal_default_instance() { - return reinterpret_cast( - &_ReceiptMessage_default_instance_); + static inline const GroupUpdateMemberLeftMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateMemberLeftMessage_default_instance_); } static constexpr int kIndexInFileMessages = 23; - friend void swap(ReceiptMessage& a, ReceiptMessage& b) { + friend void swap(GroupUpdateMemberLeftMessage& a, GroupUpdateMemberLeftMessage& b) { a.Swap(&b); } - inline void Swap(ReceiptMessage* other) { + inline void Swap(GroupUpdateMemberLeftMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5616,7 +6263,7 @@ class ReceiptMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ReceiptMessage* other) { + void UnsafeArenaSwap(GroupUpdateMemberLeftMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5624,109 +6271,39 @@ class ReceiptMessage final : // implements Message ---------------------------------------------- - ReceiptMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateMemberLeftMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const ReceiptMessage& from); - void MergeFrom(const ReceiptMessage& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - uint8_t* _InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(ReceiptMessage* other); + using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; + inline void CopyFrom(const GroupUpdateMemberLeftMessage& from) { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); + } + using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; + void MergeFrom(const GroupUpdateMemberLeftMessage& from) { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); + } + public: private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ReceiptMessage"; + return "SessionProtos.GroupUpdateMemberLeftMessage"; } protected: - explicit ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateMemberLeftMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - // nested types ---------------------------------------------------- + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - typedef ReceiptMessage_Type Type; - static constexpr Type DELIVERY = - ReceiptMessage_Type_DELIVERY; - static constexpr Type READ = - ReceiptMessage_Type_READ; - static inline bool Type_IsValid(int value) { - return ReceiptMessage_Type_IsValid(value); - } - static constexpr Type Type_MIN = - ReceiptMessage_Type_Type_MIN; - static constexpr Type Type_MAX = - ReceiptMessage_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - ReceiptMessage_Type_Type_ARRAYSIZE; - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return ReceiptMessage_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return ReceiptMessage_Type_Parse(name, value); - } + // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - enum : int { - kTimestampFieldNumber = 2, - kTypeFieldNumber = 1, - }; - // repeated uint64 timestamp = 2; - int timestamp_size() const; - private: - int _internal_timestamp_size() const; - public: - void clear_timestamp(); - private: - uint64_t _internal_timestamp(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& - _internal_timestamp() const; - void _internal_add_timestamp(uint64_t value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* - _internal_mutable_timestamp(); - public: - uint64_t timestamp(int index) const; - void set_timestamp(int index, uint64_t value); - void add_timestamp(uint64_t value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& - timestamp() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* - mutable_timestamp(); - - // required .SessionProtos.ReceiptMessage.Type type = 1; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - ::SessionProtos::ReceiptMessage_Type type() const; - void set_type(::SessionProtos::ReceiptMessage_Type value); - private: - ::SessionProtos::ReceiptMessage_Type _internal_type() const; - void _internal_set_type(::SessionProtos::ReceiptMessage_Type value); - public: - - // @@protoc_insertion_point(class_scope:SessionProtos.ReceiptMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateMemberLeftMessage) private: class _Internal; @@ -5734,34 +6311,28 @@ class ReceiptMessage final : typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t > timestamp_; - int type_; }; - union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class AttachmentPointer final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.AttachmentPointer) */ { +class GroupUpdateMemberLeftNotificationMessage final : + public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberLeftNotificationMessage) */ { public: - inline AttachmentPointer() : AttachmentPointer(nullptr) {} - ~AttachmentPointer() override; - explicit PROTOBUF_CONSTEXPR AttachmentPointer(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateMemberLeftNotificationMessage() : GroupUpdateMemberLeftNotificationMessage(nullptr) {} + explicit PROTOBUF_CONSTEXPR GroupUpdateMemberLeftNotificationMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - AttachmentPointer(const AttachmentPointer& from); - AttachmentPointer(AttachmentPointer&& from) noexcept - : AttachmentPointer() { + GroupUpdateMemberLeftNotificationMessage(const GroupUpdateMemberLeftNotificationMessage& from); + GroupUpdateMemberLeftNotificationMessage(GroupUpdateMemberLeftNotificationMessage&& from) noexcept + : GroupUpdateMemberLeftNotificationMessage() { *this = ::std::move(from); } - inline AttachmentPointer& operator=(const AttachmentPointer& from) { + inline GroupUpdateMemberLeftNotificationMessage& operator=(const GroupUpdateMemberLeftNotificationMessage& from) { CopyFrom(from); return *this; } - inline AttachmentPointer& operator=(AttachmentPointer&& from) noexcept { + inline GroupUpdateMemberLeftNotificationMessage& operator=(GroupUpdateMemberLeftNotificationMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -5775,27 +6346,36 @@ class AttachmentPointer final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const AttachmentPointer& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateMemberLeftNotificationMessage& default_instance() { return *internal_default_instance(); } - static inline const AttachmentPointer* internal_default_instance() { - return reinterpret_cast( - &_AttachmentPointer_default_instance_); + static inline const GroupUpdateMemberLeftNotificationMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateMemberLeftNotificationMessage_default_instance_); } static constexpr int kIndexInFileMessages = 24; - friend void swap(AttachmentPointer& a, AttachmentPointer& b) { + friend void swap(GroupUpdateMemberLeftNotificationMessage& a, GroupUpdateMemberLeftNotificationMessage& b) { a.Swap(&b); } - inline void Swap(AttachmentPointer* other) { + inline void Swap(GroupUpdateMemberLeftNotificationMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -5808,7 +6388,7 @@ class AttachmentPointer final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(AttachmentPointer* other) { + void UnsafeArenaSwap(GroupUpdateMemberLeftNotificationMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -5816,318 +6396,69 @@ class AttachmentPointer final : // implements Message ---------------------------------------------- - AttachmentPointer* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateMemberLeftNotificationMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const AttachmentPointer& from); - void MergeFrom(const AttachmentPointer& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - uint8_t* _InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(AttachmentPointer* other); + using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; + inline void CopyFrom(const GroupUpdateMemberLeftNotificationMessage& from) { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); + } + using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; + void MergeFrom(const GroupUpdateMemberLeftNotificationMessage& from) { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); + } + public: private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.AttachmentPointer"; + return "SessionProtos.GroupUpdateMemberLeftNotificationMessage"; } protected: - explicit AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateMemberLeftNotificationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - // nested types ---------------------------------------------------- + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - typedef AttachmentPointer_Flags Flags; - static constexpr Flags VOICE_MESSAGE = - AttachmentPointer_Flags_VOICE_MESSAGE; - static inline bool Flags_IsValid(int value) { - return AttachmentPointer_Flags_IsValid(value); - } - static constexpr Flags Flags_MIN = - AttachmentPointer_Flags_Flags_MIN; - static constexpr Flags Flags_MAX = - AttachmentPointer_Flags_Flags_MAX; - static constexpr int Flags_ARRAYSIZE = - AttachmentPointer_Flags_Flags_ARRAYSIZE; - template - static inline const std::string& Flags_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Flags_Name."); - return AttachmentPointer_Flags_Name(enum_t_value); - } - static inline bool Flags_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Flags* value) { - return AttachmentPointer_Flags_Parse(name, value); - } + // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - enum : int { - kContentTypeFieldNumber = 2, - kKeyFieldNumber = 3, - kThumbnailFieldNumber = 5, - kDigestFieldNumber = 6, - kFileNameFieldNumber = 7, - kCaptionFieldNumber = 11, - kUrlFieldNumber = 101, - kIdFieldNumber = 1, - kSizeFieldNumber = 4, - kFlagsFieldNumber = 8, - kWidthFieldNumber = 9, - kHeightFieldNumber = 10, + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { }; - // optional string contentType = 2; - bool has_contenttype() const; - private: - bool _internal_has_contenttype() const; - public: - void clear_contenttype(); - const std::string& contenttype() const; - template - void set_contenttype(ArgT0&& arg0, ArgT... args); - std::string* mutable_contenttype(); - PROTOBUF_NODISCARD std::string* release_contenttype(); - void set_allocated_contenttype(std::string* contenttype); - private: - const std::string& _internal_contenttype() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_contenttype(const std::string& value); - std::string* _internal_mutable_contenttype(); - public: - - // optional bytes key = 3; - bool has_key() const; - private: - bool _internal_has_key() const; - public: - void clear_key(); - const std::string& key() const; - template - void set_key(ArgT0&& arg0, ArgT... args); - std::string* mutable_key(); - PROTOBUF_NODISCARD std::string* release_key(); - void set_allocated_key(std::string* key); - private: - const std::string& _internal_key() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_key(const std::string& value); - std::string* _internal_mutable_key(); - public: - - // optional bytes thumbnail = 5; - bool has_thumbnail() const; - private: - bool _internal_has_thumbnail() const; - public: - void clear_thumbnail(); - const std::string& thumbnail() const; - template - void set_thumbnail(ArgT0&& arg0, ArgT... args); - std::string* mutable_thumbnail(); - PROTOBUF_NODISCARD std::string* release_thumbnail(); - void set_allocated_thumbnail(std::string* thumbnail); - private: - const std::string& _internal_thumbnail() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_thumbnail(const std::string& value); - std::string* _internal_mutable_thumbnail(); - public: - - // optional bytes digest = 6; - bool has_digest() const; - private: - bool _internal_has_digest() const; - public: - void clear_digest(); - const std::string& digest() const; - template - void set_digest(ArgT0&& arg0, ArgT... args); - std::string* mutable_digest(); - PROTOBUF_NODISCARD std::string* release_digest(); - void set_allocated_digest(std::string* digest); - private: - const std::string& _internal_digest() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_digest(const std::string& value); - std::string* _internal_mutable_digest(); - public: - - // optional string fileName = 7; - bool has_filename() const; - private: - bool _internal_has_filename() const; - public: - void clear_filename(); - const std::string& filename() const; - template - void set_filename(ArgT0&& arg0, ArgT... args); - std::string* mutable_filename(); - PROTOBUF_NODISCARD std::string* release_filename(); - void set_allocated_filename(std::string* filename); - private: - const std::string& _internal_filename() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_filename(const std::string& value); - std::string* _internal_mutable_filename(); - public: - - // optional string caption = 11; - bool has_caption() const; - private: - bool _internal_has_caption() const; - public: - void clear_caption(); - const std::string& caption() const; - template - void set_caption(ArgT0&& arg0, ArgT... args); - std::string* mutable_caption(); - PROTOBUF_NODISCARD std::string* release_caption(); - void set_allocated_caption(std::string* caption); - private: - const std::string& _internal_caption() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_caption(const std::string& value); - std::string* _internal_mutable_caption(); - public: - - // optional string url = 101; - bool has_url() const; - private: - bool _internal_has_url() const; - public: - void clear_url(); - const std::string& url() const; - template - void set_url(ArgT0&& arg0, ArgT... args); - std::string* mutable_url(); - PROTOBUF_NODISCARD std::string* release_url(); - void set_allocated_url(std::string* url); - private: - const std::string& _internal_url() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); - std::string* _internal_mutable_url(); - public: - - // required fixed64 id = 1; - bool has_id() const; - private: - bool _internal_has_id() const; - public: - void clear_id(); - uint64_t id() const; - void set_id(uint64_t value); - private: - uint64_t _internal_id() const; - void _internal_set_id(uint64_t value); - public: - - // optional uint32 size = 4; - bool has_size() const; - private: - bool _internal_has_size() const; - public: - void clear_size(); - uint32_t size() const; - void set_size(uint32_t value); - private: - uint32_t _internal_size() const; - void _internal_set_size(uint32_t value); - public: - - // optional uint32 flags = 8; - bool has_flags() const; - private: - bool _internal_has_flags() const; - public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); - private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); - public: - - // optional uint32 width = 9; - bool has_width() const; - private: - bool _internal_has_width() const; - public: - void clear_width(); - uint32_t width() const; - void set_width(uint32_t value); - private: - uint32_t _internal_width() const; - void _internal_set_width(uint32_t value); - public: - - // optional uint32 height = 10; - bool has_height() const; - private: - bool _internal_has_height() const; - public: - void clear_height(); - uint32_t height() const; - void set_height(uint32_t value); - private: - uint32_t _internal_height() const; - void _internal_set_height(uint32_t value); - public: - - // @@protoc_insertion_point(class_scope:SessionProtos.AttachmentPointer) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr contenttype_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr key_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr thumbnail_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr digest_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr caption_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; - uint64_t id_; - uint32_t size_; - uint32_t flags_; - uint32_t width_; - uint32_t height_; - }; - union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- -class SharedConfigMessage final : - public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.SharedConfigMessage) */ { +class GroupUpdateInviteResponseMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInviteResponseMessage) */ { public: - inline SharedConfigMessage() : SharedConfigMessage(nullptr) {} - ~SharedConfigMessage() override; - explicit PROTOBUF_CONSTEXPR SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + inline GroupUpdateInviteResponseMessage() : GroupUpdateInviteResponseMessage(nullptr) {} + ~GroupUpdateInviteResponseMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdateInviteResponseMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - SharedConfigMessage(const SharedConfigMessage& from); - SharedConfigMessage(SharedConfigMessage&& from) noexcept - : SharedConfigMessage() { + GroupUpdateInviteResponseMessage(const GroupUpdateInviteResponseMessage& from); + GroupUpdateInviteResponseMessage(GroupUpdateInviteResponseMessage&& from) noexcept + : GroupUpdateInviteResponseMessage() { *this = ::std::move(from); } - inline SharedConfigMessage& operator=(const SharedConfigMessage& from) { + inline GroupUpdateInviteResponseMessage& operator=(const GroupUpdateInviteResponseMessage& from) { CopyFrom(from); return *this; } - inline SharedConfigMessage& operator=(SharedConfigMessage&& from) noexcept { + inline GroupUpdateInviteResponseMessage& operator=(GroupUpdateInviteResponseMessage&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -6141,27 +6472,36 @@ class SharedConfigMessage final : return *this; } - inline const std::string& unknown_fields() const { - return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - inline std::string* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } - static const SharedConfigMessage& default_instance() { + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateInviteResponseMessage& default_instance() { return *internal_default_instance(); } - static inline const SharedConfigMessage* internal_default_instance() { - return reinterpret_cast( - &_SharedConfigMessage_default_instance_); + static inline const GroupUpdateInviteResponseMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateInviteResponseMessage_default_instance_); } static constexpr int kIndexInFileMessages = 25; - friend void swap(SharedConfigMessage& a, SharedConfigMessage& b) { + friend void swap(GroupUpdateInviteResponseMessage& a, GroupUpdateInviteResponseMessage& b) { a.Swap(&b); } - inline void Swap(SharedConfigMessage* other) { + inline void Swap(GroupUpdateInviteResponseMessage* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -6174,7 +6514,7 @@ class SharedConfigMessage final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(SharedConfigMessage* other) { + void UnsafeArenaSwap(GroupUpdateInviteResponseMessage* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -6182,12 +6522,18 @@ class SharedConfigMessage final : // implements Message ---------------------------------------------- - SharedConfigMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); + GroupUpdateInviteResponseMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; - void CopyFrom(const SharedConfigMessage& from); - void MergeFrom(const SharedConfigMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdateInviteResponseMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdateInviteResponseMessage& from) { + GroupUpdateInviteResponseMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6200,120 +6546,272 @@ class SharedConfigMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const; - void InternalSwap(SharedConfigMessage* other); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdateInviteResponseMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.SharedConfigMessage"; + return "SessionProtos.GroupUpdateInviteResponseMessage"; } protected: - explicit SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit GroupUpdateInviteResponseMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - std::string GetTypeName() const final; + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- - typedef SharedConfigMessage_Kind Kind; - static constexpr Kind USER_PROFILE = - SharedConfigMessage_Kind_USER_PROFILE; - static constexpr Kind CONTACTS = - SharedConfigMessage_Kind_CONTACTS; - static constexpr Kind CONVO_INFO_VOLATILE = - SharedConfigMessage_Kind_CONVO_INFO_VOLATILE; - static constexpr Kind USER_GROUPS = - SharedConfigMessage_Kind_USER_GROUPS; - static inline bool Kind_IsValid(int value) { - return SharedConfigMessage_Kind_IsValid(value); - } - static constexpr Kind Kind_MIN = - SharedConfigMessage_Kind_Kind_MIN; - static constexpr Kind Kind_MAX = - SharedConfigMessage_Kind_Kind_MAX; - static constexpr int Kind_ARRAYSIZE = - SharedConfigMessage_Kind_Kind_ARRAYSIZE; - template - static inline const std::string& Kind_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Kind_Name."); - return SharedConfigMessage_Kind_Name(enum_t_value); - } - static inline bool Kind_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Kind* value) { - return SharedConfigMessage_Kind_Parse(name, value); - } - // accessors ------------------------------------------------------- enum : int { - kDataFieldNumber = 3, - kSeqnoFieldNumber = 2, - kKindFieldNumber = 1, + kIsApprovedFieldNumber = 1, }; - // required bytes data = 3; - bool has_data() const; + // required bool isApproved = 1; + bool has_isapproved() const; private: - bool _internal_has_data() const; + bool _internal_has_isapproved() const; public: - void clear_data(); - const std::string& data() const; - template - void set_data(ArgT0&& arg0, ArgT... args); - std::string* mutable_data(); - PROTOBUF_NODISCARD std::string* release_data(); - void set_allocated_data(std::string* data); + void clear_isapproved(); + bool isapproved() const; + void set_isapproved(bool value); private: - const std::string& _internal_data() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_data(const std::string& value); - std::string* _internal_mutable_data(); + bool _internal_isapproved() const; + void _internal_set_isapproved(bool value); public: - // required int64 seqno = 2; - bool has_seqno() const; + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateInviteResponseMessage) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + bool isapproved_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + +class GroupUpdateDeleteMemberContentMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateDeleteMemberContentMessage) */ { + public: + inline GroupUpdateDeleteMemberContentMessage() : GroupUpdateDeleteMemberContentMessage(nullptr) {} + ~GroupUpdateDeleteMemberContentMessage() override; + explicit PROTOBUF_CONSTEXPR GroupUpdateDeleteMemberContentMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + GroupUpdateDeleteMemberContentMessage(const GroupUpdateDeleteMemberContentMessage& from); + GroupUpdateDeleteMemberContentMessage(GroupUpdateDeleteMemberContentMessage&& from) noexcept + : GroupUpdateDeleteMemberContentMessage() { + *this = ::std::move(from); + } + + inline GroupUpdateDeleteMemberContentMessage& operator=(const GroupUpdateDeleteMemberContentMessage& from) { + CopyFrom(from); + return *this; + } + inline GroupUpdateDeleteMemberContentMessage& operator=(GroupUpdateDeleteMemberContentMessage&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const GroupUpdateDeleteMemberContentMessage& default_instance() { + return *internal_default_instance(); + } + static inline const GroupUpdateDeleteMemberContentMessage* internal_default_instance() { + return reinterpret_cast( + &_GroupUpdateDeleteMemberContentMessage_default_instance_); + } + static constexpr int kIndexInFileMessages = + 26; + + friend void swap(GroupUpdateDeleteMemberContentMessage& a, GroupUpdateDeleteMemberContentMessage& b) { + a.Swap(&b); + } + inline void Swap(GroupUpdateDeleteMemberContentMessage* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(GroupUpdateDeleteMemberContentMessage* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + GroupUpdateDeleteMemberContentMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const GroupUpdateDeleteMemberContentMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const GroupUpdateDeleteMemberContentMessage& from) { + GroupUpdateDeleteMemberContentMessage::MergeImpl(*this, from); + } private: - bool _internal_has_seqno() const; + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: - void clear_seqno(); - int64_t seqno() const; - void set_seqno(int64_t value); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + private: - int64_t _internal_seqno() const; - void _internal_set_seqno(int64_t value); - public: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(GroupUpdateDeleteMemberContentMessage* other); - // required .SessionProtos.SharedConfigMessage.Kind kind = 1; - bool has_kind() const; private: - bool _internal_has_kind() const; + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.GroupUpdateDeleteMemberContentMessage"; + } + protected: + explicit GroupUpdateDeleteMemberContentMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); public: - void clear_kind(); - ::SessionProtos::SharedConfigMessage_Kind kind() const; - void set_kind(::SessionProtos::SharedConfigMessage_Kind value); + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kMemberSessionIdsFieldNumber = 1, + kMessageHashesFieldNumber = 2, + kAdminSignatureFieldNumber = 3, + }; + // repeated string memberSessionIds = 1; + int membersessionids_size() const; + private: + int _internal_membersessionids_size() const; + public: + void clear_membersessionids(); + const std::string& membersessionids(int index) const; + std::string* mutable_membersessionids(int index); + void set_membersessionids(int index, const std::string& value); + void set_membersessionids(int index, std::string&& value); + void set_membersessionids(int index, const char* value); + void set_membersessionids(int index, const char* value, size_t size); + std::string* add_membersessionids(); + void add_membersessionids(const std::string& value); + void add_membersessionids(std::string&& value); + void add_membersessionids(const char* value); + void add_membersessionids(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& membersessionids() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_membersessionids(); + private: + const std::string& _internal_membersessionids(int index) const; + std::string* _internal_add_membersessionids(); + public: + + // repeated string messageHashes = 2; + int messagehashes_size() const; + private: + int _internal_messagehashes_size() const; + public: + void clear_messagehashes(); + const std::string& messagehashes(int index) const; + std::string* mutable_messagehashes(int index); + void set_messagehashes(int index, const std::string& value); + void set_messagehashes(int index, std::string&& value); + void set_messagehashes(int index, const char* value); + void set_messagehashes(int index, const char* value, size_t size); + std::string* add_messagehashes(); + void add_messagehashes(const std::string& value); + void add_messagehashes(std::string&& value); + void add_messagehashes(const char* value); + void add_messagehashes(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& messagehashes() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_messagehashes(); + private: + const std::string& _internal_messagehashes(int index) const; + std::string* _internal_add_messagehashes(); + public: + + // optional bytes adminSignature = 3; + bool has_adminsignature() const; + private: + bool _internal_has_adminsignature() const; + public: + void clear_adminsignature(); + const std::string& adminsignature() const; + template + void set_adminsignature(ArgT0&& arg0, ArgT... args); + std::string* mutable_adminsignature(); + PROTOBUF_NODISCARD std::string* release_adminsignature(); + void set_allocated_adminsignature(std::string* adminsignature); private: - ::SessionProtos::SharedConfigMessage_Kind _internal_kind() const; - void _internal_set_kind(::SessionProtos::SharedConfigMessage_Kind value); + const std::string& _internal_adminsignature() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_adminsignature(const std::string& value); + std::string* _internal_mutable_adminsignature(); public: - // @@protoc_insertion_point(class_scope:SessionProtos.SharedConfigMessage) + // @@protoc_insertion_point(class_scope:SessionProtos.GroupUpdateDeleteMemberContentMessage) private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr data_; - int64_t seqno_; - int kind_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField membersessionids_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField messagehashes_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr adminsignature_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; @@ -6931,379 +7429,137 @@ inline void MessageRequestResponse::set_allocated_profile(::SessionProtos::LokiP // ------------------------------------------------------------------- -// ProProof - -// required uint32 version = 1; -inline bool ProProof::_internal_has_version() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - return value; -} -inline bool ProProof::has_version() const { - return _internal_has_version(); -} -inline void ProProof::clear_version() { - _impl_.version_ = 0u; - _impl_._has_bits_[0] &= ~0x00000010u; -} -inline uint32_t ProProof::_internal_version() const { - return _impl_.version_; -} -inline uint32_t ProProof::version() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProProof.version) - return _internal_version(); -} -inline void ProProof::_internal_set_version(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.version_ = value; -} -inline void ProProof::set_version(uint32_t value) { - _internal_set_version(value); - // @@protoc_insertion_point(field_set:SessionProtos.ProProof.version) -} +// Content -// required bytes genIndexHash = 2; -inline bool ProProof::_internal_has_genindexhash() const { +// optional .SessionProtos.DataMessage dataMessage = 1; +inline bool Content::_internal_has_datamessage() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.datamessage_ != nullptr); return value; } -inline bool ProProof::has_genindexhash() const { - return _internal_has_genindexhash(); +inline bool Content::has_datamessage() const { + return _internal_has_datamessage(); } -inline void ProProof::clear_genindexhash() { - _impl_.genindexhash_.ClearToEmpty(); +inline void Content::clear_datamessage() { + if (_impl_.datamessage_ != nullptr) _impl_.datamessage_->Clear(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& ProProof::genindexhash() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProProof.genIndexHash) - return _internal_genindexhash(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ProProof::set_genindexhash(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.genindexhash_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ProProof.genIndexHash) -} -inline std::string* ProProof::mutable_genindexhash() { - std::string* _s = _internal_mutable_genindexhash(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.genIndexHash) - return _s; -} -inline const std::string& ProProof::_internal_genindexhash() const { - return _impl_.genindexhash_.Get(); -} -inline void ProProof::_internal_set_genindexhash(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.genindexhash_.Set(value, GetArenaForAllocation()); +inline const ::SessionProtos::DataMessage& Content::_internal_datamessage() const { + const ::SessionProtos::DataMessage* p = _impl_.datamessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_DataMessage_default_instance_); } -inline std::string* ProProof::_internal_mutable_genindexhash() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.genindexhash_.Mutable(GetArenaForAllocation()); +inline const ::SessionProtos::DataMessage& Content::datamessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.dataMessage) + return _internal_datamessage(); } -inline std::string* ProProof::release_genindexhash() { - // @@protoc_insertion_point(field_release:SessionProtos.ProProof.genIndexHash) - if (!_internal_has_genindexhash()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.genindexhash_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.genindexhash_.IsDefault()) { - _impl_.genindexhash_.Set("", GetArenaForAllocation()); +inline void Content::unsafe_arena_set_allocated_datamessage( + ::SessionProtos::DataMessage* datamessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.datamessage_); } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ProProof::set_allocated_genindexhash(std::string* genindexhash) { - if (genindexhash != nullptr) { + _impl_.datamessage_ = datamessage; + if (datamessage) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.genindexhash_.SetAllocated(genindexhash, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.genindexhash_.IsDefault()) { - _impl_.genindexhash_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.genIndexHash) -} - -// required bytes rotatingPublicKey = 3; -inline bool ProProof::_internal_has_rotatingpublickey() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool ProProof::has_rotatingpublickey() const { - return _internal_has_rotatingpublickey(); -} -inline void ProProof::clear_rotatingpublickey() { - _impl_.rotatingpublickey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.dataMessage) } -inline const std::string& ProProof::rotatingpublickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProProof.rotatingPublicKey) - return _internal_rotatingpublickey(); +inline ::SessionProtos::DataMessage* Content::release_datamessage() { + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::DataMessage* temp = _impl_.datamessage_; + _impl_.datamessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -template -inline PROTOBUF_ALWAYS_INLINE -void ProProof::set_rotatingpublickey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.rotatingpublickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ProProof.rotatingPublicKey) +inline ::SessionProtos::DataMessage* Content::unsafe_arena_release_datamessage() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.dataMessage) + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::DataMessage* temp = _impl_.datamessage_; + _impl_.datamessage_ = nullptr; + return temp; } -inline std::string* ProProof::mutable_rotatingpublickey() { - std::string* _s = _internal_mutable_rotatingpublickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.rotatingPublicKey) - return _s; +inline ::SessionProtos::DataMessage* Content::_internal_mutable_datamessage() { + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.datamessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataMessage>(GetArenaForAllocation()); + _impl_.datamessage_ = p; + } + return _impl_.datamessage_; } -inline const std::string& ProProof::_internal_rotatingpublickey() const { - return _impl_.rotatingpublickey_.Get(); +inline ::SessionProtos::DataMessage* Content::mutable_datamessage() { + ::SessionProtos::DataMessage* _msg = _internal_mutable_datamessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.dataMessage) + return _msg; } -inline void ProProof::_internal_set_rotatingpublickey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.rotatingpublickey_.Set(value, GetArenaForAllocation()); -} -inline std::string* ProProof::_internal_mutable_rotatingpublickey() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.rotatingpublickey_.Mutable(GetArenaForAllocation()); -} -inline std::string* ProProof::release_rotatingpublickey() { - // @@protoc_insertion_point(field_release:SessionProtos.ProProof.rotatingPublicKey) - if (!_internal_has_rotatingpublickey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.rotatingpublickey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingpublickey_.IsDefault()) { - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ProProof::set_allocated_rotatingpublickey(std::string* rotatingpublickey) { - if (rotatingpublickey != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.rotatingpublickey_.SetAllocated(rotatingpublickey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingpublickey_.IsDefault()) { - _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.rotatingPublicKey) -} - -// required uint64 expiryUnixTs = 4; -inline bool ProProof::_internal_has_expiryunixts() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool ProProof::has_expiryunixts() const { - return _internal_has_expiryunixts(); -} -inline void ProProof::clear_expiryunixts() { - _impl_.expiryunixts_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000008u; -} -inline uint64_t ProProof::_internal_expiryunixts() const { - return _impl_.expiryunixts_; -} -inline uint64_t ProProof::expiryunixts() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProProof.expiryUnixTs) - return _internal_expiryunixts(); -} -inline void ProProof::_internal_set_expiryunixts(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.expiryunixts_ = value; -} -inline void ProProof::set_expiryunixts(uint64_t value) { - _internal_set_expiryunixts(value); - // @@protoc_insertion_point(field_set:SessionProtos.ProProof.expiryUnixTs) -} - -// required bytes sig = 5; -inline bool ProProof::_internal_has_sig() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool ProProof::has_sig() const { - return _internal_has_sig(); -} -inline void ProProof::clear_sig() { - _impl_.sig_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline const std::string& ProProof::sig() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProProof.sig) - return _internal_sig(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ProProof::set_sig(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.sig_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ProProof.sig) -} -inline std::string* ProProof::mutable_sig() { - std::string* _s = _internal_mutable_sig(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.sig) - return _s; -} -inline const std::string& ProProof::_internal_sig() const { - return _impl_.sig_.Get(); -} -inline void ProProof::_internal_set_sig(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.sig_.Set(value, GetArenaForAllocation()); -} -inline std::string* ProProof::_internal_mutable_sig() { - _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.sig_.Mutable(GetArenaForAllocation()); -} -inline std::string* ProProof::release_sig() { - // @@protoc_insertion_point(field_release:SessionProtos.ProProof.sig) - if (!_internal_has_sig()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.sig_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.sig_.IsDefault()) { - _impl_.sig_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ProProof::set_allocated_sig(std::string* sig) { - if (sig != nullptr) { - _impl_._has_bits_[0] |= 0x00000004u; - } else { - _impl_._has_bits_[0] &= ~0x00000004u; - } - _impl_.sig_.SetAllocated(sig, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.sig_.IsDefault()) { - _impl_.sig_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.sig) -} - -// ------------------------------------------------------------------- - -// ProConfig - -// required bytes rotatingPrivKey = 1; -inline bool ProConfig::_internal_has_rotatingprivkey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool ProConfig::has_rotatingprivkey() const { - return _internal_has_rotatingprivkey(); -} -inline void ProConfig::clear_rotatingprivkey() { - _impl_.rotatingprivkey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& ProConfig::rotatingprivkey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.rotatingPrivKey) - return _internal_rotatingprivkey(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ProConfig::set_rotatingprivkey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.rotatingprivkey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ProConfig.rotatingPrivKey) -} -inline std::string* ProConfig::mutable_rotatingprivkey() { - std::string* _s = _internal_mutable_rotatingprivkey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.rotatingPrivKey) - return _s; -} -inline const std::string& ProConfig::_internal_rotatingprivkey() const { - return _impl_.rotatingprivkey_.Get(); -} -inline void ProConfig::_internal_set_rotatingprivkey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.rotatingprivkey_.Set(value, GetArenaForAllocation()); -} -inline std::string* ProConfig::_internal_mutable_rotatingprivkey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.rotatingprivkey_.Mutable(GetArenaForAllocation()); -} -inline std::string* ProConfig::release_rotatingprivkey() { - // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.rotatingPrivKey) - if (!_internal_has_rotatingprivkey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.rotatingprivkey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingprivkey_.IsDefault()) { - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); +inline void Content::set_allocated_datamessage(::SessionProtos::DataMessage* datamessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.datamessage_; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ProConfig::set_allocated_rotatingprivkey(std::string* rotatingprivkey) { - if (rotatingprivkey != nullptr) { + if (datamessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(datamessage); + if (message_arena != submessage_arena) { + datamessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, datamessage, submessage_arena); + } _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.rotatingprivkey_.SetAllocated(rotatingprivkey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingprivkey_.IsDefault()) { - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.rotatingPrivKey) + _impl_.datamessage_ = datamessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.dataMessage) } -// required .SessionProtos.ProProof proof = 2; -inline bool ProConfig::_internal_has_proof() const { +// optional .SessionProtos.CallMessage callMessage = 3; +inline bool Content::_internal_has_callmessage() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); + PROTOBUF_ASSUME(!value || _impl_.callmessage_ != nullptr); return value; } -inline bool ProConfig::has_proof() const { - return _internal_has_proof(); +inline bool Content::has_callmessage() const { + return _internal_has_callmessage(); } -inline void ProConfig::clear_proof() { - if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); +inline void Content::clear_callmessage() { + if (_impl_.callmessage_ != nullptr) _impl_.callmessage_->Clear(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const ::SessionProtos::ProProof& ProConfig::_internal_proof() const { - const ::SessionProtos::ProProof* p = _impl_.proof_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ProProof_default_instance_); +inline const ::SessionProtos::CallMessage& Content::_internal_callmessage() const { + const ::SessionProtos::CallMessage* p = _impl_.callmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_CallMessage_default_instance_); } -inline const ::SessionProtos::ProProof& ProConfig::proof() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.proof) - return _internal_proof(); +inline const ::SessionProtos::CallMessage& Content::callmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.callMessage) + return _internal_callmessage(); } -inline void ProConfig::unsafe_arena_set_allocated_proof( - ::SessionProtos::ProProof* proof) { +inline void Content::unsafe_arena_set_allocated_callmessage( + ::SessionProtos::CallMessage* callmessage) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.callmessage_); } - _impl_.proof_ = proof; - if (proof) { + _impl_.callmessage_ = callmessage; + if (callmessage) { _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProConfig.proof) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.callMessage) } -inline ::SessionProtos::ProProof* ProConfig::release_proof() { +inline ::SessionProtos::CallMessage* Content::release_callmessage() { _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::ProProof* temp = _impl_.proof_; - _impl_.proof_ = nullptr; + ::SessionProtos::CallMessage* temp = _impl_.callmessage_; + _impl_.callmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7315,89 +7571,85 @@ inline ::SessionProtos::ProProof* ProConfig::release_proof() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::ProProof* ProConfig::unsafe_arena_release_proof() { - // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.proof) +inline ::SessionProtos::CallMessage* Content::unsafe_arena_release_callmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.callMessage) _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::ProProof* temp = _impl_.proof_; - _impl_.proof_ = nullptr; + ::SessionProtos::CallMessage* temp = _impl_.callmessage_; + _impl_.callmessage_ = nullptr; return temp; } -inline ::SessionProtos::ProProof* ProConfig::_internal_mutable_proof() { +inline ::SessionProtos::CallMessage* Content::_internal_mutable_callmessage() { _impl_._has_bits_[0] |= 0x00000002u; - if (_impl_.proof_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); - _impl_.proof_ = p; + if (_impl_.callmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::CallMessage>(GetArenaForAllocation()); + _impl_.callmessage_ = p; } - return _impl_.proof_; + return _impl_.callmessage_; } -inline ::SessionProtos::ProProof* ProConfig::mutable_proof() { - ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.proof) +inline ::SessionProtos::CallMessage* Content::mutable_callmessage() { + ::SessionProtos::CallMessage* _msg = _internal_mutable_callmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.callMessage) return _msg; } -inline void ProConfig::set_allocated_proof(::SessionProtos::ProProof* proof) { +inline void Content::set_allocated_callmessage(::SessionProtos::CallMessage* callmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.proof_; + delete _impl_.callmessage_; } - if (proof) { + if (callmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(callmessage); if (message_arena != submessage_arena) { - proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, proof, submessage_arena); + callmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, callmessage, submessage_arena); } _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.proof_ = proof; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.proof) + _impl_.callmessage_ = callmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.callMessage) } -// ------------------------------------------------------------------- - -// ProMessageConfig - -// required .SessionProtos.ProProof proof = 1; -inline bool ProMessageConfig::_internal_has_proof() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); +// optional .SessionProtos.ReceiptMessage receiptMessage = 5; +inline bool Content::_internal_has_receiptmessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + PROTOBUF_ASSUME(!value || _impl_.receiptmessage_ != nullptr); return value; } -inline bool ProMessageConfig::has_proof() const { - return _internal_has_proof(); +inline bool Content::has_receiptmessage() const { + return _internal_has_receiptmessage(); } -inline void ProMessageConfig::clear_proof() { - if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); - _impl_._has_bits_[0] &= ~0x00000001u; +inline void Content::clear_receiptmessage() { + if (_impl_.receiptmessage_ != nullptr) _impl_.receiptmessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000004u; } -inline const ::SessionProtos::ProProof& ProMessageConfig::_internal_proof() const { - const ::SessionProtos::ProProof* p = _impl_.proof_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ProProof_default_instance_); +inline const ::SessionProtos::ReceiptMessage& Content::_internal_receiptmessage() const { + const ::SessionProtos::ReceiptMessage* p = _impl_.receiptmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ReceiptMessage_default_instance_); } -inline const ::SessionProtos::ProProof& ProMessageConfig::proof() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProMessageConfig.proof) - return _internal_proof(); +inline const ::SessionProtos::ReceiptMessage& Content::receiptmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.receiptMessage) + return _internal_receiptmessage(); } -inline void ProMessageConfig::unsafe_arena_set_allocated_proof( - ::SessionProtos::ProProof* proof) { +inline void Content::unsafe_arena_set_allocated_receiptmessage( + ::SessionProtos::ReceiptMessage* receiptmessage) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.receiptmessage_); } - _impl_.proof_ = proof; - if (proof) { - _impl_._has_bits_[0] |= 0x00000001u; + _impl_.receiptmessage_ = receiptmessage; + if (receiptmessage) { + _impl_._has_bits_[0] |= 0x00000004u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000004u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProMessageConfig.proof) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.receiptMessage) } -inline ::SessionProtos::ProProof* ProMessageConfig::release_proof() { - _impl_._has_bits_[0] &= ~0x00000001u; - ::SessionProtos::ProProof* temp = _impl_.proof_; - _impl_.proof_ = nullptr; +inline ::SessionProtos::ReceiptMessage* Content::release_receiptmessage() { + _impl_._has_bits_[0] &= ~0x00000004u; + ::SessionProtos::ReceiptMessage* temp = _impl_.receiptmessage_; + _impl_.receiptmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7409,117 +7661,85 @@ inline ::SessionProtos::ProProof* ProMessageConfig::release_proof() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::ProProof* ProMessageConfig::unsafe_arena_release_proof() { - // @@protoc_insertion_point(field_release:SessionProtos.ProMessageConfig.proof) - _impl_._has_bits_[0] &= ~0x00000001u; - ::SessionProtos::ProProof* temp = _impl_.proof_; - _impl_.proof_ = nullptr; +inline ::SessionProtos::ReceiptMessage* Content::unsafe_arena_release_receiptmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.receiptMessage) + _impl_._has_bits_[0] &= ~0x00000004u; + ::SessionProtos::ReceiptMessage* temp = _impl_.receiptmessage_; + _impl_.receiptmessage_ = nullptr; return temp; } -inline ::SessionProtos::ProProof* ProMessageConfig::_internal_mutable_proof() { - _impl_._has_bits_[0] |= 0x00000001u; - if (_impl_.proof_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); - _impl_.proof_ = p; +inline ::SessionProtos::ReceiptMessage* Content::_internal_mutable_receiptmessage() { + _impl_._has_bits_[0] |= 0x00000004u; + if (_impl_.receiptmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ReceiptMessage>(GetArenaForAllocation()); + _impl_.receiptmessage_ = p; } - return _impl_.proof_; + return _impl_.receiptmessage_; } -inline ::SessionProtos::ProProof* ProMessageConfig::mutable_proof() { - ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProMessageConfig.proof) +inline ::SessionProtos::ReceiptMessage* Content::mutable_receiptmessage() { + ::SessionProtos::ReceiptMessage* _msg = _internal_mutable_receiptmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.receiptMessage) return _msg; } -inline void ProMessageConfig::set_allocated_proof(::SessionProtos::ProProof* proof) { +inline void Content::set_allocated_receiptmessage(::SessionProtos::ReceiptMessage* receiptmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.proof_; + delete _impl_.receiptmessage_; } - if (proof) { + if (receiptmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(receiptmessage); if (message_arena != submessage_arena) { - proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, proof, submessage_arena); + receiptmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, receiptmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000004u; } - _impl_.proof_ = proof; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProMessageConfig.proof) + _impl_.receiptmessage_ = receiptmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.receiptMessage) } -// required uint32 flags = 2; -inline bool ProMessageConfig::_internal_has_flags() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; +// optional .SessionProtos.TypingMessage typingMessage = 6; +inline bool Content::_internal_has_typingmessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.typingmessage_ != nullptr); return value; } -inline bool ProMessageConfig::has_flags() const { - return _internal_has_flags(); -} -inline void ProMessageConfig::clear_flags() { - _impl_.flags_ = 0u; - _impl_._has_bits_[0] &= ~0x00000002u; +inline bool Content::has_typingmessage() const { + return _internal_has_typingmessage(); } -inline uint32_t ProMessageConfig::_internal_flags() const { - return _impl_.flags_; +inline void Content::clear_typingmessage() { + if (_impl_.typingmessage_ != nullptr) _impl_.typingmessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; } -inline uint32_t ProMessageConfig::flags() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProMessageConfig.flags) - return _internal_flags(); +inline const ::SessionProtos::TypingMessage& Content::_internal_typingmessage() const { + const ::SessionProtos::TypingMessage* p = _impl_.typingmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_TypingMessage_default_instance_); } -inline void ProMessageConfig::_internal_set_flags(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.flags_ = value; +inline const ::SessionProtos::TypingMessage& Content::typingmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.typingMessage) + return _internal_typingmessage(); } -inline void ProMessageConfig::set_flags(uint32_t value) { - _internal_set_flags(value); - // @@protoc_insertion_point(field_set:SessionProtos.ProMessageConfig.flags) +inline void Content::unsafe_arena_set_allocated_typingmessage( + ::SessionProtos::TypingMessage* typingmessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.typingmessage_); + } + _impl_.typingmessage_ = typingmessage; + if (typingmessage) { + _impl_._has_bits_[0] |= 0x00000008u; + } else { + _impl_._has_bits_[0] &= ~0x00000008u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.typingMessage) } - -// ------------------------------------------------------------------- - -// Content - -// optional .SessionProtos.DataMessage dataMessage = 1; -inline bool Content::_internal_has_datamessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || _impl_.datamessage_ != nullptr); - return value; -} -inline bool Content::has_datamessage() const { - return _internal_has_datamessage(); -} -inline void Content::clear_datamessage() { - if (_impl_.datamessage_ != nullptr) _impl_.datamessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const ::SessionProtos::DataMessage& Content::_internal_datamessage() const { - const ::SessionProtos::DataMessage* p = _impl_.datamessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataMessage_default_instance_); -} -inline const ::SessionProtos::DataMessage& Content::datamessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.dataMessage) - return _internal_datamessage(); -} -inline void Content::unsafe_arena_set_allocated_datamessage( - ::SessionProtos::DataMessage* datamessage) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.datamessage_); - } - _impl_.datamessage_ = datamessage; - if (datamessage) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.dataMessage) -} -inline ::SessionProtos::DataMessage* Content::release_datamessage() { - _impl_._has_bits_[0] &= ~0x00000001u; - ::SessionProtos::DataMessage* temp = _impl_.datamessage_; - _impl_.datamessage_ = nullptr; +inline ::SessionProtos::TypingMessage* Content::release_typingmessage() { + _impl_._has_bits_[0] &= ~0x00000008u; + ::SessionProtos::TypingMessage* temp = _impl_.typingmessage_; + _impl_.typingmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7531,85 +7751,85 @@ inline ::SessionProtos::DataMessage* Content::release_datamessage() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::DataMessage* Content::unsafe_arena_release_datamessage() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.dataMessage) - _impl_._has_bits_[0] &= ~0x00000001u; - ::SessionProtos::DataMessage* temp = _impl_.datamessage_; - _impl_.datamessage_ = nullptr; +inline ::SessionProtos::TypingMessage* Content::unsafe_arena_release_typingmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.typingMessage) + _impl_._has_bits_[0] &= ~0x00000008u; + ::SessionProtos::TypingMessage* temp = _impl_.typingmessage_; + _impl_.typingmessage_ = nullptr; return temp; } -inline ::SessionProtos::DataMessage* Content::_internal_mutable_datamessage() { - _impl_._has_bits_[0] |= 0x00000001u; - if (_impl_.datamessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage>(GetArenaForAllocation()); - _impl_.datamessage_ = p; +inline ::SessionProtos::TypingMessage* Content::_internal_mutable_typingmessage() { + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.typingmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::TypingMessage>(GetArenaForAllocation()); + _impl_.typingmessage_ = p; } - return _impl_.datamessage_; + return _impl_.typingmessage_; } -inline ::SessionProtos::DataMessage* Content::mutable_datamessage() { - ::SessionProtos::DataMessage* _msg = _internal_mutable_datamessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.dataMessage) +inline ::SessionProtos::TypingMessage* Content::mutable_typingmessage() { + ::SessionProtos::TypingMessage* _msg = _internal_mutable_typingmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.typingMessage) return _msg; } -inline void Content::set_allocated_datamessage(::SessionProtos::DataMessage* datamessage) { +inline void Content::set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.datamessage_; + delete _impl_.typingmessage_; } - if (datamessage) { + if (typingmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(datamessage); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(typingmessage); if (message_arena != submessage_arena) { - datamessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, datamessage, submessage_arena); + typingmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, typingmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000008u; } - _impl_.datamessage_ = datamessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.dataMessage) + _impl_.typingmessage_ = typingmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.typingMessage) } -// optional .SessionProtos.CallMessage callMessage = 3; -inline bool Content::_internal_has_callmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || _impl_.callmessage_ != nullptr); +// optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; +inline bool Content::_internal_has_dataextractionnotification() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + PROTOBUF_ASSUME(!value || _impl_.dataextractionnotification_ != nullptr); return value; } -inline bool Content::has_callmessage() const { - return _internal_has_callmessage(); +inline bool Content::has_dataextractionnotification() const { + return _internal_has_dataextractionnotification(); } -inline void Content::clear_callmessage() { - if (_impl_.callmessage_ != nullptr) _impl_.callmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000002u; +inline void Content::clear_dataextractionnotification() { + if (_impl_.dataextractionnotification_ != nullptr) _impl_.dataextractionnotification_->Clear(); + _impl_._has_bits_[0] &= ~0x00000010u; } -inline const ::SessionProtos::CallMessage& Content::_internal_callmessage() const { - const ::SessionProtos::CallMessage* p = _impl_.callmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_CallMessage_default_instance_); +inline const ::SessionProtos::DataExtractionNotification& Content::_internal_dataextractionnotification() const { + const ::SessionProtos::DataExtractionNotification* p = _impl_.dataextractionnotification_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_DataExtractionNotification_default_instance_); } -inline const ::SessionProtos::CallMessage& Content::callmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.callMessage) - return _internal_callmessage(); +inline const ::SessionProtos::DataExtractionNotification& Content::dataextractionnotification() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.dataExtractionNotification) + return _internal_dataextractionnotification(); } -inline void Content::unsafe_arena_set_allocated_callmessage( - ::SessionProtos::CallMessage* callmessage) { +inline void Content::unsafe_arena_set_allocated_dataextractionnotification( + ::SessionProtos::DataExtractionNotification* dataextractionnotification) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.callmessage_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.dataextractionnotification_); } - _impl_.callmessage_ = callmessage; - if (callmessage) { - _impl_._has_bits_[0] |= 0x00000002u; + _impl_.dataextractionnotification_ = dataextractionnotification; + if (dataextractionnotification) { + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000010u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.callMessage) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.dataExtractionNotification) } -inline ::SessionProtos::CallMessage* Content::release_callmessage() { - _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::CallMessage* temp = _impl_.callmessage_; - _impl_.callmessage_ = nullptr; +inline ::SessionProtos::DataExtractionNotification* Content::release_dataextractionnotification() { + _impl_._has_bits_[0] &= ~0x00000010u; + ::SessionProtos::DataExtractionNotification* temp = _impl_.dataextractionnotification_; + _impl_.dataextractionnotification_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7621,85 +7841,85 @@ inline ::SessionProtos::CallMessage* Content::release_callmessage() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::CallMessage* Content::unsafe_arena_release_callmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.callMessage) - _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::CallMessage* temp = _impl_.callmessage_; - _impl_.callmessage_ = nullptr; +inline ::SessionProtos::DataExtractionNotification* Content::unsafe_arena_release_dataextractionnotification() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.dataExtractionNotification) + _impl_._has_bits_[0] &= ~0x00000010u; + ::SessionProtos::DataExtractionNotification* temp = _impl_.dataextractionnotification_; + _impl_.dataextractionnotification_ = nullptr; return temp; } -inline ::SessionProtos::CallMessage* Content::_internal_mutable_callmessage() { - _impl_._has_bits_[0] |= 0x00000002u; - if (_impl_.callmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::CallMessage>(GetArenaForAllocation()); - _impl_.callmessage_ = p; +inline ::SessionProtos::DataExtractionNotification* Content::_internal_mutable_dataextractionnotification() { + _impl_._has_bits_[0] |= 0x00000010u; + if (_impl_.dataextractionnotification_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataExtractionNotification>(GetArenaForAllocation()); + _impl_.dataextractionnotification_ = p; } - return _impl_.callmessage_; + return _impl_.dataextractionnotification_; } -inline ::SessionProtos::CallMessage* Content::mutable_callmessage() { - ::SessionProtos::CallMessage* _msg = _internal_mutable_callmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.callMessage) +inline ::SessionProtos::DataExtractionNotification* Content::mutable_dataextractionnotification() { + ::SessionProtos::DataExtractionNotification* _msg = _internal_mutable_dataextractionnotification(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.dataExtractionNotification) return _msg; } -inline void Content::set_allocated_callmessage(::SessionProtos::CallMessage* callmessage) { +inline void Content::set_allocated_dataextractionnotification(::SessionProtos::DataExtractionNotification* dataextractionnotification) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.callmessage_; + delete _impl_.dataextractionnotification_; } - if (callmessage) { + if (dataextractionnotification) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(callmessage); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(dataextractionnotification); if (message_arena != submessage_arena) { - callmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, callmessage, submessage_arena); + dataextractionnotification = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, dataextractionnotification, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000010u; } - _impl_.callmessage_ = callmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.callMessage) + _impl_.dataextractionnotification_ = dataextractionnotification; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.dataExtractionNotification) } -// optional .SessionProtos.ReceiptMessage receiptMessage = 5; -inline bool Content::_internal_has_receiptmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - PROTOBUF_ASSUME(!value || _impl_.receiptmessage_ != nullptr); +// optional .SessionProtos.UnsendRequest unsendRequest = 9; +inline bool Content::_internal_has_unsendrequest() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + PROTOBUF_ASSUME(!value || _impl_.unsendrequest_ != nullptr); return value; } -inline bool Content::has_receiptmessage() const { - return _internal_has_receiptmessage(); +inline bool Content::has_unsendrequest() const { + return _internal_has_unsendrequest(); } -inline void Content::clear_receiptmessage() { - if (_impl_.receiptmessage_ != nullptr) _impl_.receiptmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000004u; +inline void Content::clear_unsendrequest() { + if (_impl_.unsendrequest_ != nullptr) _impl_.unsendrequest_->Clear(); + _impl_._has_bits_[0] &= ~0x00000020u; } -inline const ::SessionProtos::ReceiptMessage& Content::_internal_receiptmessage() const { - const ::SessionProtos::ReceiptMessage* p = _impl_.receiptmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ReceiptMessage_default_instance_); +inline const ::SessionProtos::UnsendRequest& Content::_internal_unsendrequest() const { + const ::SessionProtos::UnsendRequest* p = _impl_.unsendrequest_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_UnsendRequest_default_instance_); } -inline const ::SessionProtos::ReceiptMessage& Content::receiptmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.receiptMessage) - return _internal_receiptmessage(); +inline const ::SessionProtos::UnsendRequest& Content::unsendrequest() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.unsendRequest) + return _internal_unsendrequest(); } -inline void Content::unsafe_arena_set_allocated_receiptmessage( - ::SessionProtos::ReceiptMessage* receiptmessage) { +inline void Content::unsafe_arena_set_allocated_unsendrequest( + ::SessionProtos::UnsendRequest* unsendrequest) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.receiptmessage_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.unsendrequest_); } - _impl_.receiptmessage_ = receiptmessage; - if (receiptmessage) { - _impl_._has_bits_[0] |= 0x00000004u; + _impl_.unsendrequest_ = unsendrequest; + if (unsendrequest) { + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000020u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.receiptMessage) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.unsendRequest) } -inline ::SessionProtos::ReceiptMessage* Content::release_receiptmessage() { - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::ReceiptMessage* temp = _impl_.receiptmessage_; - _impl_.receiptmessage_ = nullptr; +inline ::SessionProtos::UnsendRequest* Content::release_unsendrequest() { + _impl_._has_bits_[0] &= ~0x00000020u; + ::SessionProtos::UnsendRequest* temp = _impl_.unsendrequest_; + _impl_.unsendrequest_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7711,85 +7931,85 @@ inline ::SessionProtos::ReceiptMessage* Content::release_receiptmessage() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::ReceiptMessage* Content::unsafe_arena_release_receiptmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.receiptMessage) - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::ReceiptMessage* temp = _impl_.receiptmessage_; - _impl_.receiptmessage_ = nullptr; +inline ::SessionProtos::UnsendRequest* Content::unsafe_arena_release_unsendrequest() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.unsendRequest) + _impl_._has_bits_[0] &= ~0x00000020u; + ::SessionProtos::UnsendRequest* temp = _impl_.unsendrequest_; + _impl_.unsendrequest_ = nullptr; return temp; } -inline ::SessionProtos::ReceiptMessage* Content::_internal_mutable_receiptmessage() { - _impl_._has_bits_[0] |= 0x00000004u; - if (_impl_.receiptmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ReceiptMessage>(GetArenaForAllocation()); - _impl_.receiptmessage_ = p; +inline ::SessionProtos::UnsendRequest* Content::_internal_mutable_unsendrequest() { + _impl_._has_bits_[0] |= 0x00000020u; + if (_impl_.unsendrequest_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::UnsendRequest>(GetArenaForAllocation()); + _impl_.unsendrequest_ = p; } - return _impl_.receiptmessage_; + return _impl_.unsendrequest_; } -inline ::SessionProtos::ReceiptMessage* Content::mutable_receiptmessage() { - ::SessionProtos::ReceiptMessage* _msg = _internal_mutable_receiptmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.receiptMessage) +inline ::SessionProtos::UnsendRequest* Content::mutable_unsendrequest() { + ::SessionProtos::UnsendRequest* _msg = _internal_mutable_unsendrequest(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.unsendRequest) return _msg; } -inline void Content::set_allocated_receiptmessage(::SessionProtos::ReceiptMessage* receiptmessage) { +inline void Content::set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.receiptmessage_; + delete _impl_.unsendrequest_; } - if (receiptmessage) { + if (unsendrequest) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(receiptmessage); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(unsendrequest); if (message_arena != submessage_arena) { - receiptmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, receiptmessage, submessage_arena); + unsendrequest = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, unsendrequest, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000020u; } - _impl_.receiptmessage_ = receiptmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.receiptMessage) + _impl_.unsendrequest_ = unsendrequest; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.unsendRequest) } -// optional .SessionProtos.TypingMessage typingMessage = 6; -inline bool Content::_internal_has_typingmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || _impl_.typingmessage_ != nullptr); +// optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; +inline bool Content::_internal_has_messagerequestresponse() const { + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + PROTOBUF_ASSUME(!value || _impl_.messagerequestresponse_ != nullptr); return value; } -inline bool Content::has_typingmessage() const { - return _internal_has_typingmessage(); +inline bool Content::has_messagerequestresponse() const { + return _internal_has_messagerequestresponse(); } -inline void Content::clear_typingmessage() { - if (_impl_.typingmessage_ != nullptr) _impl_.typingmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000008u; +inline void Content::clear_messagerequestresponse() { + if (_impl_.messagerequestresponse_ != nullptr) _impl_.messagerequestresponse_->Clear(); + _impl_._has_bits_[0] &= ~0x00000040u; } -inline const ::SessionProtos::TypingMessage& Content::_internal_typingmessage() const { - const ::SessionProtos::TypingMessage* p = _impl_.typingmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_TypingMessage_default_instance_); +inline const ::SessionProtos::MessageRequestResponse& Content::_internal_messagerequestresponse() const { + const ::SessionProtos::MessageRequestResponse* p = _impl_.messagerequestresponse_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_MessageRequestResponse_default_instance_); } -inline const ::SessionProtos::TypingMessage& Content::typingmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.typingMessage) - return _internal_typingmessage(); +inline const ::SessionProtos::MessageRequestResponse& Content::messagerequestresponse() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.messageRequestResponse) + return _internal_messagerequestresponse(); } -inline void Content::unsafe_arena_set_allocated_typingmessage( - ::SessionProtos::TypingMessage* typingmessage) { +inline void Content::unsafe_arena_set_allocated_messagerequestresponse( + ::SessionProtos::MessageRequestResponse* messagerequestresponse) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.typingmessage_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.messagerequestresponse_); } - _impl_.typingmessage_ = typingmessage; - if (typingmessage) { - _impl_._has_bits_[0] |= 0x00000008u; + _impl_.messagerequestresponse_ = messagerequestresponse; + if (messagerequestresponse) { + _impl_._has_bits_[0] |= 0x00000040u; } else { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000040u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.typingMessage) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.messageRequestResponse) } -inline ::SessionProtos::TypingMessage* Content::release_typingmessage() { - _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::TypingMessage* temp = _impl_.typingmessage_; - _impl_.typingmessage_ = nullptr; +inline ::SessionProtos::MessageRequestResponse* Content::release_messagerequestresponse() { + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::MessageRequestResponse* temp = _impl_.messagerequestresponse_; + _impl_.messagerequestresponse_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7801,85 +8021,85 @@ inline ::SessionProtos::TypingMessage* Content::release_typingmessage() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::TypingMessage* Content::unsafe_arena_release_typingmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.typingMessage) - _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::TypingMessage* temp = _impl_.typingmessage_; - _impl_.typingmessage_ = nullptr; +inline ::SessionProtos::MessageRequestResponse* Content::unsafe_arena_release_messagerequestresponse() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.messageRequestResponse) + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::MessageRequestResponse* temp = _impl_.messagerequestresponse_; + _impl_.messagerequestresponse_ = nullptr; return temp; } -inline ::SessionProtos::TypingMessage* Content::_internal_mutable_typingmessage() { - _impl_._has_bits_[0] |= 0x00000008u; - if (_impl_.typingmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::TypingMessage>(GetArenaForAllocation()); - _impl_.typingmessage_ = p; +inline ::SessionProtos::MessageRequestResponse* Content::_internal_mutable_messagerequestresponse() { + _impl_._has_bits_[0] |= 0x00000040u; + if (_impl_.messagerequestresponse_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(GetArenaForAllocation()); + _impl_.messagerequestresponse_ = p; } - return _impl_.typingmessage_; + return _impl_.messagerequestresponse_; } -inline ::SessionProtos::TypingMessage* Content::mutable_typingmessage() { - ::SessionProtos::TypingMessage* _msg = _internal_mutable_typingmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.typingMessage) +inline ::SessionProtos::MessageRequestResponse* Content::mutable_messagerequestresponse() { + ::SessionProtos::MessageRequestResponse* _msg = _internal_mutable_messagerequestresponse(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.messageRequestResponse) return _msg; } -inline void Content::set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage) { +inline void Content::set_allocated_messagerequestresponse(::SessionProtos::MessageRequestResponse* messagerequestresponse) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.typingmessage_; + delete _impl_.messagerequestresponse_; } - if (typingmessage) { + if (messagerequestresponse) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(typingmessage); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(messagerequestresponse); if (message_arena != submessage_arena) { - typingmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, typingmessage, submessage_arena); + messagerequestresponse = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, messagerequestresponse, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000040u; } else { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000040u; } - _impl_.typingmessage_ = typingmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.typingMessage) + _impl_.messagerequestresponse_ = messagerequestresponse; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.messageRequestResponse) } -// optional .SessionProtos.ConfigurationMessage configurationMessage = 7; -inline bool Content::_internal_has_configurationmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - PROTOBUF_ASSUME(!value || _impl_.configurationmessage_ != nullptr); +// optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; +inline bool Content::_internal_has_sharedconfigmessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + PROTOBUF_ASSUME(!value || _impl_.sharedconfigmessage_ != nullptr); return value; } -inline bool Content::has_configurationmessage() const { - return _internal_has_configurationmessage(); +inline bool Content::has_sharedconfigmessage() const { + return _internal_has_sharedconfigmessage(); } -inline void Content::clear_configurationmessage() { - if (_impl_.configurationmessage_ != nullptr) _impl_.configurationmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000010u; +inline void Content::clear_sharedconfigmessage() { + if (_impl_.sharedconfigmessage_ != nullptr) _impl_.sharedconfigmessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000080u; } -inline const ::SessionProtos::ConfigurationMessage& Content::_internal_configurationmessage() const { - const ::SessionProtos::ConfigurationMessage* p = _impl_.configurationmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ConfigurationMessage_default_instance_); +inline const ::SessionProtos::SharedConfigMessage& Content::_internal_sharedconfigmessage() const { + const ::SessionProtos::SharedConfigMessage* p = _impl_.sharedconfigmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_SharedConfigMessage_default_instance_); } -inline const ::SessionProtos::ConfigurationMessage& Content::configurationmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.configurationMessage) - return _internal_configurationmessage(); +inline const ::SessionProtos::SharedConfigMessage& Content::sharedconfigmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.sharedConfigMessage) + return _internal_sharedconfigmessage(); } -inline void Content::unsafe_arena_set_allocated_configurationmessage( - ::SessionProtos::ConfigurationMessage* configurationmessage) { +inline void Content::unsafe_arena_set_allocated_sharedconfigmessage( + ::SessionProtos::SharedConfigMessage* sharedconfigmessage) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.configurationmessage_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.sharedconfigmessage_); } - _impl_.configurationmessage_ = configurationmessage; - if (configurationmessage) { - _impl_._has_bits_[0] |= 0x00000010u; + _impl_.sharedconfigmessage_ = sharedconfigmessage; + if (sharedconfigmessage) { + _impl_._has_bits_[0] |= 0x00000080u; } else { - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000080u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.configurationMessage) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.sharedConfigMessage) } -inline ::SessionProtos::ConfigurationMessage* Content::release_configurationmessage() { - _impl_._has_bits_[0] &= ~0x00000010u; - ::SessionProtos::ConfigurationMessage* temp = _impl_.configurationmessage_; - _impl_.configurationmessage_ = nullptr; +inline ::SessionProtos::SharedConfigMessage* Content::release_sharedconfigmessage() { + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::SharedConfigMessage* temp = _impl_.sharedconfigmessage_; + _impl_.sharedconfigmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -7891,494 +8111,129 @@ inline ::SessionProtos::ConfigurationMessage* Content::release_configurationmess #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::ConfigurationMessage* Content::unsafe_arena_release_configurationmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.configurationMessage) - _impl_._has_bits_[0] &= ~0x00000010u; - ::SessionProtos::ConfigurationMessage* temp = _impl_.configurationmessage_; - _impl_.configurationmessage_ = nullptr; +inline ::SessionProtos::SharedConfigMessage* Content::unsafe_arena_release_sharedconfigmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.sharedConfigMessage) + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::SharedConfigMessage* temp = _impl_.sharedconfigmessage_; + _impl_.sharedconfigmessage_ = nullptr; return temp; } -inline ::SessionProtos::ConfigurationMessage* Content::_internal_mutable_configurationmessage() { - _impl_._has_bits_[0] |= 0x00000010u; - if (_impl_.configurationmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ConfigurationMessage>(GetArenaForAllocation()); - _impl_.configurationmessage_ = p; +inline ::SessionProtos::SharedConfigMessage* Content::_internal_mutable_sharedconfigmessage() { + _impl_._has_bits_[0] |= 0x00000080u; + if (_impl_.sharedconfigmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::SharedConfigMessage>(GetArenaForAllocation()); + _impl_.sharedconfigmessage_ = p; } - return _impl_.configurationmessage_; + return _impl_.sharedconfigmessage_; } -inline ::SessionProtos::ConfigurationMessage* Content::mutable_configurationmessage() { - ::SessionProtos::ConfigurationMessage* _msg = _internal_mutable_configurationmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.configurationMessage) +inline ::SessionProtos::SharedConfigMessage* Content::mutable_sharedconfigmessage() { + ::SessionProtos::SharedConfigMessage* _msg = _internal_mutable_sharedconfigmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.sharedConfigMessage) return _msg; } -inline void Content::set_allocated_configurationmessage(::SessionProtos::ConfigurationMessage* configurationmessage) { +inline void Content::set_allocated_sharedconfigmessage(::SessionProtos::SharedConfigMessage* sharedconfigmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.configurationmessage_; + delete _impl_.sharedconfigmessage_; } - if (configurationmessage) { + if (sharedconfigmessage) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(configurationmessage); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(sharedconfigmessage); if (message_arena != submessage_arena) { - configurationmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, configurationmessage, submessage_arena); + sharedconfigmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, sharedconfigmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000080u; } else { - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000080u; } - _impl_.configurationmessage_ = configurationmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.configurationMessage) + _impl_.sharedconfigmessage_ = sharedconfigmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.sharedConfigMessage) } -// optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; -inline bool Content::_internal_has_dataextractionnotification() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; - PROTOBUF_ASSUME(!value || _impl_.dataextractionnotification_ != nullptr); +// optional .SessionProtos.Content.ExpirationType expirationType = 12; +inline bool Content::_internal_has_expirationtype() const { + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; return value; } -inline bool Content::has_dataextractionnotification() const { - return _internal_has_dataextractionnotification(); +inline bool Content::has_expirationtype() const { + return _internal_has_expirationtype(); } -inline void Content::clear_dataextractionnotification() { - if (_impl_.dataextractionnotification_ != nullptr) _impl_.dataextractionnotification_->Clear(); - _impl_._has_bits_[0] &= ~0x00000020u; +inline void Content::clear_expirationtype() { + _impl_.expirationtype_ = 0; + _impl_._has_bits_[0] &= ~0x00000100u; } -inline const ::SessionProtos::DataExtractionNotification& Content::_internal_dataextractionnotification() const { - const ::SessionProtos::DataExtractionNotification* p = _impl_.dataextractionnotification_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataExtractionNotification_default_instance_); +inline ::SessionProtos::Content_ExpirationType Content::_internal_expirationtype() const { + return static_cast< ::SessionProtos::Content_ExpirationType >(_impl_.expirationtype_); } -inline const ::SessionProtos::DataExtractionNotification& Content::dataextractionnotification() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.dataExtractionNotification) - return _internal_dataextractionnotification(); +inline ::SessionProtos::Content_ExpirationType Content::expirationtype() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.expirationType) + return _internal_expirationtype(); } -inline void Content::unsafe_arena_set_allocated_dataextractionnotification( - ::SessionProtos::DataExtractionNotification* dataextractionnotification) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.dataextractionnotification_); - } - _impl_.dataextractionnotification_ = dataextractionnotification; - if (dataextractionnotification) { - _impl_._has_bits_[0] |= 0x00000020u; - } else { - _impl_._has_bits_[0] &= ~0x00000020u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.dataExtractionNotification) +inline void Content::_internal_set_expirationtype(::SessionProtos::Content_ExpirationType value) { + assert(::SessionProtos::Content_ExpirationType_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000100u; + _impl_.expirationtype_ = value; } -inline ::SessionProtos::DataExtractionNotification* Content::release_dataextractionnotification() { - _impl_._has_bits_[0] &= ~0x00000020u; - ::SessionProtos::DataExtractionNotification* temp = _impl_.dataextractionnotification_; - _impl_.dataextractionnotification_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::DataExtractionNotification* Content::unsafe_arena_release_dataextractionnotification() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.dataExtractionNotification) - _impl_._has_bits_[0] &= ~0x00000020u; - ::SessionProtos::DataExtractionNotification* temp = _impl_.dataextractionnotification_; - _impl_.dataextractionnotification_ = nullptr; - return temp; -} -inline ::SessionProtos::DataExtractionNotification* Content::_internal_mutable_dataextractionnotification() { - _impl_._has_bits_[0] |= 0x00000020u; - if (_impl_.dataextractionnotification_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataExtractionNotification>(GetArenaForAllocation()); - _impl_.dataextractionnotification_ = p; - } - return _impl_.dataextractionnotification_; -} -inline ::SessionProtos::DataExtractionNotification* Content::mutable_dataextractionnotification() { - ::SessionProtos::DataExtractionNotification* _msg = _internal_mutable_dataextractionnotification(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.dataExtractionNotification) - return _msg; -} -inline void Content::set_allocated_dataextractionnotification(::SessionProtos::DataExtractionNotification* dataextractionnotification) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.dataextractionnotification_; - } - if (dataextractionnotification) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(dataextractionnotification); - if (message_arena != submessage_arena) { - dataextractionnotification = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, dataextractionnotification, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000020u; - } else { - _impl_._has_bits_[0] &= ~0x00000020u; - } - _impl_.dataextractionnotification_ = dataextractionnotification; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.dataExtractionNotification) -} - -// optional .SessionProtos.UnsendRequest unsendRequest = 9; -inline bool Content::_internal_has_unsendrequest() const { - bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; - PROTOBUF_ASSUME(!value || _impl_.unsendrequest_ != nullptr); - return value; -} -inline bool Content::has_unsendrequest() const { - return _internal_has_unsendrequest(); -} -inline void Content::clear_unsendrequest() { - if (_impl_.unsendrequest_ != nullptr) _impl_.unsendrequest_->Clear(); - _impl_._has_bits_[0] &= ~0x00000040u; -} -inline const ::SessionProtos::UnsendRequest& Content::_internal_unsendrequest() const { - const ::SessionProtos::UnsendRequest* p = _impl_.unsendrequest_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_UnsendRequest_default_instance_); -} -inline const ::SessionProtos::UnsendRequest& Content::unsendrequest() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.unsendRequest) - return _internal_unsendrequest(); -} -inline void Content::unsafe_arena_set_allocated_unsendrequest( - ::SessionProtos::UnsendRequest* unsendrequest) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.unsendrequest_); - } - _impl_.unsendrequest_ = unsendrequest; - if (unsendrequest) { - _impl_._has_bits_[0] |= 0x00000040u; - } else { - _impl_._has_bits_[0] &= ~0x00000040u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.unsendRequest) -} -inline ::SessionProtos::UnsendRequest* Content::release_unsendrequest() { - _impl_._has_bits_[0] &= ~0x00000040u; - ::SessionProtos::UnsendRequest* temp = _impl_.unsendrequest_; - _impl_.unsendrequest_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::UnsendRequest* Content::unsafe_arena_release_unsendrequest() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.unsendRequest) - _impl_._has_bits_[0] &= ~0x00000040u; - ::SessionProtos::UnsendRequest* temp = _impl_.unsendrequest_; - _impl_.unsendrequest_ = nullptr; - return temp; -} -inline ::SessionProtos::UnsendRequest* Content::_internal_mutable_unsendrequest() { - _impl_._has_bits_[0] |= 0x00000040u; - if (_impl_.unsendrequest_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::UnsendRequest>(GetArenaForAllocation()); - _impl_.unsendrequest_ = p; - } - return _impl_.unsendrequest_; -} -inline ::SessionProtos::UnsendRequest* Content::mutable_unsendrequest() { - ::SessionProtos::UnsendRequest* _msg = _internal_mutable_unsendrequest(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.unsendRequest) - return _msg; -} -inline void Content::set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.unsendrequest_; - } - if (unsendrequest) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(unsendrequest); - if (message_arena != submessage_arena) { - unsendrequest = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, unsendrequest, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000040u; - } else { - _impl_._has_bits_[0] &= ~0x00000040u; - } - _impl_.unsendrequest_ = unsendrequest; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.unsendRequest) -} - -// optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; -inline bool Content::_internal_has_messagerequestresponse() const { - bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; - PROTOBUF_ASSUME(!value || _impl_.messagerequestresponse_ != nullptr); - return value; -} -inline bool Content::has_messagerequestresponse() const { - return _internal_has_messagerequestresponse(); -} -inline void Content::clear_messagerequestresponse() { - if (_impl_.messagerequestresponse_ != nullptr) _impl_.messagerequestresponse_->Clear(); - _impl_._has_bits_[0] &= ~0x00000080u; -} -inline const ::SessionProtos::MessageRequestResponse& Content::_internal_messagerequestresponse() const { - const ::SessionProtos::MessageRequestResponse* p = _impl_.messagerequestresponse_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_MessageRequestResponse_default_instance_); -} -inline const ::SessionProtos::MessageRequestResponse& Content::messagerequestresponse() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.messageRequestResponse) - return _internal_messagerequestresponse(); -} -inline void Content::unsafe_arena_set_allocated_messagerequestresponse( - ::SessionProtos::MessageRequestResponse* messagerequestresponse) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.messagerequestresponse_); - } - _impl_.messagerequestresponse_ = messagerequestresponse; - if (messagerequestresponse) { - _impl_._has_bits_[0] |= 0x00000080u; - } else { - _impl_._has_bits_[0] &= ~0x00000080u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.messageRequestResponse) -} -inline ::SessionProtos::MessageRequestResponse* Content::release_messagerequestresponse() { - _impl_._has_bits_[0] &= ~0x00000080u; - ::SessionProtos::MessageRequestResponse* temp = _impl_.messagerequestresponse_; - _impl_.messagerequestresponse_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::MessageRequestResponse* Content::unsafe_arena_release_messagerequestresponse() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.messageRequestResponse) - _impl_._has_bits_[0] &= ~0x00000080u; - ::SessionProtos::MessageRequestResponse* temp = _impl_.messagerequestresponse_; - _impl_.messagerequestresponse_ = nullptr; - return temp; -} -inline ::SessionProtos::MessageRequestResponse* Content::_internal_mutable_messagerequestresponse() { - _impl_._has_bits_[0] |= 0x00000080u; - if (_impl_.messagerequestresponse_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(GetArenaForAllocation()); - _impl_.messagerequestresponse_ = p; - } - return _impl_.messagerequestresponse_; -} -inline ::SessionProtos::MessageRequestResponse* Content::mutable_messagerequestresponse() { - ::SessionProtos::MessageRequestResponse* _msg = _internal_mutable_messagerequestresponse(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.messageRequestResponse) - return _msg; -} -inline void Content::set_allocated_messagerequestresponse(::SessionProtos::MessageRequestResponse* messagerequestresponse) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.messagerequestresponse_; - } - if (messagerequestresponse) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(messagerequestresponse); - if (message_arena != submessage_arena) { - messagerequestresponse = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, messagerequestresponse, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000080u; - } else { - _impl_._has_bits_[0] &= ~0x00000080u; - } - _impl_.messagerequestresponse_ = messagerequestresponse; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.messageRequestResponse) -} - -// optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; -inline bool Content::_internal_has_sharedconfigmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; - PROTOBUF_ASSUME(!value || _impl_.sharedconfigmessage_ != nullptr); - return value; -} -inline bool Content::has_sharedconfigmessage() const { - return _internal_has_sharedconfigmessage(); -} -inline void Content::clear_sharedconfigmessage() { - if (_impl_.sharedconfigmessage_ != nullptr) _impl_.sharedconfigmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000100u; -} -inline const ::SessionProtos::SharedConfigMessage& Content::_internal_sharedconfigmessage() const { - const ::SessionProtos::SharedConfigMessage* p = _impl_.sharedconfigmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_SharedConfigMessage_default_instance_); -} -inline const ::SessionProtos::SharedConfigMessage& Content::sharedconfigmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.sharedConfigMessage) - return _internal_sharedconfigmessage(); -} -inline void Content::unsafe_arena_set_allocated_sharedconfigmessage( - ::SessionProtos::SharedConfigMessage* sharedconfigmessage) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.sharedconfigmessage_); - } - _impl_.sharedconfigmessage_ = sharedconfigmessage; - if (sharedconfigmessage) { - _impl_._has_bits_[0] |= 0x00000100u; - } else { - _impl_._has_bits_[0] &= ~0x00000100u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.sharedConfigMessage) -} -inline ::SessionProtos::SharedConfigMessage* Content::release_sharedconfigmessage() { - _impl_._has_bits_[0] &= ~0x00000100u; - ::SessionProtos::SharedConfigMessage* temp = _impl_.sharedconfigmessage_; - _impl_.sharedconfigmessage_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::SharedConfigMessage* Content::unsafe_arena_release_sharedconfigmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.sharedConfigMessage) - _impl_._has_bits_[0] &= ~0x00000100u; - ::SessionProtos::SharedConfigMessage* temp = _impl_.sharedconfigmessage_; - _impl_.sharedconfigmessage_ = nullptr; - return temp; -} -inline ::SessionProtos::SharedConfigMessage* Content::_internal_mutable_sharedconfigmessage() { - _impl_._has_bits_[0] |= 0x00000100u; - if (_impl_.sharedconfigmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::SharedConfigMessage>(GetArenaForAllocation()); - _impl_.sharedconfigmessage_ = p; - } - return _impl_.sharedconfigmessage_; -} -inline ::SessionProtos::SharedConfigMessage* Content::mutable_sharedconfigmessage() { - ::SessionProtos::SharedConfigMessage* _msg = _internal_mutable_sharedconfigmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.sharedConfigMessage) - return _msg; -} -inline void Content::set_allocated_sharedconfigmessage(::SessionProtos::SharedConfigMessage* sharedconfigmessage) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.sharedconfigmessage_; - } - if (sharedconfigmessage) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(sharedconfigmessage); - if (message_arena != submessage_arena) { - sharedconfigmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, sharedconfigmessage, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000100u; - } else { - _impl_._has_bits_[0] &= ~0x00000100u; - } - _impl_.sharedconfigmessage_ = sharedconfigmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.sharedConfigMessage) +inline void Content::set_expirationtype(::SessionProtos::Content_ExpirationType value) { + _internal_set_expirationtype(value); + // @@protoc_insertion_point(field_set:SessionProtos.Content.expirationType) } -// optional .SessionProtos.ProMessageConfig proMessageConfig = 12; -inline bool Content::_internal_has_promessageconfig() const { +// optional uint32 expirationTimer = 13; +inline bool Content::_internal_has_expirationtimer() const { bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; - PROTOBUF_ASSUME(!value || _impl_.promessageconfig_ != nullptr); return value; } -inline bool Content::has_promessageconfig() const { - return _internal_has_promessageconfig(); +inline bool Content::has_expirationtimer() const { + return _internal_has_expirationtimer(); } -inline void Content::clear_promessageconfig() { - if (_impl_.promessageconfig_ != nullptr) _impl_.promessageconfig_->Clear(); +inline void Content::clear_expirationtimer() { + _impl_.expirationtimer_ = 0u; _impl_._has_bits_[0] &= ~0x00000200u; } -inline const ::SessionProtos::ProMessageConfig& Content::_internal_promessageconfig() const { - const ::SessionProtos::ProMessageConfig* p = _impl_.promessageconfig_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ProMessageConfig_default_instance_); +inline uint32_t Content::_internal_expirationtimer() const { + return _impl_.expirationtimer_; } -inline const ::SessionProtos::ProMessageConfig& Content::promessageconfig() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.proMessageConfig) - return _internal_promessageconfig(); +inline uint32_t Content::expirationtimer() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.expirationTimer) + return _internal_expirationtimer(); } -inline void Content::unsafe_arena_set_allocated_promessageconfig( - ::SessionProtos::ProMessageConfig* promessageconfig) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.promessageconfig_); - } - _impl_.promessageconfig_ = promessageconfig; - if (promessageconfig) { - _impl_._has_bits_[0] |= 0x00000200u; - } else { - _impl_._has_bits_[0] &= ~0x00000200u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.proMessageConfig) +inline void Content::_internal_set_expirationtimer(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000200u; + _impl_.expirationtimer_ = value; } -inline ::SessionProtos::ProMessageConfig* Content::release_promessageconfig() { - _impl_._has_bits_[0] &= ~0x00000200u; - ::SessionProtos::ProMessageConfig* temp = _impl_.promessageconfig_; - _impl_.promessageconfig_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; +inline void Content::set_expirationtimer(uint32_t value) { + _internal_set_expirationtimer(value); + // @@protoc_insertion_point(field_set:SessionProtos.Content.expirationTimer) } -inline ::SessionProtos::ProMessageConfig* Content::unsafe_arena_release_promessageconfig() { - // @@protoc_insertion_point(field_release:SessionProtos.Content.proMessageConfig) - _impl_._has_bits_[0] &= ~0x00000200u; - ::SessionProtos::ProMessageConfig* temp = _impl_.promessageconfig_; - _impl_.promessageconfig_ = nullptr; - return temp; + +// optional uint64 sigTimestamp = 15; +inline bool Content::_internal_has_sigtimestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; + return value; } -inline ::SessionProtos::ProMessageConfig* Content::_internal_mutable_promessageconfig() { - _impl_._has_bits_[0] |= 0x00000200u; - if (_impl_.promessageconfig_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ProMessageConfig>(GetArenaForAllocation()); - _impl_.promessageconfig_ = p; - } - return _impl_.promessageconfig_; +inline bool Content::has_sigtimestamp() const { + return _internal_has_sigtimestamp(); } -inline ::SessionProtos::ProMessageConfig* Content::mutable_promessageconfig() { - ::SessionProtos::ProMessageConfig* _msg = _internal_mutable_promessageconfig(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Content.proMessageConfig) - return _msg; +inline void Content::clear_sigtimestamp() { + _impl_.sigtimestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000400u; } -inline void Content::set_allocated_promessageconfig(::SessionProtos::ProMessageConfig* promessageconfig) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.promessageconfig_; - } - if (promessageconfig) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(promessageconfig); - if (message_arena != submessage_arena) { - promessageconfig = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, promessageconfig, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000200u; - } else { - _impl_._has_bits_[0] &= ~0x00000200u; - } - _impl_.promessageconfig_ = promessageconfig; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.proMessageConfig) +inline uint64_t Content::_internal_sigtimestamp() const { + return _impl_.sigtimestamp_; +} +inline uint64_t Content::sigtimestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.sigTimestamp) + return _internal_sigtimestamp(); +} +inline void Content::_internal_set_sigtimestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000400u; + _impl_.sigtimestamp_ = value; +} +inline void Content::set_sigtimestamp(uint64_t value) { + _internal_set_sigtimestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.Content.sigTimestamp) } // ------------------------------------------------------------------- @@ -9954,387 +9809,78 @@ inline void DataMessage_OpenGroupInvitation::_internal_set_url(const std::string } inline std::string* DataMessage_OpenGroupInvitation::_internal_mutable_url() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.url_.Mutable(GetArenaForAllocation()); -} -inline std::string* DataMessage_OpenGroupInvitation::release_url() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.OpenGroupInvitation.url) - if (!_internal_has_url()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.url_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.url_.IsDefault()) { - _impl_.url_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void DataMessage_OpenGroupInvitation::set_allocated_url(std::string* url) { - if (url != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.url_.SetAllocated(url, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.url_.IsDefault()) { - _impl_.url_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.OpenGroupInvitation.url) -} - -// required string name = 3; -inline bool DataMessage_OpenGroupInvitation::_internal_has_name() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool DataMessage_OpenGroupInvitation::has_name() const { - return _internal_has_name(); -} -inline void DataMessage_OpenGroupInvitation::clear_name() { - _impl_.name_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const std::string& DataMessage_OpenGroupInvitation::name() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.OpenGroupInvitation.name) - return _internal_name(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void DataMessage_OpenGroupInvitation::set_name(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.OpenGroupInvitation.name) -} -inline std::string* DataMessage_OpenGroupInvitation::mutable_name() { - std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.OpenGroupInvitation.name) - return _s; -} -inline const std::string& DataMessage_OpenGroupInvitation::_internal_name() const { - return _impl_.name_.Get(); -} -inline void DataMessage_OpenGroupInvitation::_internal_set_name(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(value, GetArenaForAllocation()); -} -inline std::string* DataMessage_OpenGroupInvitation::_internal_mutable_name() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.name_.Mutable(GetArenaForAllocation()); -} -inline std::string* DataMessage_OpenGroupInvitation::release_name() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.OpenGroupInvitation.name) - if (!_internal_has_name()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.name_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void DataMessage_OpenGroupInvitation::set_allocated_name(std::string* name) { - if (name != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.name_.SetAllocated(name, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.OpenGroupInvitation.name) -} - -// ------------------------------------------------------------------- - -// DataMessage_ClosedGroupControlMessage_KeyPairWrapper - -// required bytes publicKey = 1; -inline bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_has_publickey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::has_publickey() const { - return _internal_has_publickey(); -} -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::clear_publickey() { - _impl_.publickey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& DataMessage_ClosedGroupControlMessage_KeyPairWrapper::publickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.publicKey) - return _internal_publickey(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::set_publickey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.publicKey) -} -inline std::string* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::mutable_publickey() { - std::string* _s = _internal_mutable_publickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.publicKey) - return _s; -} -inline const std::string& DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_publickey() const { - return _impl_.publickey_.Get(); -} -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_set_publickey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.Set(value, GetArenaForAllocation()); -} -inline std::string* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_mutable_publickey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.publickey_.Mutable(GetArenaForAllocation()); -} -inline std::string* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::release_publickey() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.publicKey) - if (!_internal_has_publickey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.publickey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::set_allocated_publickey(std::string* publickey) { - if (publickey != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.publickey_.SetAllocated(publickey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.publicKey) -} - -// required bytes encryptedKeyPair = 2; -inline bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_has_encryptedkeypair() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool DataMessage_ClosedGroupControlMessage_KeyPairWrapper::has_encryptedkeypair() const { - return _internal_has_encryptedkeypair(); -} -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::clear_encryptedkeypair() { - _impl_.encryptedkeypair_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const std::string& DataMessage_ClosedGroupControlMessage_KeyPairWrapper::encryptedkeypair() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.encryptedKeyPair) - return _internal_encryptedkeypair(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::set_encryptedkeypair(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.encryptedkeypair_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.encryptedKeyPair) -} -inline std::string* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::mutable_encryptedkeypair() { - std::string* _s = _internal_mutable_encryptedkeypair(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.encryptedKeyPair) - return _s; -} -inline const std::string& DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_encryptedkeypair() const { - return _impl_.encryptedkeypair_.Get(); -} -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_set_encryptedkeypair(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.encryptedkeypair_.Set(value, GetArenaForAllocation()); -} -inline std::string* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::_internal_mutable_encryptedkeypair() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.encryptedkeypair_.Mutable(GetArenaForAllocation()); -} -inline std::string* DataMessage_ClosedGroupControlMessage_KeyPairWrapper::release_encryptedkeypair() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.encryptedKeyPair) - if (!_internal_has_encryptedkeypair()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.encryptedkeypair_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.encryptedkeypair_.IsDefault()) { - _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void DataMessage_ClosedGroupControlMessage_KeyPairWrapper::set_allocated_encryptedkeypair(std::string* encryptedkeypair) { - if (encryptedkeypair != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.encryptedkeypair_.SetAllocated(encryptedkeypair, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.encryptedkeypair_.IsDefault()) { - _impl_.encryptedkeypair_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper.encryptedKeyPair) -} - -// ------------------------------------------------------------------- - -// DataMessage_ClosedGroupControlMessage - -// required .SessionProtos.DataMessage.ClosedGroupControlMessage.Type type = 1; -inline bool DataMessage_ClosedGroupControlMessage::_internal_has_type() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - return value; -} -inline bool DataMessage_ClosedGroupControlMessage::has_type() const { - return _internal_has_type(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_type() { - _impl_.type_ = 1; - _impl_._has_bits_[0] &= ~0x00000010u; -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::_internal_type() const { - return static_cast< ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type >(_impl_.type_); -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type DataMessage_ClosedGroupControlMessage::type() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.type) - return _internal_type(); -} -inline void DataMessage_ClosedGroupControlMessage::_internal_set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value) { - assert(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.type_ = value; -} -inline void DataMessage_ClosedGroupControlMessage::set_type(::SessionProtos::DataMessage_ClosedGroupControlMessage_Type value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.type) -} - -// optional bytes publicKey = 2; -inline bool DataMessage_ClosedGroupControlMessage::_internal_has_publickey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool DataMessage_ClosedGroupControlMessage::has_publickey() const { - return _internal_has_publickey(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_publickey() { - _impl_.publickey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& DataMessage_ClosedGroupControlMessage::publickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.publicKey) - return _internal_publickey(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void DataMessage_ClosedGroupControlMessage::set_publickey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.publicKey) -} -inline std::string* DataMessage_ClosedGroupControlMessage::mutable_publickey() { - std::string* _s = _internal_mutable_publickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.publicKey) - return _s; -} -inline const std::string& DataMessage_ClosedGroupControlMessage::_internal_publickey() const { - return _impl_.publickey_.Get(); -} -inline void DataMessage_ClosedGroupControlMessage::_internal_set_publickey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.Set(value, GetArenaForAllocation()); -} -inline std::string* DataMessage_ClosedGroupControlMessage::_internal_mutable_publickey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.publickey_.Mutable(GetArenaForAllocation()); + return _impl_.url_.Mutable(GetArenaForAllocation()); } -inline std::string* DataMessage_ClosedGroupControlMessage::release_publickey() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.ClosedGroupControlMessage.publicKey) - if (!_internal_has_publickey()) { +inline std::string* DataMessage_OpenGroupInvitation::release_url() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.OpenGroupInvitation.url) + if (!_internal_has_url()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.publickey_.Release(); + auto* p = _impl_.url_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void DataMessage_ClosedGroupControlMessage::set_allocated_publickey(std::string* publickey) { - if (publickey != nullptr) { +inline void DataMessage_OpenGroupInvitation::set_allocated_url(std::string* url) { + if (url != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.publickey_.SetAllocated(publickey, GetArenaForAllocation()); + _impl_.url_.SetAllocated(url, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.ClosedGroupControlMessage.publicKey) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.OpenGroupInvitation.url) } -// optional string name = 3; -inline bool DataMessage_ClosedGroupControlMessage::_internal_has_name() const { +// required string name = 3; +inline bool DataMessage_OpenGroupInvitation::_internal_has_name() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool DataMessage_ClosedGroupControlMessage::has_name() const { +inline bool DataMessage_OpenGroupInvitation::has_name() const { return _internal_has_name(); } -inline void DataMessage_ClosedGroupControlMessage::clear_name() { +inline void DataMessage_OpenGroupInvitation::clear_name() { _impl_.name_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const std::string& DataMessage_ClosedGroupControlMessage::name() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.name) +inline const std::string& DataMessage_OpenGroupInvitation::name() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.OpenGroupInvitation.name) return _internal_name(); } template inline PROTOBUF_ALWAYS_INLINE -void DataMessage_ClosedGroupControlMessage::set_name(ArgT0&& arg0, ArgT... args) { +void DataMessage_OpenGroupInvitation::set_name(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000002u; _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.name) + // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.OpenGroupInvitation.name) } -inline std::string* DataMessage_ClosedGroupControlMessage::mutable_name() { +inline std::string* DataMessage_OpenGroupInvitation::mutable_name() { std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.name) + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.OpenGroupInvitation.name) return _s; } -inline const std::string& DataMessage_ClosedGroupControlMessage::_internal_name() const { +inline const std::string& DataMessage_OpenGroupInvitation::_internal_name() const { return _impl_.name_.Get(); } -inline void DataMessage_ClosedGroupControlMessage::_internal_set_name(const std::string& value) { +inline void DataMessage_OpenGroupInvitation::_internal_set_name(const std::string& value) { _impl_._has_bits_[0] |= 0x00000002u; _impl_.name_.Set(value, GetArenaForAllocation()); } -inline std::string* DataMessage_ClosedGroupControlMessage::_internal_mutable_name() { +inline std::string* DataMessage_OpenGroupInvitation::_internal_mutable_name() { _impl_._has_bits_[0] |= 0x00000002u; return _impl_.name_.Mutable(GetArenaForAllocation()); } -inline std::string* DataMessage_ClosedGroupControlMessage::release_name() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.ClosedGroupControlMessage.name) +inline std::string* DataMessage_OpenGroupInvitation::release_name() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.OpenGroupInvitation.name) if (!_internal_has_name()) { return nullptr; } @@ -10347,7 +9893,7 @@ inline std::string* DataMessage_ClosedGroupControlMessage::release_name() { #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void DataMessage_ClosedGroupControlMessage::set_allocated_name(std::string* name) { +inline void DataMessage_OpenGroupInvitation::set_allocated_name(std::string* name) { if (name != nullptr) { _impl_._has_bits_[0] |= 0x00000002u; } else { @@ -10359,315 +9905,7 @@ inline void DataMessage_ClosedGroupControlMessage::set_allocated_name(std::strin _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.ClosedGroupControlMessage.name) -} - -// optional .SessionProtos.KeyPair encryptionKeyPair = 4; -inline bool DataMessage_ClosedGroupControlMessage::_internal_has_encryptionkeypair() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - PROTOBUF_ASSUME(!value || _impl_.encryptionkeypair_ != nullptr); - return value; -} -inline bool DataMessage_ClosedGroupControlMessage::has_encryptionkeypair() const { - return _internal_has_encryptionkeypair(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_encryptionkeypair() { - if (_impl_.encryptionkeypair_ != nullptr) _impl_.encryptionkeypair_->Clear(); - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline const ::SessionProtos::KeyPair& DataMessage_ClosedGroupControlMessage::_internal_encryptionkeypair() const { - const ::SessionProtos::KeyPair* p = _impl_.encryptionkeypair_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_KeyPair_default_instance_); -} -inline const ::SessionProtos::KeyPair& DataMessage_ClosedGroupControlMessage::encryptionkeypair() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.encryptionKeyPair) - return _internal_encryptionkeypair(); -} -inline void DataMessage_ClosedGroupControlMessage::unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.encryptionkeypair_); - } - _impl_.encryptionkeypair_ = encryptionkeypair; - if (encryptionkeypair) { - _impl_._has_bits_[0] |= 0x00000004u; - } else { - _impl_._has_bits_[0] &= ~0x00000004u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.ClosedGroupControlMessage.encryptionKeyPair) -} -inline ::SessionProtos::KeyPair* DataMessage_ClosedGroupControlMessage::release_encryptionkeypair() { - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; - _impl_.encryptionkeypair_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::KeyPair* DataMessage_ClosedGroupControlMessage::unsafe_arena_release_encryptionkeypair() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.ClosedGroupControlMessage.encryptionKeyPair) - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; - _impl_.encryptionkeypair_ = nullptr; - return temp; -} -inline ::SessionProtos::KeyPair* DataMessage_ClosedGroupControlMessage::_internal_mutable_encryptionkeypair() { - _impl_._has_bits_[0] |= 0x00000004u; - if (_impl_.encryptionkeypair_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::KeyPair>(GetArenaForAllocation()); - _impl_.encryptionkeypair_ = p; - } - return _impl_.encryptionkeypair_; -} -inline ::SessionProtos::KeyPair* DataMessage_ClosedGroupControlMessage::mutable_encryptionkeypair() { - ::SessionProtos::KeyPair* _msg = _internal_mutable_encryptionkeypair(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.encryptionKeyPair) - return _msg; -} -inline void DataMessage_ClosedGroupControlMessage::set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.encryptionkeypair_; - } - if (encryptionkeypair) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(encryptionkeypair); - if (message_arena != submessage_arena) { - encryptionkeypair = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, encryptionkeypair, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000004u; - } else { - _impl_._has_bits_[0] &= ~0x00000004u; - } - _impl_.encryptionkeypair_ = encryptionkeypair; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.ClosedGroupControlMessage.encryptionKeyPair) -} - -// repeated bytes members = 5; -inline int DataMessage_ClosedGroupControlMessage::_internal_members_size() const { - return _impl_.members_.size(); -} -inline int DataMessage_ClosedGroupControlMessage::members_size() const { - return _internal_members_size(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_members() { - _impl_.members_.Clear(); -} -inline std::string* DataMessage_ClosedGroupControlMessage::add_members() { - std::string* _s = _internal_add_members(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.members) - return _s; -} -inline const std::string& DataMessage_ClosedGroupControlMessage::_internal_members(int index) const { - return _impl_.members_.Get(index); -} -inline const std::string& DataMessage_ClosedGroupControlMessage::members(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.members) - return _internal_members(index); -} -inline std::string* DataMessage_ClosedGroupControlMessage::mutable_members(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.members) - return _impl_.members_.Mutable(index); -} -inline void DataMessage_ClosedGroupControlMessage::set_members(int index, const std::string& value) { - _impl_.members_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline void DataMessage_ClosedGroupControlMessage::set_members(int index, std::string&& value) { - _impl_.members_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline void DataMessage_ClosedGroupControlMessage::set_members(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.members_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline void DataMessage_ClosedGroupControlMessage::set_members(int index, const void* value, size_t size) { - _impl_.members_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline std::string* DataMessage_ClosedGroupControlMessage::_internal_add_members() { - return _impl_.members_.Add(); -} -inline void DataMessage_ClosedGroupControlMessage::add_members(const std::string& value) { - _impl_.members_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline void DataMessage_ClosedGroupControlMessage::add_members(std::string&& value) { - _impl_.members_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline void DataMessage_ClosedGroupControlMessage::add_members(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.members_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline void DataMessage_ClosedGroupControlMessage::add_members(const void* value, size_t size) { - _impl_.members_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.DataMessage.ClosedGroupControlMessage.members) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -DataMessage_ClosedGroupControlMessage::members() const { - // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.ClosedGroupControlMessage.members) - return _impl_.members_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -DataMessage_ClosedGroupControlMessage::mutable_members() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.ClosedGroupControlMessage.members) - return &_impl_.members_; -} - -// repeated bytes admins = 6; -inline int DataMessage_ClosedGroupControlMessage::_internal_admins_size() const { - return _impl_.admins_.size(); -} -inline int DataMessage_ClosedGroupControlMessage::admins_size() const { - return _internal_admins_size(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_admins() { - _impl_.admins_.Clear(); -} -inline std::string* DataMessage_ClosedGroupControlMessage::add_admins() { - std::string* _s = _internal_add_admins(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) - return _s; -} -inline const std::string& DataMessage_ClosedGroupControlMessage::_internal_admins(int index) const { - return _impl_.admins_.Get(index); -} -inline const std::string& DataMessage_ClosedGroupControlMessage::admins(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) - return _internal_admins(index); -} -inline std::string* DataMessage_ClosedGroupControlMessage::mutable_admins(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) - return _impl_.admins_.Mutable(index); -} -inline void DataMessage_ClosedGroupControlMessage::set_admins(int index, const std::string& value) { - _impl_.admins_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline void DataMessage_ClosedGroupControlMessage::set_admins(int index, std::string&& value) { - _impl_.admins_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline void DataMessage_ClosedGroupControlMessage::set_admins(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.admins_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline void DataMessage_ClosedGroupControlMessage::set_admins(int index, const void* value, size_t size) { - _impl_.admins_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline std::string* DataMessage_ClosedGroupControlMessage::_internal_add_admins() { - return _impl_.admins_.Add(); -} -inline void DataMessage_ClosedGroupControlMessage::add_admins(const std::string& value) { - _impl_.admins_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline void DataMessage_ClosedGroupControlMessage::add_admins(std::string&& value) { - _impl_.admins_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline void DataMessage_ClosedGroupControlMessage::add_admins(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.admins_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline void DataMessage_ClosedGroupControlMessage::add_admins(const void* value, size_t size) { - _impl_.admins_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -DataMessage_ClosedGroupControlMessage::admins() const { - // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) - return _impl_.admins_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -DataMessage_ClosedGroupControlMessage::mutable_admins() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.ClosedGroupControlMessage.admins) - return &_impl_.admins_; -} - -// repeated .SessionProtos.DataMessage.ClosedGroupControlMessage.KeyPairWrapper wrappers = 7; -inline int DataMessage_ClosedGroupControlMessage::_internal_wrappers_size() const { - return _impl_.wrappers_.size(); -} -inline int DataMessage_ClosedGroupControlMessage::wrappers_size() const { - return _internal_wrappers_size(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_wrappers() { - _impl_.wrappers_.Clear(); -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* DataMessage_ClosedGroupControlMessage::mutable_wrappers(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.ClosedGroupControlMessage.wrappers) - return _impl_.wrappers_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >* -DataMessage_ClosedGroupControlMessage::mutable_wrappers() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.DataMessage.ClosedGroupControlMessage.wrappers) - return &_impl_.wrappers_; -} -inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& DataMessage_ClosedGroupControlMessage::_internal_wrappers(int index) const { - return _impl_.wrappers_.Get(index); -} -inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper& DataMessage_ClosedGroupControlMessage::wrappers(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.wrappers) - return _internal_wrappers(index); -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* DataMessage_ClosedGroupControlMessage::_internal_add_wrappers() { - return _impl_.wrappers_.Add(); -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* DataMessage_ClosedGroupControlMessage::add_wrappers() { - ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper* _add = _internal_add_wrappers(); - // @@protoc_insertion_point(field_add:SessionProtos.DataMessage.ClosedGroupControlMessage.wrappers) - return _add; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::DataMessage_ClosedGroupControlMessage_KeyPairWrapper >& -DataMessage_ClosedGroupControlMessage::wrappers() const { - // @@protoc_insertion_point(field_list:SessionProtos.DataMessage.ClosedGroupControlMessage.wrappers) - return _impl_.wrappers_; -} - -// optional uint32 expirationTimer = 8; -inline bool DataMessage_ClosedGroupControlMessage::_internal_has_expirationtimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool DataMessage_ClosedGroupControlMessage::has_expirationtimer() const { - return _internal_has_expirationtimer(); -} -inline void DataMessage_ClosedGroupControlMessage::clear_expirationtimer() { - _impl_.expirationtimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000008u; -} -inline uint32_t DataMessage_ClosedGroupControlMessage::_internal_expirationtimer() const { - return _impl_.expirationtimer_; -} -inline uint32_t DataMessage_ClosedGroupControlMessage::expirationtimer() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.ClosedGroupControlMessage.expirationTimer) - return _internal_expirationtimer(); -} -inline void DataMessage_ClosedGroupControlMessage::_internal_set_expirationtimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.expirationtimer_ = value; -} -inline void DataMessage_ClosedGroupControlMessage::set_expirationtimer(uint32_t value) { - _internal_set_expirationtimer(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.ClosedGroupControlMessage.expirationTimer) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.OpenGroupInvitation.name) } // ------------------------------------------------------------------- @@ -10784,7 +10022,7 @@ DataMessage::attachments() const { // optional uint32 flags = 4; inline bool DataMessage::_internal_has_flags() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; return value; } inline bool DataMessage::has_flags() const { @@ -10792,7 +10030,7 @@ inline bool DataMessage::has_flags() const { } inline void DataMessage::clear_flags() { _impl_.flags_ = 0u; - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; } inline uint32_t DataMessage::_internal_flags() const { return _impl_.flags_; @@ -10802,7 +10040,7 @@ inline uint32_t DataMessage::flags() const { return _internal_flags(); } inline void DataMessage::_internal_set_flags(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000200u; _impl_.flags_ = value; } inline void DataMessage::set_flags(uint32_t value) { @@ -10810,34 +10048,6 @@ inline void DataMessage::set_flags(uint32_t value) { // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.flags) } -// optional uint32 expireTimer = 5; -inline bool DataMessage::_internal_has_expiretimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; - return value; -} -inline bool DataMessage::has_expiretimer() const { - return _internal_has_expiretimer(); -} -inline void DataMessage::clear_expiretimer() { - _impl_.expiretimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000200u; -} -inline uint32_t DataMessage::_internal_expiretimer() const { - return _impl_.expiretimer_; -} -inline uint32_t DataMessage::expiretimer() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.expireTimer) - return _internal_expiretimer(); -} -inline void DataMessage::_internal_set_expiretimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000200u; - _impl_.expiretimer_ = value; -} -inline void DataMessage::set_expiretimer(uint32_t value) { - _internal_set_expiretimer(value); - // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.expireTimer) -} - // optional bytes profileKey = 6; inline bool DataMessage::_internal_has_profilekey() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; @@ -10908,7 +10118,7 @@ inline void DataMessage::set_allocated_profilekey(std::string* profilekey) { // optional uint64 timestamp = 7; inline bool DataMessage::_internal_has_timestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; return value; } inline bool DataMessage::has_timestamp() const { @@ -10916,7 +10126,7 @@ inline bool DataMessage::has_timestamp() const { } inline void DataMessage::clear_timestamp() { _impl_.timestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000400u; + _impl_._has_bits_[0] &= ~0x00000100u; } inline uint64_t DataMessage::_internal_timestamp() const { return _impl_.timestamp_; @@ -10926,7 +10136,7 @@ inline uint64_t DataMessage::timestamp() const { return _internal_timestamp(); } inline void DataMessage::_internal_set_timestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000400u; + _impl_._has_bits_[0] |= 0x00000100u; _impl_.timestamp_ = value; } inline void DataMessage::set_timestamp(uint64_t value) { @@ -11294,134 +10504,44 @@ inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::release_op #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::unsafe_arena_release_opengroupinvitation() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.openGroupInvitation) - _impl_._has_bits_[0] &= ~0x00000040u; - ::SessionProtos::DataMessage_OpenGroupInvitation* temp = _impl_.opengroupinvitation_; - _impl_.opengroupinvitation_ = nullptr; - return temp; -} -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::_internal_mutable_opengroupinvitation() { - _impl_._has_bits_[0] |= 0x00000040u; - if (_impl_.opengroupinvitation_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_OpenGroupInvitation>(GetArenaForAllocation()); - _impl_.opengroupinvitation_ = p; - } - return _impl_.opengroupinvitation_; -} -inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::mutable_opengroupinvitation() { - ::SessionProtos::DataMessage_OpenGroupInvitation* _msg = _internal_mutable_opengroupinvitation(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.openGroupInvitation) - return _msg; -} -inline void DataMessage::set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.opengroupinvitation_; - } - if (opengroupinvitation) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(opengroupinvitation); - if (message_arena != submessage_arena) { - opengroupinvitation = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, opengroupinvitation, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000040u; - } else { - _impl_._has_bits_[0] &= ~0x00000040u; - } - _impl_.opengroupinvitation_ = opengroupinvitation; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.openGroupInvitation) -} - -// optional .SessionProtos.DataMessage.ClosedGroupControlMessage closedGroupControlMessage = 104; -inline bool DataMessage::_internal_has_closedgroupcontrolmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; - PROTOBUF_ASSUME(!value || _impl_.closedgroupcontrolmessage_ != nullptr); - return value; -} -inline bool DataMessage::has_closedgroupcontrolmessage() const { - return _internal_has_closedgroupcontrolmessage(); -} -inline void DataMessage::clear_closedgroupcontrolmessage() { - if (_impl_.closedgroupcontrolmessage_ != nullptr) _impl_.closedgroupcontrolmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000080u; -} -inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage& DataMessage::_internal_closedgroupcontrolmessage() const { - const ::SessionProtos::DataMessage_ClosedGroupControlMessage* p = _impl_.closedgroupcontrolmessage_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_DataMessage_ClosedGroupControlMessage_default_instance_); -} -inline const ::SessionProtos::DataMessage_ClosedGroupControlMessage& DataMessage::closedgroupcontrolmessage() const { - // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.closedGroupControlMessage) - return _internal_closedgroupcontrolmessage(); -} -inline void DataMessage::unsafe_arena_set_allocated_closedgroupcontrolmessage( - ::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.closedgroupcontrolmessage_); - } - _impl_.closedgroupcontrolmessage_ = closedgroupcontrolmessage; - if (closedgroupcontrolmessage) { - _impl_._has_bits_[0] |= 0x00000080u; - } else { - _impl_._has_bits_[0] &= ~0x00000080u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.closedGroupControlMessage) -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::release_closedgroupcontrolmessage() { - _impl_._has_bits_[0] &= ~0x00000080u; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* temp = _impl_.closedgroupcontrolmessage_; - _impl_.closedgroupcontrolmessage_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::unsafe_arena_release_closedgroupcontrolmessage() { - // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.closedGroupControlMessage) - _impl_._has_bits_[0] &= ~0x00000080u; - ::SessionProtos::DataMessage_ClosedGroupControlMessage* temp = _impl_.closedgroupcontrolmessage_; - _impl_.closedgroupcontrolmessage_ = nullptr; +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::unsafe_arena_release_opengroupinvitation() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.openGroupInvitation) + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::DataMessage_OpenGroupInvitation* temp = _impl_.opengroupinvitation_; + _impl_.opengroupinvitation_ = nullptr; return temp; } -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::_internal_mutable_closedgroupcontrolmessage() { - _impl_._has_bits_[0] |= 0x00000080u; - if (_impl_.closedgroupcontrolmessage_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_ClosedGroupControlMessage>(GetArenaForAllocation()); - _impl_.closedgroupcontrolmessage_ = p; +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::_internal_mutable_opengroupinvitation() { + _impl_._has_bits_[0] |= 0x00000040u; + if (_impl_.opengroupinvitation_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::DataMessage_OpenGroupInvitation>(GetArenaForAllocation()); + _impl_.opengroupinvitation_ = p; } - return _impl_.closedgroupcontrolmessage_; + return _impl_.opengroupinvitation_; } -inline ::SessionProtos::DataMessage_ClosedGroupControlMessage* DataMessage::mutable_closedgroupcontrolmessage() { - ::SessionProtos::DataMessage_ClosedGroupControlMessage* _msg = _internal_mutable_closedgroupcontrolmessage(); - // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.closedGroupControlMessage) +inline ::SessionProtos::DataMessage_OpenGroupInvitation* DataMessage::mutable_opengroupinvitation() { + ::SessionProtos::DataMessage_OpenGroupInvitation* _msg = _internal_mutable_opengroupinvitation(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.openGroupInvitation) return _msg; } -inline void DataMessage::set_allocated_closedgroupcontrolmessage(::SessionProtos::DataMessage_ClosedGroupControlMessage* closedgroupcontrolmessage) { +inline void DataMessage::set_allocated_opengroupinvitation(::SessionProtos::DataMessage_OpenGroupInvitation* opengroupinvitation) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.closedgroupcontrolmessage_; + delete _impl_.opengroupinvitation_; } - if (closedgroupcontrolmessage) { + if (opengroupinvitation) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(closedgroupcontrolmessage); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(opengroupinvitation); if (message_arena != submessage_arena) { - closedgroupcontrolmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, closedgroupcontrolmessage, submessage_arena); + opengroupinvitation = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, opengroupinvitation, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000080u; + _impl_._has_bits_[0] |= 0x00000040u; } else { - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000040u; } - _impl_.closedgroupcontrolmessage_ = closedgroupcontrolmessage; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.closedGroupControlMessage) + _impl_.opengroupinvitation_ = opengroupinvitation; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.openGroupInvitation) } // optional string syncTarget = 105; @@ -11494,7 +10614,7 @@ inline void DataMessage::set_allocated_synctarget(std::string* synctarget) { // optional bool blocksCommunityMessageRequests = 106; inline bool DataMessage::_internal_has_blockscommunitymessagerequests() const { - bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } inline bool DataMessage::has_blockscommunitymessagerequests() const { @@ -11502,7 +10622,7 @@ inline bool DataMessage::has_blockscommunitymessagerequests() const { } inline void DataMessage::clear_blockscommunitymessagerequests() { _impl_.blockscommunitymessagerequests_ = false; - _impl_._has_bits_[0] &= ~0x00000800u; + _impl_._has_bits_[0] &= ~0x00000400u; } inline bool DataMessage::_internal_blockscommunitymessagerequests() const { return _impl_.blockscommunitymessagerequests_; @@ -11512,7 +10632,7 @@ inline bool DataMessage::blockscommunitymessagerequests() const { return _internal_blockscommunitymessagerequests(); } inline void DataMessage::_internal_set_blockscommunitymessagerequests(bool value) { - _impl_._has_bits_[0] |= 0x00000800u; + _impl_._has_bits_[0] |= 0x00000400u; _impl_.blockscommunitymessagerequests_ = value; } inline void DataMessage::set_blockscommunitymessagerequests(bool value) { @@ -11520,185 +10640,45 @@ inline void DataMessage::set_blockscommunitymessagerequests(bool value) { // @@protoc_insertion_point(field_set:SessionProtos.DataMessage.blocksCommunityMessageRequests) } -// ------------------------------------------------------------------- - -// ConfigurationMessage_ClosedGroup - -// optional bytes publicKey = 1; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_publickey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool ConfigurationMessage_ClosedGroup::has_publickey() const { - return _internal_has_publickey(); -} -inline void ConfigurationMessage_ClosedGroup::clear_publickey() { - _impl_.publickey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& ConfigurationMessage_ClosedGroup::publickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) - return _internal_publickey(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ClosedGroup::set_publickey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) -} -inline std::string* ConfigurationMessage_ClosedGroup::mutable_publickey() { - std::string* _s = _internal_mutable_publickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) - return _s; -} -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_publickey() const { - return _impl_.publickey_.Get(); -} -inline void ConfigurationMessage_ClosedGroup::_internal_set_publickey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.Set(value, GetArenaForAllocation()); -} -inline std::string* ConfigurationMessage_ClosedGroup::_internal_mutable_publickey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.publickey_.Mutable(GetArenaForAllocation()); -} -inline std::string* ConfigurationMessage_ClosedGroup::release_publickey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) - if (!_internal_has_publickey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.publickey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ConfigurationMessage_ClosedGroup::set_allocated_publickey(std::string* publickey) { - if (publickey != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.publickey_.SetAllocated(publickey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.publicKey) -} - -// optional string name = 2; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_name() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool ConfigurationMessage_ClosedGroup::has_name() const { - return _internal_has_name(); -} -inline void ConfigurationMessage_ClosedGroup::clear_name() { - _impl_.name_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const std::string& ConfigurationMessage_ClosedGroup::name() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.name) - return _internal_name(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_ClosedGroup::set_name(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.name) -} -inline std::string* ConfigurationMessage_ClosedGroup::mutable_name() { - std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.name) - return _s; -} -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_name() const { - return _impl_.name_.Get(); -} -inline void ConfigurationMessage_ClosedGroup::_internal_set_name(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(value, GetArenaForAllocation()); -} -inline std::string* ConfigurationMessage_ClosedGroup::_internal_mutable_name() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.name_.Mutable(GetArenaForAllocation()); -} -inline std::string* ConfigurationMessage_ClosedGroup::release_name() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.name) - if (!_internal_has_name()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.name_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ConfigurationMessage_ClosedGroup::set_allocated_name(std::string* name) { - if (name != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.name_.SetAllocated(name, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.name) -} - -// optional .SessionProtos.KeyPair encryptionKeyPair = 3; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_encryptionkeypair() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - PROTOBUF_ASSUME(!value || _impl_.encryptionkeypair_ != nullptr); +// optional .SessionProtos.GroupUpdateMessage groupUpdateMessage = 120; +inline bool DataMessage::_internal_has_groupupdatemessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + PROTOBUF_ASSUME(!value || _impl_.groupupdatemessage_ != nullptr); return value; } -inline bool ConfigurationMessage_ClosedGroup::has_encryptionkeypair() const { - return _internal_has_encryptionkeypair(); +inline bool DataMessage::has_groupupdatemessage() const { + return _internal_has_groupupdatemessage(); } -inline void ConfigurationMessage_ClosedGroup::clear_encryptionkeypair() { - if (_impl_.encryptionkeypair_ != nullptr) _impl_.encryptionkeypair_->Clear(); - _impl_._has_bits_[0] &= ~0x00000004u; +inline void DataMessage::clear_groupupdatemessage() { + if (_impl_.groupupdatemessage_ != nullptr) _impl_.groupupdatemessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000080u; } -inline const ::SessionProtos::KeyPair& ConfigurationMessage_ClosedGroup::_internal_encryptionkeypair() const { - const ::SessionProtos::KeyPair* p = _impl_.encryptionkeypair_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_KeyPair_default_instance_); +inline const ::SessionProtos::GroupUpdateMessage& DataMessage::_internal_groupupdatemessage() const { + const ::SessionProtos::GroupUpdateMessage* p = _impl_.groupupdatemessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateMessage_default_instance_); } -inline const ::SessionProtos::KeyPair& ConfigurationMessage_ClosedGroup::encryptionkeypair() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) - return _internal_encryptionkeypair(); +inline const ::SessionProtos::GroupUpdateMessage& DataMessage::groupupdatemessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.DataMessage.groupUpdateMessage) + return _internal_groupupdatemessage(); } -inline void ConfigurationMessage_ClosedGroup::unsafe_arena_set_allocated_encryptionkeypair( - ::SessionProtos::KeyPair* encryptionkeypair) { +inline void DataMessage::unsafe_arena_set_allocated_groupupdatemessage( + ::SessionProtos::GroupUpdateMessage* groupupdatemessage) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.encryptionkeypair_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.groupupdatemessage_); } - _impl_.encryptionkeypair_ = encryptionkeypair; - if (encryptionkeypair) { - _impl_._has_bits_[0] |= 0x00000004u; + _impl_.groupupdatemessage_ = groupupdatemessage; + if (groupupdatemessage) { + _impl_._has_bits_[0] |= 0x00000080u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000080u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.DataMessage.groupUpdateMessage) } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::release_encryptionkeypair() { - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; - _impl_.encryptionkeypair_ = nullptr; +inline ::SessionProtos::GroupUpdateMessage* DataMessage::release_groupupdatemessage() { + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::GroupUpdateMessage* temp = _impl_.groupupdatemessage_; + _impl_.groupupdatemessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -11710,986 +10690,1188 @@ inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::release_encry #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::unsafe_arena_release_encryptionkeypair() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) - _impl_._has_bits_[0] &= ~0x00000004u; - ::SessionProtos::KeyPair* temp = _impl_.encryptionkeypair_; - _impl_.encryptionkeypair_ = nullptr; +inline ::SessionProtos::GroupUpdateMessage* DataMessage::unsafe_arena_release_groupupdatemessage() { + // @@protoc_insertion_point(field_release:SessionProtos.DataMessage.groupUpdateMessage) + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::GroupUpdateMessage* temp = _impl_.groupupdatemessage_; + _impl_.groupupdatemessage_ = nullptr; return temp; } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::_internal_mutable_encryptionkeypair() { - _impl_._has_bits_[0] |= 0x00000004u; - if (_impl_.encryptionkeypair_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::KeyPair>(GetArenaForAllocation()); - _impl_.encryptionkeypair_ = p; +inline ::SessionProtos::GroupUpdateMessage* DataMessage::_internal_mutable_groupupdatemessage() { + _impl_._has_bits_[0] |= 0x00000080u; + if (_impl_.groupupdatemessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateMessage>(GetArenaForAllocation()); + _impl_.groupupdatemessage_ = p; } - return _impl_.encryptionkeypair_; + return _impl_.groupupdatemessage_; } -inline ::SessionProtos::KeyPair* ConfigurationMessage_ClosedGroup::mutable_encryptionkeypair() { - ::SessionProtos::KeyPair* _msg = _internal_mutable_encryptionkeypair(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) +inline ::SessionProtos::GroupUpdateMessage* DataMessage::mutable_groupupdatemessage() { + ::SessionProtos::GroupUpdateMessage* _msg = _internal_mutable_groupupdatemessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.DataMessage.groupUpdateMessage) return _msg; } -inline void ConfigurationMessage_ClosedGroup::set_allocated_encryptionkeypair(::SessionProtos::KeyPair* encryptionkeypair) { +inline void DataMessage::set_allocated_groupupdatemessage(::SessionProtos::GroupUpdateMessage* groupupdatemessage) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.encryptionkeypair_; + delete _impl_.groupupdatemessage_; } - if (encryptionkeypair) { + if (groupupdatemessage) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(encryptionkeypair); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(groupupdatemessage); if (message_arena != submessage_arena) { - encryptionkeypair = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, encryptionkeypair, submessage_arena); + groupupdatemessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, groupupdatemessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000080u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000080u; } - _impl_.encryptionkeypair_ = encryptionkeypair; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.ClosedGroup.encryptionKeyPair) + _impl_.groupupdatemessage_ = groupupdatemessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.DataMessage.groupUpdateMessage) } -// repeated bytes members = 4; -inline int ConfigurationMessage_ClosedGroup::_internal_members_size() const { - return _impl_.members_.size(); -} -inline int ConfigurationMessage_ClosedGroup::members_size() const { - return _internal_members_size(); -} -inline void ConfigurationMessage_ClosedGroup::clear_members() { - _impl_.members_.Clear(); -} -inline std::string* ConfigurationMessage_ClosedGroup::add_members() { - std::string* _s = _internal_add_members(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _s; -} -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_members(int index) const { - return _impl_.members_.Get(index); -} -inline const std::string& ConfigurationMessage_ClosedGroup::members(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _internal_members(index); -} -inline std::string* ConfigurationMessage_ClosedGroup::mutable_members(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _impl_.members_.Mutable(index); -} -inline void ConfigurationMessage_ClosedGroup::set_members(int index, const std::string& value) { - _impl_.members_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.members) -} -inline void ConfigurationMessage_ClosedGroup::set_members(int index, std::string&& value) { - _impl_.members_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.members) -} -inline void ConfigurationMessage_ClosedGroup::set_members(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.members_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.ClosedGroup.members) -} -inline void ConfigurationMessage_ClosedGroup::set_members(int index, const void* value, size_t size) { - _impl_.members_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.members) -} -inline std::string* ConfigurationMessage_ClosedGroup::_internal_add_members() { - return _impl_.members_.Add(); +// ------------------------------------------------------------------- + +// ReceiptMessage + +// required .SessionProtos.ReceiptMessage.Type type = 1; +inline bool ReceiptMessage::_internal_has_type() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; } -inline void ConfigurationMessage_ClosedGroup::add_members(const std::string& value) { - _impl_.members_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline bool ReceiptMessage::has_type() const { + return _internal_has_type(); } -inline void ConfigurationMessage_ClosedGroup::add_members(std::string&& value) { - _impl_.members_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline void ReceiptMessage::clear_type() { + _impl_.type_ = 0; + _impl_._has_bits_[0] &= ~0x00000001u; } -inline void ConfigurationMessage_ClosedGroup::add_members(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.members_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline ::SessionProtos::ReceiptMessage_Type ReceiptMessage::_internal_type() const { + return static_cast< ::SessionProtos::ReceiptMessage_Type >(_impl_.type_); } -inline void ConfigurationMessage_ClosedGroup::add_members(const void* value, size_t size) { - _impl_.members_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.members) +inline ::SessionProtos::ReceiptMessage_Type ReceiptMessage::type() const { + // @@protoc_insertion_point(field_get:SessionProtos.ReceiptMessage.type) + return _internal_type(); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -ConfigurationMessage_ClosedGroup::members() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return _impl_.members_; +inline void ReceiptMessage::_internal_set_type(::SessionProtos::ReceiptMessage_Type value) { + assert(::SessionProtos::ReceiptMessage_Type_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.type_ = value; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -ConfigurationMessage_ClosedGroup::mutable_members() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.ClosedGroup.members) - return &_impl_.members_; +inline void ReceiptMessage::set_type(::SessionProtos::ReceiptMessage_Type value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:SessionProtos.ReceiptMessage.type) } -// repeated bytes admins = 5; -inline int ConfigurationMessage_ClosedGroup::_internal_admins_size() const { - return _impl_.admins_.size(); -} -inline int ConfigurationMessage_ClosedGroup::admins_size() const { - return _internal_admins_size(); -} -inline void ConfigurationMessage_ClosedGroup::clear_admins() { - _impl_.admins_.Clear(); -} -inline std::string* ConfigurationMessage_ClosedGroup::add_admins() { - std::string* _s = _internal_add_admins(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _s; -} -inline const std::string& ConfigurationMessage_ClosedGroup::_internal_admins(int index) const { - return _impl_.admins_.Get(index); -} -inline const std::string& ConfigurationMessage_ClosedGroup::admins(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _internal_admins(index); -} -inline std::string* ConfigurationMessage_ClosedGroup::mutable_admins(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _impl_.admins_.Mutable(index); +// repeated uint64 timestamp = 2; +inline int ReceiptMessage::_internal_timestamp_size() const { + return _impl_.timestamp_.size(); } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const std::string& value) { - _impl_.admins_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline int ReceiptMessage::timestamp_size() const { + return _internal_timestamp_size(); } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, std::string&& value) { - _impl_.admins_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline void ReceiptMessage::clear_timestamp() { + _impl_.timestamp_.Clear(); } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.admins_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline uint64_t ReceiptMessage::_internal_timestamp(int index) const { + return _impl_.timestamp_.Get(index); } -inline void ConfigurationMessage_ClosedGroup::set_admins(int index, const void* value, size_t size) { - _impl_.admins_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline uint64_t ReceiptMessage::timestamp(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.ReceiptMessage.timestamp) + return _internal_timestamp(index); } -inline std::string* ConfigurationMessage_ClosedGroup::_internal_add_admins() { - return _impl_.admins_.Add(); +inline void ReceiptMessage::set_timestamp(int index, uint64_t value) { + _impl_.timestamp_.Set(index, value); + // @@protoc_insertion_point(field_set:SessionProtos.ReceiptMessage.timestamp) } -inline void ConfigurationMessage_ClosedGroup::add_admins(const std::string& value) { - _impl_.admins_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline void ReceiptMessage::_internal_add_timestamp(uint64_t value) { + _impl_.timestamp_.Add(value); } -inline void ConfigurationMessage_ClosedGroup::add_admins(std::string&& value) { - _impl_.admins_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline void ReceiptMessage::add_timestamp(uint64_t value) { + _internal_add_timestamp(value); + // @@protoc_insertion_point(field_add:SessionProtos.ReceiptMessage.timestamp) } -inline void ConfigurationMessage_ClosedGroup::add_admins(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.admins_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& +ReceiptMessage::_internal_timestamp() const { + return _impl_.timestamp_; } -inline void ConfigurationMessage_ClosedGroup::add_admins(const void* value, size_t size) { - _impl_.admins_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.ClosedGroup.admins) +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& +ReceiptMessage::timestamp() const { + // @@protoc_insertion_point(field_list:SessionProtos.ReceiptMessage.timestamp) + return _internal_timestamp(); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -ConfigurationMessage_ClosedGroup::admins() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return _impl_.admins_; +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* +ReceiptMessage::_internal_mutable_timestamp() { + return &_impl_.timestamp_; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -ConfigurationMessage_ClosedGroup::mutable_admins() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.ClosedGroup.admins) - return &_impl_.admins_; +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* +ReceiptMessage::mutable_timestamp() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.ReceiptMessage.timestamp) + return _internal_mutable_timestamp(); } -// optional uint32 expirationTimer = 6; -inline bool ConfigurationMessage_ClosedGroup::_internal_has_expirationtimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; +// ------------------------------------------------------------------- + +// AttachmentPointer + +// required fixed64 id = 1; +inline bool AttachmentPointer::_internal_has_id() const { + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; return value; } -inline bool ConfigurationMessage_ClosedGroup::has_expirationtimer() const { - return _internal_has_expirationtimer(); +inline bool AttachmentPointer::has_id() const { + return _internal_has_id(); } -inline void ConfigurationMessage_ClosedGroup::clear_expirationtimer() { - _impl_.expirationtimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000008u; +inline void AttachmentPointer::clear_id() { + _impl_.id_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000080u; } -inline uint32_t ConfigurationMessage_ClosedGroup::_internal_expirationtimer() const { - return _impl_.expirationtimer_; +inline uint64_t AttachmentPointer::_internal_id() const { + return _impl_.id_; } -inline uint32_t ConfigurationMessage_ClosedGroup::expirationtimer() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.ClosedGroup.expirationTimer) - return _internal_expirationtimer(); +inline uint64_t AttachmentPointer::id() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.id) + return _internal_id(); } -inline void ConfigurationMessage_ClosedGroup::_internal_set_expirationtimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.expirationtimer_ = value; +inline void AttachmentPointer::_internal_set_id(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000080u; + _impl_.id_ = value; } -inline void ConfigurationMessage_ClosedGroup::set_expirationtimer(uint32_t value) { - _internal_set_expirationtimer(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.ClosedGroup.expirationTimer) +inline void AttachmentPointer::set_id(uint64_t value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.id) } -// ------------------------------------------------------------------- - -// ConfigurationMessage_Contact - -// required bytes publicKey = 1; -inline bool ConfigurationMessage_Contact::_internal_has_publickey() const { +// optional string contentType = 2; +inline bool AttachmentPointer::_internal_has_contenttype() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_publickey() const { - return _internal_has_publickey(); +inline bool AttachmentPointer::has_contenttype() const { + return _internal_has_contenttype(); } -inline void ConfigurationMessage_Contact::clear_publickey() { - _impl_.publickey_.ClearToEmpty(); +inline void AttachmentPointer::clear_contenttype() { + _impl_.contenttype_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& ConfigurationMessage_Contact::publickey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.publicKey) - return _internal_publickey(); +inline const std::string& AttachmentPointer::contenttype() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.contentType) + return _internal_contenttype(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_publickey(ArgT0&& arg0, ArgT... args) { +void AttachmentPointer::set_contenttype(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.publicKey) + _impl_.contenttype_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.contentType) } -inline std::string* ConfigurationMessage_Contact::mutable_publickey() { - std::string* _s = _internal_mutable_publickey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.publicKey) +inline std::string* AttachmentPointer::mutable_contenttype() { + std::string* _s = _internal_mutable_contenttype(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.contentType) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_publickey() const { - return _impl_.publickey_.Get(); +inline const std::string& AttachmentPointer::_internal_contenttype() const { + return _impl_.contenttype_.Get(); } -inline void ConfigurationMessage_Contact::_internal_set_publickey(const std::string& value) { +inline void AttachmentPointer::_internal_set_contenttype(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.publickey_.Set(value, GetArenaForAllocation()); + _impl_.contenttype_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_publickey() { +inline std::string* AttachmentPointer::_internal_mutable_contenttype() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.publickey_.Mutable(GetArenaForAllocation()); + return _impl_.contenttype_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::release_publickey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.publicKey) - if (!_internal_has_publickey()) { +inline std::string* AttachmentPointer::release_contenttype() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.contentType) + if (!_internal_has_contenttype()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.publickey_.Release(); + auto* p = _impl_.contenttype_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); + if (_impl_.contenttype_.IsDefault()) { + _impl_.contenttype_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Contact::set_allocated_publickey(std::string* publickey) { - if (publickey != nullptr) { +inline void AttachmentPointer::set_allocated_contenttype(std::string* contenttype) { + if (contenttype != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.publickey_.SetAllocated(publickey, GetArenaForAllocation()); + _impl_.contenttype_.SetAllocated(contenttype, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.publickey_.IsDefault()) { - _impl_.publickey_.Set("", GetArenaForAllocation()); + if (_impl_.contenttype_.IsDefault()) { + _impl_.contenttype_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.publicKey) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.contentType) } -// required string name = 2; -inline bool ConfigurationMessage_Contact::_internal_has_name() const { +// optional bytes key = 3; +inline bool AttachmentPointer::_internal_has_key() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_name() const { - return _internal_has_name(); +inline bool AttachmentPointer::has_key() const { + return _internal_has_key(); } -inline void ConfigurationMessage_Contact::clear_name() { - _impl_.name_.ClearToEmpty(); +inline void AttachmentPointer::clear_key() { + _impl_.key_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const std::string& ConfigurationMessage_Contact::name() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.name) - return _internal_name(); +inline const std::string& AttachmentPointer::key() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.key) + return _internal_key(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_name(ArgT0&& arg0, ArgT... args) { +void AttachmentPointer::set_key(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.name) + _impl_.key_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.key) } -inline std::string* ConfigurationMessage_Contact::mutable_name() { - std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.name) +inline std::string* AttachmentPointer::mutable_key() { + std::string* _s = _internal_mutable_key(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.key) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_name() const { - return _impl_.name_.Get(); +inline const std::string& AttachmentPointer::_internal_key() const { + return _impl_.key_.Get(); } -inline void ConfigurationMessage_Contact::_internal_set_name(const std::string& value) { +inline void AttachmentPointer::_internal_set_key(const std::string& value) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.name_.Set(value, GetArenaForAllocation()); + _impl_.key_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_name() { +inline std::string* AttachmentPointer::_internal_mutable_key() { _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.name_.Mutable(GetArenaForAllocation()); + return _impl_.key_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::release_name() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.name) - if (!_internal_has_name()) { +inline std::string* AttachmentPointer::release_key() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.key) + if (!_internal_has_key()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.name_.Release(); + auto* p = _impl_.key_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); + if (_impl_.key_.IsDefault()) { + _impl_.key_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Contact::set_allocated_name(std::string* name) { - if (name != nullptr) { +inline void AttachmentPointer::set_allocated_key(std::string* key) { + if (key != nullptr) { _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.name_.SetAllocated(name, GetArenaForAllocation()); + _impl_.key_.SetAllocated(key, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); + if (_impl_.key_.IsDefault()) { + _impl_.key_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.name) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.key) +} + +// optional uint32 size = 4; +inline bool AttachmentPointer::_internal_has_size() const { + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; + return value; +} +inline bool AttachmentPointer::has_size() const { + return _internal_has_size(); +} +inline void AttachmentPointer::clear_size() { + _impl_.size_ = 0u; + _impl_._has_bits_[0] &= ~0x00000100u; +} +inline uint32_t AttachmentPointer::_internal_size() const { + return _impl_.size_; +} +inline uint32_t AttachmentPointer::size() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.size) + return _internal_size(); +} +inline void AttachmentPointer::_internal_set_size(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000100u; + _impl_.size_ = value; +} +inline void AttachmentPointer::set_size(uint32_t value) { + _internal_set_size(value); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.size) } -// optional string profilePicture = 3; -inline bool ConfigurationMessage_Contact::_internal_has_profilepicture() const { +// optional bytes thumbnail = 5; +inline bool AttachmentPointer::_internal_has_thumbnail() const { bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_profilepicture() const { - return _internal_has_profilepicture(); +inline bool AttachmentPointer::has_thumbnail() const { + return _internal_has_thumbnail(); } -inline void ConfigurationMessage_Contact::clear_profilepicture() { - _impl_.profilepicture_.ClearToEmpty(); +inline void AttachmentPointer::clear_thumbnail() { + _impl_.thumbnail_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000004u; } -inline const std::string& ConfigurationMessage_Contact::profilepicture() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.profilePicture) - return _internal_profilepicture(); +inline const std::string& AttachmentPointer::thumbnail() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.thumbnail) + return _internal_thumbnail(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_profilepicture(ArgT0&& arg0, ArgT... args) { +void AttachmentPointer::set_thumbnail(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000004u; - _impl_.profilepicture_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.profilePicture) + _impl_.thumbnail_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.thumbnail) } -inline std::string* ConfigurationMessage_Contact::mutable_profilepicture() { - std::string* _s = _internal_mutable_profilepicture(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.profilePicture) +inline std::string* AttachmentPointer::mutable_thumbnail() { + std::string* _s = _internal_mutable_thumbnail(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.thumbnail) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_profilepicture() const { - return _impl_.profilepicture_.Get(); +inline const std::string& AttachmentPointer::_internal_thumbnail() const { + return _impl_.thumbnail_.Get(); } -inline void ConfigurationMessage_Contact::_internal_set_profilepicture(const std::string& value) { +inline void AttachmentPointer::_internal_set_thumbnail(const std::string& value) { _impl_._has_bits_[0] |= 0x00000004u; - _impl_.profilepicture_.Set(value, GetArenaForAllocation()); + _impl_.thumbnail_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_profilepicture() { +inline std::string* AttachmentPointer::_internal_mutable_thumbnail() { _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.profilepicture_.Mutable(GetArenaForAllocation()); + return _impl_.thumbnail_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::release_profilepicture() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.profilePicture) - if (!_internal_has_profilepicture()) { +inline std::string* AttachmentPointer::release_thumbnail() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.thumbnail) + if (!_internal_has_thumbnail()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.profilepicture_.Release(); + auto* p = _impl_.thumbnail_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilepicture_.IsDefault()) { - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + if (_impl_.thumbnail_.IsDefault()) { + _impl_.thumbnail_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void AttachmentPointer::set_allocated_thumbnail(std::string* thumbnail) { + if (thumbnail != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.thumbnail_.SetAllocated(thumbnail, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.thumbnail_.IsDefault()) { + _impl_.thumbnail_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.thumbnail) +} + +// optional bytes digest = 6; +inline bool AttachmentPointer::_internal_has_digest() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool AttachmentPointer::has_digest() const { + return _internal_has_digest(); +} +inline void AttachmentPointer::clear_digest() { + _impl_.digest_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline const std::string& AttachmentPointer::digest() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.digest) + return _internal_digest(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void AttachmentPointer::set_digest(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.digest_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.digest) +} +inline std::string* AttachmentPointer::mutable_digest() { + std::string* _s = _internal_mutable_digest(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.digest) + return _s; +} +inline const std::string& AttachmentPointer::_internal_digest() const { + return _impl_.digest_.Get(); +} +inline void AttachmentPointer::_internal_set_digest(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.digest_.Set(value, GetArenaForAllocation()); +} +inline std::string* AttachmentPointer::_internal_mutable_digest() { + _impl_._has_bits_[0] |= 0x00000008u; + return _impl_.digest_.Mutable(GetArenaForAllocation()); +} +inline std::string* AttachmentPointer::release_digest() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.digest) + if (!_internal_has_digest()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000008u; + auto* p = _impl_.digest_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.digest_.IsDefault()) { + _impl_.digest_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Contact::set_allocated_profilepicture(std::string* profilepicture) { - if (profilepicture != nullptr) { - _impl_._has_bits_[0] |= 0x00000004u; +inline void AttachmentPointer::set_allocated_digest(std::string* digest) { + if (digest != nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000008u; } - _impl_.profilepicture_.SetAllocated(profilepicture, GetArenaForAllocation()); + _impl_.digest_.SetAllocated(digest, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilepicture_.IsDefault()) { - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + if (_impl_.digest_.IsDefault()) { + _impl_.digest_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.profilePicture) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.digest) } -// optional bytes profileKey = 4; -inline bool ConfigurationMessage_Contact::_internal_has_profilekey() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; +// optional string fileName = 7; +inline bool AttachmentPointer::_internal_has_filename() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_profilekey() const { - return _internal_has_profilekey(); +inline bool AttachmentPointer::has_filename() const { + return _internal_has_filename(); } -inline void ConfigurationMessage_Contact::clear_profilekey() { - _impl_.profilekey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000008u; +inline void AttachmentPointer::clear_filename() { + _impl_.filename_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000010u; } -inline const std::string& ConfigurationMessage_Contact::profilekey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.profileKey) - return _internal_profilekey(); +inline const std::string& AttachmentPointer::filename() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.fileName) + return _internal_filename(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage_Contact::set_profilekey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.profileKey) +void AttachmentPointer::set_filename(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.filename_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.fileName) } -inline std::string* ConfigurationMessage_Contact::mutable_profilekey() { - std::string* _s = _internal_mutable_profilekey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.Contact.profileKey) +inline std::string* AttachmentPointer::mutable_filename() { + std::string* _s = _internal_mutable_filename(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.fileName) return _s; } -inline const std::string& ConfigurationMessage_Contact::_internal_profilekey() const { - return _impl_.profilekey_.Get(); +inline const std::string& AttachmentPointer::_internal_filename() const { + return _impl_.filename_.Get(); } -inline void ConfigurationMessage_Contact::_internal_set_profilekey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.profilekey_.Set(value, GetArenaForAllocation()); +inline void AttachmentPointer::_internal_set_filename(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.filename_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::_internal_mutable_profilekey() { - _impl_._has_bits_[0] |= 0x00000008u; - return _impl_.profilekey_.Mutable(GetArenaForAllocation()); +inline std::string* AttachmentPointer::_internal_mutable_filename() { + _impl_._has_bits_[0] |= 0x00000010u; + return _impl_.filename_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage_Contact::release_profilekey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.Contact.profileKey) - if (!_internal_has_profilekey()) { +inline std::string* AttachmentPointer::release_filename() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.fileName) + if (!_internal_has_filename()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000008u; - auto* p = _impl_.profilekey_.Release(); + _impl_._has_bits_[0] &= ~0x00000010u; + auto* p = _impl_.filename_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (_impl_.filename_.IsDefault()) { + _impl_.filename_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage_Contact::set_allocated_profilekey(std::string* profilekey) { - if (profilekey != nullptr) { - _impl_._has_bits_[0] |= 0x00000008u; +inline void AttachmentPointer::set_allocated_filename(std::string* filename) { + if (filename != nullptr) { + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } - _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); + _impl_.filename_.SetAllocated(filename, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (_impl_.filename_.IsDefault()) { + _impl_.filename_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.Contact.profileKey) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.fileName) } -// optional bool isApproved = 5; -inline bool ConfigurationMessage_Contact::_internal_has_isapproved() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; +// optional uint32 flags = 8; +inline bool AttachmentPointer::_internal_has_flags() const { + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_isapproved() const { - return _internal_has_isapproved(); +inline bool AttachmentPointer::has_flags() const { + return _internal_has_flags(); } -inline void ConfigurationMessage_Contact::clear_isapproved() { - _impl_.isapproved_ = false; - _impl_._has_bits_[0] &= ~0x00000010u; +inline void AttachmentPointer::clear_flags() { + _impl_.flags_ = 0u; + _impl_._has_bits_[0] &= ~0x00000200u; } -inline bool ConfigurationMessage_Contact::_internal_isapproved() const { - return _impl_.isapproved_; +inline uint32_t AttachmentPointer::_internal_flags() const { + return _impl_.flags_; } -inline bool ConfigurationMessage_Contact::isapproved() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.isApproved) - return _internal_isapproved(); +inline uint32_t AttachmentPointer::flags() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.flags) + return _internal_flags(); } -inline void ConfigurationMessage_Contact::_internal_set_isapproved(bool value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.isapproved_ = value; +inline void AttachmentPointer::_internal_set_flags(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000200u; + _impl_.flags_ = value; } -inline void ConfigurationMessage_Contact::set_isapproved(bool value) { - _internal_set_isapproved(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.isApproved) +inline void AttachmentPointer::set_flags(uint32_t value) { + _internal_set_flags(value); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.flags) +} + +// optional uint32 width = 9; +inline bool AttachmentPointer::_internal_has_width() const { + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; + return value; +} +inline bool AttachmentPointer::has_width() const { + return _internal_has_width(); +} +inline void AttachmentPointer::clear_width() { + _impl_.width_ = 0u; + _impl_._has_bits_[0] &= ~0x00000400u; +} +inline uint32_t AttachmentPointer::_internal_width() const { + return _impl_.width_; +} +inline uint32_t AttachmentPointer::width() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.width) + return _internal_width(); +} +inline void AttachmentPointer::_internal_set_width(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000400u; + _impl_.width_ = value; +} +inline void AttachmentPointer::set_width(uint32_t value) { + _internal_set_width(value); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.width) +} + +// optional uint32 height = 10; +inline bool AttachmentPointer::_internal_has_height() const { + bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; + return value; +} +inline bool AttachmentPointer::has_height() const { + return _internal_has_height(); +} +inline void AttachmentPointer::clear_height() { + _impl_.height_ = 0u; + _impl_._has_bits_[0] &= ~0x00000800u; +} +inline uint32_t AttachmentPointer::_internal_height() const { + return _impl_.height_; +} +inline uint32_t AttachmentPointer::height() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.height) + return _internal_height(); +} +inline void AttachmentPointer::_internal_set_height(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000800u; + _impl_.height_ = value; +} +inline void AttachmentPointer::set_height(uint32_t value) { + _internal_set_height(value); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.height) } -// optional bool isBlocked = 6; -inline bool ConfigurationMessage_Contact::_internal_has_isblocked() const { +// optional string caption = 11; +inline bool AttachmentPointer::_internal_has_caption() const { bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_isblocked() const { - return _internal_has_isblocked(); +inline bool AttachmentPointer::has_caption() const { + return _internal_has_caption(); } -inline void ConfigurationMessage_Contact::clear_isblocked() { - _impl_.isblocked_ = false; +inline void AttachmentPointer::clear_caption() { + _impl_.caption_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000020u; } -inline bool ConfigurationMessage_Contact::_internal_isblocked() const { - return _impl_.isblocked_; +inline const std::string& AttachmentPointer::caption() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.caption) + return _internal_caption(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void AttachmentPointer::set_caption(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.caption_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.caption) +} +inline std::string* AttachmentPointer::mutable_caption() { + std::string* _s = _internal_mutable_caption(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.caption) + return _s; +} +inline const std::string& AttachmentPointer::_internal_caption() const { + return _impl_.caption_.Get(); } -inline bool ConfigurationMessage_Contact::isblocked() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.isBlocked) - return _internal_isblocked(); +inline void AttachmentPointer::_internal_set_caption(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.caption_.Set(value, GetArenaForAllocation()); } -inline void ConfigurationMessage_Contact::_internal_set_isblocked(bool value) { +inline std::string* AttachmentPointer::_internal_mutable_caption() { _impl_._has_bits_[0] |= 0x00000020u; - _impl_.isblocked_ = value; + return _impl_.caption_.Mutable(GetArenaForAllocation()); +} +inline std::string* AttachmentPointer::release_caption() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.caption) + if (!_internal_has_caption()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000020u; + auto* p = _impl_.caption_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.caption_.IsDefault()) { + _impl_.caption_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } -inline void ConfigurationMessage_Contact::set_isblocked(bool value) { - _internal_set_isblocked(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.isBlocked) +inline void AttachmentPointer::set_allocated_caption(std::string* caption) { + if (caption != nullptr) { + _impl_._has_bits_[0] |= 0x00000020u; + } else { + _impl_._has_bits_[0] &= ~0x00000020u; + } + _impl_.caption_.SetAllocated(caption, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.caption_.IsDefault()) { + _impl_.caption_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.caption) } -// optional bool didApproveMe = 7; -inline bool ConfigurationMessage_Contact::_internal_has_didapproveme() const { +// optional string url = 101; +inline bool AttachmentPointer::_internal_has_url() const { bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; return value; } -inline bool ConfigurationMessage_Contact::has_didapproveme() const { - return _internal_has_didapproveme(); +inline bool AttachmentPointer::has_url() const { + return _internal_has_url(); } -inline void ConfigurationMessage_Contact::clear_didapproveme() { - _impl_.didapproveme_ = false; +inline void AttachmentPointer::clear_url() { + _impl_.url_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000040u; } -inline bool ConfigurationMessage_Contact::_internal_didapproveme() const { - return _impl_.didapproveme_; +inline const std::string& AttachmentPointer::url() const { + // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.url) + return _internal_url(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void AttachmentPointer::set_url(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.url_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.url) +} +inline std::string* AttachmentPointer::mutable_url() { + std::string* _s = _internal_mutable_url(); + // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.url) + return _s; +} +inline const std::string& AttachmentPointer::_internal_url() const { + return _impl_.url_.Get(); } -inline bool ConfigurationMessage_Contact::didapproveme() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.Contact.didApproveMe) - return _internal_didapproveme(); +inline void AttachmentPointer::_internal_set_url(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.url_.Set(value, GetArenaForAllocation()); } -inline void ConfigurationMessage_Contact::_internal_set_didapproveme(bool value) { +inline std::string* AttachmentPointer::_internal_mutable_url() { _impl_._has_bits_[0] |= 0x00000040u; - _impl_.didapproveme_ = value; + return _impl_.url_.Mutable(GetArenaForAllocation()); +} +inline std::string* AttachmentPointer::release_url() { + // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.url) + if (!_internal_has_url()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000040u; + auto* p = _impl_.url_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } -inline void ConfigurationMessage_Contact::set_didapproveme(bool value) { - _internal_set_didapproveme(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.Contact.didApproveMe) +inline void AttachmentPointer::set_allocated_url(std::string* url) { + if (url != nullptr) { + _impl_._has_bits_[0] |= 0x00000040u; + } else { + _impl_._has_bits_[0] &= ~0x00000040u; + } + _impl_.url_.SetAllocated(url, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.url) } // ------------------------------------------------------------------- -// ConfigurationMessage +// SharedConfigMessage -// repeated .SessionProtos.ConfigurationMessage.ClosedGroup closedGroups = 1; -inline int ConfigurationMessage::_internal_closedgroups_size() const { - return _impl_.closedgroups_.size(); -} -inline int ConfigurationMessage::closedgroups_size() const { - return _internal_closedgroups_size(); -} -inline void ConfigurationMessage::clear_closedgroups() { - _impl_.closedgroups_.Clear(); -} -inline ::SessionProtos::ConfigurationMessage_ClosedGroup* ConfigurationMessage::mutable_closedgroups(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.closedGroups) - return _impl_.closedgroups_.Mutable(index); +// required .SessionProtos.SharedConfigMessage.Kind kind = 1; +inline bool SharedConfigMessage::_internal_has_kind() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >* -ConfigurationMessage::mutable_closedgroups() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.closedGroups) - return &_impl_.closedgroups_; +inline bool SharedConfigMessage::has_kind() const { + return _internal_has_kind(); } -inline const ::SessionProtos::ConfigurationMessage_ClosedGroup& ConfigurationMessage::_internal_closedgroups(int index) const { - return _impl_.closedgroups_.Get(index); +inline void SharedConfigMessage::clear_kind() { + _impl_.kind_ = 1; + _impl_._has_bits_[0] &= ~0x00000004u; } -inline const ::SessionProtos::ConfigurationMessage_ClosedGroup& ConfigurationMessage::closedgroups(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.closedGroups) - return _internal_closedgroups(index); +inline ::SessionProtos::SharedConfigMessage_Kind SharedConfigMessage::_internal_kind() const { + return static_cast< ::SessionProtos::SharedConfigMessage_Kind >(_impl_.kind_); } -inline ::SessionProtos::ConfigurationMessage_ClosedGroup* ConfigurationMessage::_internal_add_closedgroups() { - return _impl_.closedgroups_.Add(); +inline ::SessionProtos::SharedConfigMessage_Kind SharedConfigMessage::kind() const { + // @@protoc_insertion_point(field_get:SessionProtos.SharedConfigMessage.kind) + return _internal_kind(); } -inline ::SessionProtos::ConfigurationMessage_ClosedGroup* ConfigurationMessage::add_closedgroups() { - ::SessionProtos::ConfigurationMessage_ClosedGroup* _add = _internal_add_closedgroups(); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.closedGroups) - return _add; +inline void SharedConfigMessage::_internal_set_kind(::SessionProtos::SharedConfigMessage_Kind value) { + assert(::SessionProtos::SharedConfigMessage_Kind_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.kind_ = value; } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_ClosedGroup >& -ConfigurationMessage::closedgroups() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.closedGroups) - return _impl_.closedgroups_; +inline void SharedConfigMessage::set_kind(::SessionProtos::SharedConfigMessage_Kind value) { + _internal_set_kind(value); + // @@protoc_insertion_point(field_set:SessionProtos.SharedConfigMessage.kind) } -// repeated string openGroups = 2; -inline int ConfigurationMessage::_internal_opengroups_size() const { - return _impl_.opengroups_.size(); -} -inline int ConfigurationMessage::opengroups_size() const { - return _internal_opengroups_size(); -} -inline void ConfigurationMessage::clear_opengroups() { - _impl_.opengroups_.Clear(); -} -inline std::string* ConfigurationMessage::add_opengroups() { - std::string* _s = _internal_add_opengroups(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.ConfigurationMessage.openGroups) - return _s; -} -inline const std::string& ConfigurationMessage::_internal_opengroups(int index) const { - return _impl_.opengroups_.Get(index); -} -inline const std::string& ConfigurationMessage::opengroups(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.openGroups) - return _internal_opengroups(index); -} -inline std::string* ConfigurationMessage::mutable_opengroups(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.openGroups) - return _impl_.opengroups_.Mutable(index); -} -inline void ConfigurationMessage::set_opengroups(int index, const std::string& value) { - _impl_.opengroups_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.openGroups) -} -inline void ConfigurationMessage::set_opengroups(int index, std::string&& value) { - _impl_.opengroups_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.openGroups) -} -inline void ConfigurationMessage::set_opengroups(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.opengroups_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.ConfigurationMessage.openGroups) -} -inline void ConfigurationMessage::set_opengroups(int index, const char* value, size_t size) { - _impl_.opengroups_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.ConfigurationMessage.openGroups) -} -inline std::string* ConfigurationMessage::_internal_add_opengroups() { - return _impl_.opengroups_.Add(); +// required int64 seqno = 2; +inline bool SharedConfigMessage::_internal_has_seqno() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; } -inline void ConfigurationMessage::add_opengroups(const std::string& value) { - _impl_.opengroups_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.openGroups) +inline bool SharedConfigMessage::has_seqno() const { + return _internal_has_seqno(); } -inline void ConfigurationMessage::add_opengroups(std::string&& value) { - _impl_.opengroups_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.openGroups) +inline void SharedConfigMessage::clear_seqno() { + _impl_.seqno_ = int64_t{0}; + _impl_._has_bits_[0] &= ~0x00000002u; } -inline void ConfigurationMessage::add_opengroups(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.opengroups_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.ConfigurationMessage.openGroups) +inline int64_t SharedConfigMessage::_internal_seqno() const { + return _impl_.seqno_; } -inline void ConfigurationMessage::add_opengroups(const char* value, size_t size) { - _impl_.opengroups_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.ConfigurationMessage.openGroups) +inline int64_t SharedConfigMessage::seqno() const { + // @@protoc_insertion_point(field_get:SessionProtos.SharedConfigMessage.seqno) + return _internal_seqno(); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -ConfigurationMessage::opengroups() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.openGroups) - return _impl_.opengroups_; +inline void SharedConfigMessage::_internal_set_seqno(int64_t value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.seqno_ = value; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -ConfigurationMessage::mutable_opengroups() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.openGroups) - return &_impl_.opengroups_; +inline void SharedConfigMessage::set_seqno(int64_t value) { + _internal_set_seqno(value); + // @@protoc_insertion_point(field_set:SessionProtos.SharedConfigMessage.seqno) } -// optional string displayName = 3; -inline bool ConfigurationMessage::_internal_has_displayname() const { +// required bytes data = 3; +inline bool SharedConfigMessage::_internal_has_data() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool ConfigurationMessage::has_displayname() const { - return _internal_has_displayname(); +inline bool SharedConfigMessage::has_data() const { + return _internal_has_data(); } -inline void ConfigurationMessage::clear_displayname() { - _impl_.displayname_.ClearToEmpty(); +inline void SharedConfigMessage::clear_data() { + _impl_.data_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& ConfigurationMessage::displayname() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.displayName) - return _internal_displayname(); +inline const std::string& SharedConfigMessage::data() const { + // @@protoc_insertion_point(field_get:SessionProtos.SharedConfigMessage.data) + return _internal_data(); } template inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage::set_displayname(ArgT0&& arg0, ArgT... args) { +void SharedConfigMessage::set_data(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.displayname_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.displayName) + _impl_.data_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.SharedConfigMessage.data) } -inline std::string* ConfigurationMessage::mutable_displayname() { - std::string* _s = _internal_mutable_displayname(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.displayName) +inline std::string* SharedConfigMessage::mutable_data() { + std::string* _s = _internal_mutable_data(); + // @@protoc_insertion_point(field_mutable:SessionProtos.SharedConfigMessage.data) return _s; } -inline const std::string& ConfigurationMessage::_internal_displayname() const { - return _impl_.displayname_.Get(); +inline const std::string& SharedConfigMessage::_internal_data() const { + return _impl_.data_.Get(); } -inline void ConfigurationMessage::_internal_set_displayname(const std::string& value) { +inline void SharedConfigMessage::_internal_set_data(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.displayname_.Set(value, GetArenaForAllocation()); + _impl_.data_.Set(value, GetArenaForAllocation()); } -inline std::string* ConfigurationMessage::_internal_mutable_displayname() { +inline std::string* SharedConfigMessage::_internal_mutable_data() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.displayname_.Mutable(GetArenaForAllocation()); + return _impl_.data_.Mutable(GetArenaForAllocation()); } -inline std::string* ConfigurationMessage::release_displayname() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.displayName) - if (!_internal_has_displayname()) { +inline std::string* SharedConfigMessage::release_data() { + // @@protoc_insertion_point(field_release:SessionProtos.SharedConfigMessage.data) + if (!_internal_has_data()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.displayname_.Release(); + auto* p = _impl_.data_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.displayname_.IsDefault()) { - _impl_.displayname_.Set("", GetArenaForAllocation()); + if (_impl_.data_.IsDefault()) { + _impl_.data_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void ConfigurationMessage::set_allocated_displayname(std::string* displayname) { - if (displayname != nullptr) { +inline void SharedConfigMessage::set_allocated_data(std::string* data) { + if (data != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.displayname_.SetAllocated(displayname, GetArenaForAllocation()); + _impl_.data_.SetAllocated(data, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.displayname_.IsDefault()) { - _impl_.displayname_.Set("", GetArenaForAllocation()); + if (_impl_.data_.IsDefault()) { + _impl_.data_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.displayName) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.SharedConfigMessage.data) } -// optional string profilePicture = 4; -inline bool ConfigurationMessage::_internal_has_profilepicture() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; +// ------------------------------------------------------------------- + +// GroupUpdateMessage + +// optional .SessionProtos.GroupUpdateInviteMessage inviteMessage = 1; +inline bool GroupUpdateMessage::_internal_has_invitemessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.invitemessage_ != nullptr); return value; } -inline bool ConfigurationMessage::has_profilepicture() const { - return _internal_has_profilepicture(); -} -inline void ConfigurationMessage::clear_profilepicture() { - _impl_.profilepicture_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; +inline bool GroupUpdateMessage::has_invitemessage() const { + return _internal_has_invitemessage(); } -inline const std::string& ConfigurationMessage::profilepicture() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.profilePicture) - return _internal_profilepicture(); +inline void GroupUpdateMessage::clear_invitemessage() { + if (_impl_.invitemessage_ != nullptr) _impl_.invitemessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; } -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage::set_profilepicture(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.profilepicture_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.profilePicture) +inline const ::SessionProtos::GroupUpdateInviteMessage& GroupUpdateMessage::_internal_invitemessage() const { + const ::SessionProtos::GroupUpdateInviteMessage* p = _impl_.invitemessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateInviteMessage_default_instance_); } -inline std::string* ConfigurationMessage::mutable_profilepicture() { - std::string* _s = _internal_mutable_profilepicture(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.profilePicture) - return _s; +inline const ::SessionProtos::GroupUpdateInviteMessage& GroupUpdateMessage::invitemessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.inviteMessage) + return _internal_invitemessage(); } -inline const std::string& ConfigurationMessage::_internal_profilepicture() const { - return _impl_.profilepicture_.Get(); +inline void GroupUpdateMessage::unsafe_arena_set_allocated_invitemessage( + ::SessionProtos::GroupUpdateInviteMessage* invitemessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.invitemessage_); + } + _impl_.invitemessage_ = invitemessage; + if (invitemessage) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.inviteMessage) } -inline void ConfigurationMessage::_internal_set_profilepicture(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.profilepicture_.Set(value, GetArenaForAllocation()); +inline ::SessionProtos::GroupUpdateInviteMessage* GroupUpdateMessage::release_invitemessage() { + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::GroupUpdateInviteMessage* temp = _impl_.invitemessage_; + _impl_.invitemessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline std::string* ConfigurationMessage::_internal_mutable_profilepicture() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.profilepicture_.Mutable(GetArenaForAllocation()); +inline ::SessionProtos::GroupUpdateInviteMessage* GroupUpdateMessage::unsafe_arena_release_invitemessage() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.inviteMessage) + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::GroupUpdateInviteMessage* temp = _impl_.invitemessage_; + _impl_.invitemessage_ = nullptr; + return temp; } -inline std::string* ConfigurationMessage::release_profilepicture() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.profilePicture) - if (!_internal_has_profilepicture()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.profilepicture_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilepicture_.IsDefault()) { - _impl_.profilepicture_.Set("", GetArenaForAllocation()); +inline ::SessionProtos::GroupUpdateInviteMessage* GroupUpdateMessage::_internal_mutable_invitemessage() { + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.invitemessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateInviteMessage>(GetArenaForAllocation()); + _impl_.invitemessage_ = p; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; + return _impl_.invitemessage_; } -inline void ConfigurationMessage::set_allocated_profilepicture(std::string* profilepicture) { - if (profilepicture != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; +inline ::SessionProtos::GroupUpdateInviteMessage* GroupUpdateMessage::mutable_invitemessage() { + ::SessionProtos::GroupUpdateInviteMessage* _msg = _internal_mutable_invitemessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.inviteMessage) + return _msg; +} +inline void GroupUpdateMessage::set_allocated_invitemessage(::SessionProtos::GroupUpdateInviteMessage* invitemessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.invitemessage_; } - _impl_.profilepicture_.SetAllocated(profilepicture, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilepicture_.IsDefault()) { - _impl_.profilepicture_.Set("", GetArenaForAllocation()); + if (invitemessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(invitemessage); + if (message_arena != submessage_arena) { + invitemessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, invitemessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.profilePicture) + _impl_.invitemessage_ = invitemessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.inviteMessage) } -// optional bytes profileKey = 5; -inline bool ConfigurationMessage::_internal_has_profilekey() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; +// optional .SessionProtos.GroupUpdateInfoChangeMessage infoChangeMessage = 2; +inline bool GroupUpdateMessage::_internal_has_infochangemessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.infochangemessage_ != nullptr); return value; } -inline bool ConfigurationMessage::has_profilekey() const { - return _internal_has_profilekey(); -} -inline void ConfigurationMessage::clear_profilekey() { - _impl_.profilekey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000004u; +inline bool GroupUpdateMessage::has_infochangemessage() const { + return _internal_has_infochangemessage(); } -inline const std::string& ConfigurationMessage::profilekey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.profileKey) - return _internal_profilekey(); +inline void GroupUpdateMessage::clear_infochangemessage() { + if (_impl_.infochangemessage_ != nullptr) _impl_.infochangemessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } -template -inline PROTOBUF_ALWAYS_INLINE -void ConfigurationMessage::set_profilekey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.profilekey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ConfigurationMessage.profileKey) +inline const ::SessionProtos::GroupUpdateInfoChangeMessage& GroupUpdateMessage::_internal_infochangemessage() const { + const ::SessionProtos::GroupUpdateInfoChangeMessage* p = _impl_.infochangemessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateInfoChangeMessage_default_instance_); } -inline std::string* ConfigurationMessage::mutable_profilekey() { - std::string* _s = _internal_mutable_profilekey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.profileKey) - return _s; +inline const ::SessionProtos::GroupUpdateInfoChangeMessage& GroupUpdateMessage::infochangemessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.infoChangeMessage) + return _internal_infochangemessage(); } -inline const std::string& ConfigurationMessage::_internal_profilekey() const { - return _impl_.profilekey_.Get(); +inline void GroupUpdateMessage::unsafe_arena_set_allocated_infochangemessage( + ::SessionProtos::GroupUpdateInfoChangeMessage* infochangemessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.infochangemessage_); + } + _impl_.infochangemessage_ = infochangemessage; + if (infochangemessage) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.infoChangeMessage) } -inline void ConfigurationMessage::_internal_set_profilekey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.profilekey_.Set(value, GetArenaForAllocation()); +inline ::SessionProtos::GroupUpdateInfoChangeMessage* GroupUpdateMessage::release_infochangemessage() { + _impl_._has_bits_[0] &= ~0x00000002u; + ::SessionProtos::GroupUpdateInfoChangeMessage* temp = _impl_.infochangemessage_; + _impl_.infochangemessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline std::string* ConfigurationMessage::_internal_mutable_profilekey() { - _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.profilekey_.Mutable(GetArenaForAllocation()); +inline ::SessionProtos::GroupUpdateInfoChangeMessage* GroupUpdateMessage::unsafe_arena_release_infochangemessage() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.infoChangeMessage) + _impl_._has_bits_[0] &= ~0x00000002u; + ::SessionProtos::GroupUpdateInfoChangeMessage* temp = _impl_.infochangemessage_; + _impl_.infochangemessage_ = nullptr; + return temp; } -inline std::string* ConfigurationMessage::release_profilekey() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.profileKey) - if (!_internal_has_profilekey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.profilekey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); +inline ::SessionProtos::GroupUpdateInfoChangeMessage* GroupUpdateMessage::_internal_mutable_infochangemessage() { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.infochangemessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateInfoChangeMessage>(GetArenaForAllocation()); + _impl_.infochangemessage_ = p; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; + return _impl_.infochangemessage_; +} +inline ::SessionProtos::GroupUpdateInfoChangeMessage* GroupUpdateMessage::mutable_infochangemessage() { + ::SessionProtos::GroupUpdateInfoChangeMessage* _msg = _internal_mutable_infochangemessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.infoChangeMessage) + return _msg; } -inline void ConfigurationMessage::set_allocated_profilekey(std::string* profilekey) { - if (profilekey != nullptr) { - _impl_._has_bits_[0] |= 0x00000004u; - } else { - _impl_._has_bits_[0] &= ~0x00000004u; +inline void GroupUpdateMessage::set_allocated_infochangemessage(::SessionProtos::GroupUpdateInfoChangeMessage* infochangemessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.infochangemessage_; } - _impl_.profilekey_.SetAllocated(profilekey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.profilekey_.IsDefault()) { - _impl_.profilekey_.Set("", GetArenaForAllocation()); + if (infochangemessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(infochangemessage); + if (message_arena != submessage_arena) { + infochangemessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, infochangemessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.profileKey) + _impl_.infochangemessage_ = infochangemessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.infoChangeMessage) } -// repeated .SessionProtos.ConfigurationMessage.Contact contacts = 6; -inline int ConfigurationMessage::_internal_contacts_size() const { - return _impl_.contacts_.size(); +// optional .SessionProtos.GroupUpdateMemberChangeMessage memberChangeMessage = 3; +inline bool GroupUpdateMessage::_internal_has_memberchangemessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + PROTOBUF_ASSUME(!value || _impl_.memberchangemessage_ != nullptr); + return value; +} +inline bool GroupUpdateMessage::has_memberchangemessage() const { + return _internal_has_memberchangemessage(); } -inline int ConfigurationMessage::contacts_size() const { - return _internal_contacts_size(); +inline void GroupUpdateMessage::clear_memberchangemessage() { + if (_impl_.memberchangemessage_ != nullptr) _impl_.memberchangemessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000004u; } -inline void ConfigurationMessage::clear_contacts() { - _impl_.contacts_.Clear(); +inline const ::SessionProtos::GroupUpdateMemberChangeMessage& GroupUpdateMessage::_internal_memberchangemessage() const { + const ::SessionProtos::GroupUpdateMemberChangeMessage* p = _impl_.memberchangemessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateMemberChangeMessage_default_instance_); } -inline ::SessionProtos::ConfigurationMessage_Contact* ConfigurationMessage::mutable_contacts(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.contacts) - return _impl_.contacts_.Mutable(index); +inline const ::SessionProtos::GroupUpdateMemberChangeMessage& GroupUpdateMessage::memberchangemessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.memberChangeMessage) + return _internal_memberchangemessage(); } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >* -ConfigurationMessage::mutable_contacts() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ConfigurationMessage.contacts) - return &_impl_.contacts_; +inline void GroupUpdateMessage::unsafe_arena_set_allocated_memberchangemessage( + ::SessionProtos::GroupUpdateMemberChangeMessage* memberchangemessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.memberchangemessage_); + } + _impl_.memberchangemessage_ = memberchangemessage; + if (memberchangemessage) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.memberChangeMessage) } -inline const ::SessionProtos::ConfigurationMessage_Contact& ConfigurationMessage::_internal_contacts(int index) const { - return _impl_.contacts_.Get(index); +inline ::SessionProtos::GroupUpdateMemberChangeMessage* GroupUpdateMessage::release_memberchangemessage() { + _impl_._has_bits_[0] &= ~0x00000004u; + ::SessionProtos::GroupUpdateMemberChangeMessage* temp = _impl_.memberchangemessage_; + _impl_.memberchangemessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline const ::SessionProtos::ConfigurationMessage_Contact& ConfigurationMessage::contacts(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.contacts) - return _internal_contacts(index); +inline ::SessionProtos::GroupUpdateMemberChangeMessage* GroupUpdateMessage::unsafe_arena_release_memberchangemessage() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.memberChangeMessage) + _impl_._has_bits_[0] &= ~0x00000004u; + ::SessionProtos::GroupUpdateMemberChangeMessage* temp = _impl_.memberchangemessage_; + _impl_.memberchangemessage_ = nullptr; + return temp; } -inline ::SessionProtos::ConfigurationMessage_Contact* ConfigurationMessage::_internal_add_contacts() { - return _impl_.contacts_.Add(); +inline ::SessionProtos::GroupUpdateMemberChangeMessage* GroupUpdateMessage::_internal_mutable_memberchangemessage() { + _impl_._has_bits_[0] |= 0x00000004u; + if (_impl_.memberchangemessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateMemberChangeMessage>(GetArenaForAllocation()); + _impl_.memberchangemessage_ = p; + } + return _impl_.memberchangemessage_; } -inline ::SessionProtos::ConfigurationMessage_Contact* ConfigurationMessage::add_contacts() { - ::SessionProtos::ConfigurationMessage_Contact* _add = _internal_add_contacts(); - // @@protoc_insertion_point(field_add:SessionProtos.ConfigurationMessage.contacts) - return _add; +inline ::SessionProtos::GroupUpdateMemberChangeMessage* GroupUpdateMessage::mutable_memberchangemessage() { + ::SessionProtos::GroupUpdateMemberChangeMessage* _msg = _internal_mutable_memberchangemessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.memberChangeMessage) + return _msg; } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::SessionProtos::ConfigurationMessage_Contact >& -ConfigurationMessage::contacts() const { - // @@protoc_insertion_point(field_list:SessionProtos.ConfigurationMessage.contacts) - return _impl_.contacts_; +inline void GroupUpdateMessage::set_allocated_memberchangemessage(::SessionProtos::GroupUpdateMemberChangeMessage* memberchangemessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.memberchangemessage_; + } + if (memberchangemessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(memberchangemessage); + if (message_arena != submessage_arena) { + memberchangemessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, memberchangemessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.memberchangemessage_ = memberchangemessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.memberChangeMessage) } -// optional .SessionProtos.ProConfig proConfig = 7; -inline bool ConfigurationMessage::_internal_has_proconfig() const { +// optional .SessionProtos.GroupUpdatePromoteMessage promoteMessage = 4; +inline bool GroupUpdateMessage::_internal_has_promotemessage() const { bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || _impl_.proconfig_ != nullptr); + PROTOBUF_ASSUME(!value || _impl_.promotemessage_ != nullptr); return value; } -inline bool ConfigurationMessage::has_proconfig() const { - return _internal_has_proconfig(); +inline bool GroupUpdateMessage::has_promotemessage() const { + return _internal_has_promotemessage(); } -inline void ConfigurationMessage::clear_proconfig() { - if (_impl_.proconfig_ != nullptr) _impl_.proconfig_->Clear(); +inline void GroupUpdateMessage::clear_promotemessage() { + if (_impl_.promotemessage_ != nullptr) _impl_.promotemessage_->Clear(); _impl_._has_bits_[0] &= ~0x00000008u; } -inline const ::SessionProtos::ProConfig& ConfigurationMessage::_internal_proconfig() const { - const ::SessionProtos::ProConfig* p = _impl_.proconfig_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ProConfig_default_instance_); +inline const ::SessionProtos::GroupUpdatePromoteMessage& GroupUpdateMessage::_internal_promotemessage() const { + const ::SessionProtos::GroupUpdatePromoteMessage* p = _impl_.promotemessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdatePromoteMessage_default_instance_); } -inline const ::SessionProtos::ProConfig& ConfigurationMessage::proconfig() const { - // @@protoc_insertion_point(field_get:SessionProtos.ConfigurationMessage.proConfig) - return _internal_proconfig(); +inline const ::SessionProtos::GroupUpdatePromoteMessage& GroupUpdateMessage::promotemessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.promoteMessage) + return _internal_promotemessage(); } -inline void ConfigurationMessage::unsafe_arena_set_allocated_proconfig( - ::SessionProtos::ProConfig* proconfig) { +inline void GroupUpdateMessage::unsafe_arena_set_allocated_promotemessage( + ::SessionProtos::GroupUpdatePromoteMessage* promotemessage) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proconfig_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.promotemessage_); } - _impl_.proconfig_ = proconfig; - if (proconfig) { + _impl_.promotemessage_ = promotemessage; + if (promotemessage) { _impl_._has_bits_[0] |= 0x00000008u; } else { _impl_._has_bits_[0] &= ~0x00000008u; } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ConfigurationMessage.proConfig) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.promoteMessage) } -inline ::SessionProtos::ProConfig* ConfigurationMessage::release_proconfig() { +inline ::SessionProtos::GroupUpdatePromoteMessage* GroupUpdateMessage::release_promotemessage() { _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::ProConfig* temp = _impl_.proconfig_; - _impl_.proconfig_ = nullptr; + ::SessionProtos::GroupUpdatePromoteMessage* temp = _impl_.promotemessage_; + _impl_.promotemessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -12701,873 +11883,1483 @@ inline ::SessionProtos::ProConfig* ConfigurationMessage::release_proconfig() { #endif // !PROTOBUF_FORCE_COPY_IN_RELEASE return temp; } -inline ::SessionProtos::ProConfig* ConfigurationMessage::unsafe_arena_release_proconfig() { - // @@protoc_insertion_point(field_release:SessionProtos.ConfigurationMessage.proConfig) +inline ::SessionProtos::GroupUpdatePromoteMessage* GroupUpdateMessage::unsafe_arena_release_promotemessage() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.promoteMessage) _impl_._has_bits_[0] &= ~0x00000008u; - ::SessionProtos::ProConfig* temp = _impl_.proconfig_; - _impl_.proconfig_ = nullptr; + ::SessionProtos::GroupUpdatePromoteMessage* temp = _impl_.promotemessage_; + _impl_.promotemessage_ = nullptr; return temp; } -inline ::SessionProtos::ProConfig* ConfigurationMessage::_internal_mutable_proconfig() { +inline ::SessionProtos::GroupUpdatePromoteMessage* GroupUpdateMessage::_internal_mutable_promotemessage() { _impl_._has_bits_[0] |= 0x00000008u; - if (_impl_.proconfig_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ProConfig>(GetArenaForAllocation()); - _impl_.proconfig_ = p; + if (_impl_.promotemessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdatePromoteMessage>(GetArenaForAllocation()); + _impl_.promotemessage_ = p; } - return _impl_.proconfig_; + return _impl_.promotemessage_; } -inline ::SessionProtos::ProConfig* ConfigurationMessage::mutable_proconfig() { - ::SessionProtos::ProConfig* _msg = _internal_mutable_proconfig(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ConfigurationMessage.proConfig) +inline ::SessionProtos::GroupUpdatePromoteMessage* GroupUpdateMessage::mutable_promotemessage() { + ::SessionProtos::GroupUpdatePromoteMessage* _msg = _internal_mutable_promotemessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.promoteMessage) return _msg; } -inline void ConfigurationMessage::set_allocated_proconfig(::SessionProtos::ProConfig* proconfig) { +inline void GroupUpdateMessage::set_allocated_promotemessage(::SessionProtos::GroupUpdatePromoteMessage* promotemessage) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete _impl_.proconfig_; + delete _impl_.promotemessage_; } - if (proconfig) { + if (promotemessage) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proconfig); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(promotemessage); if (message_arena != submessage_arena) { - proconfig = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, proconfig, submessage_arena); + promotemessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, promotemessage, submessage_arena); } _impl_._has_bits_[0] |= 0x00000008u; } else { _impl_._has_bits_[0] &= ~0x00000008u; } - _impl_.proconfig_ = proconfig; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ConfigurationMessage.proConfig) + _impl_.promotemessage_ = promotemessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.promoteMessage) } -// ------------------------------------------------------------------- - -// ReceiptMessage - -// required .SessionProtos.ReceiptMessage.Type type = 1; -inline bool ReceiptMessage::_internal_has_type() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; +// optional .SessionProtos.GroupUpdateMemberLeftMessage memberLeftMessage = 5; +inline bool GroupUpdateMessage::_internal_has_memberleftmessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + PROTOBUF_ASSUME(!value || _impl_.memberleftmessage_ != nullptr); return value; } -inline bool ReceiptMessage::has_type() const { - return _internal_has_type(); +inline bool GroupUpdateMessage::has_memberleftmessage() const { + return _internal_has_memberleftmessage(); } -inline void ReceiptMessage::clear_type() { - _impl_.type_ = 0; - _impl_._has_bits_[0] &= ~0x00000001u; +inline void GroupUpdateMessage::clear_memberleftmessage() { + if (_impl_.memberleftmessage_ != nullptr) _impl_.memberleftmessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000010u; } -inline ::SessionProtos::ReceiptMessage_Type ReceiptMessage::_internal_type() const { - return static_cast< ::SessionProtos::ReceiptMessage_Type >(_impl_.type_); +inline const ::SessionProtos::GroupUpdateMemberLeftMessage& GroupUpdateMessage::_internal_memberleftmessage() const { + const ::SessionProtos::GroupUpdateMemberLeftMessage* p = _impl_.memberleftmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateMemberLeftMessage_default_instance_); } -inline ::SessionProtos::ReceiptMessage_Type ReceiptMessage::type() const { - // @@protoc_insertion_point(field_get:SessionProtos.ReceiptMessage.type) - return _internal_type(); +inline const ::SessionProtos::GroupUpdateMemberLeftMessage& GroupUpdateMessage::memberleftmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.memberLeftMessage) + return _internal_memberleftmessage(); } -inline void ReceiptMessage::_internal_set_type(::SessionProtos::ReceiptMessage_Type value) { - assert(::SessionProtos::ReceiptMessage_Type_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.type_ = value; +inline void GroupUpdateMessage::unsafe_arena_set_allocated_memberleftmessage( + ::SessionProtos::GroupUpdateMemberLeftMessage* memberleftmessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.memberleftmessage_); + } + _impl_.memberleftmessage_ = memberleftmessage; + if (memberleftmessage) { + _impl_._has_bits_[0] |= 0x00000010u; + } else { + _impl_._has_bits_[0] &= ~0x00000010u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.memberLeftMessage) } -inline void ReceiptMessage::set_type(::SessionProtos::ReceiptMessage_Type value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:SessionProtos.ReceiptMessage.type) +inline ::SessionProtos::GroupUpdateMemberLeftMessage* GroupUpdateMessage::release_memberleftmessage() { + _impl_._has_bits_[0] &= ~0x00000010u; + ::SessionProtos::GroupUpdateMemberLeftMessage* temp = _impl_.memberleftmessage_; + _impl_.memberleftmessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } - -// repeated uint64 timestamp = 2; -inline int ReceiptMessage::_internal_timestamp_size() const { - return _impl_.timestamp_.size(); +inline ::SessionProtos::GroupUpdateMemberLeftMessage* GroupUpdateMessage::unsafe_arena_release_memberleftmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.memberLeftMessage) + _impl_._has_bits_[0] &= ~0x00000010u; + ::SessionProtos::GroupUpdateMemberLeftMessage* temp = _impl_.memberleftmessage_; + _impl_.memberleftmessage_ = nullptr; + return temp; } -inline int ReceiptMessage::timestamp_size() const { - return _internal_timestamp_size(); +inline ::SessionProtos::GroupUpdateMemberLeftMessage* GroupUpdateMessage::_internal_mutable_memberleftmessage() { + _impl_._has_bits_[0] |= 0x00000010u; + if (_impl_.memberleftmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateMemberLeftMessage>(GetArenaForAllocation()); + _impl_.memberleftmessage_ = p; + } + return _impl_.memberleftmessage_; } -inline void ReceiptMessage::clear_timestamp() { - _impl_.timestamp_.Clear(); +inline ::SessionProtos::GroupUpdateMemberLeftMessage* GroupUpdateMessage::mutable_memberleftmessage() { + ::SessionProtos::GroupUpdateMemberLeftMessage* _msg = _internal_mutable_memberleftmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.memberLeftMessage) + return _msg; } -inline uint64_t ReceiptMessage::_internal_timestamp(int index) const { - return _impl_.timestamp_.Get(index); +inline void GroupUpdateMessage::set_allocated_memberleftmessage(::SessionProtos::GroupUpdateMemberLeftMessage* memberleftmessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.memberleftmessage_; + } + if (memberleftmessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(memberleftmessage); + if (message_arena != submessage_arena) { + memberleftmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, memberleftmessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000010u; + } else { + _impl_._has_bits_[0] &= ~0x00000010u; + } + _impl_.memberleftmessage_ = memberleftmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.memberLeftMessage) } -inline uint64_t ReceiptMessage::timestamp(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.ReceiptMessage.timestamp) - return _internal_timestamp(index); + +// optional .SessionProtos.GroupUpdateInviteResponseMessage inviteResponse = 6; +inline bool GroupUpdateMessage::_internal_has_inviteresponse() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + PROTOBUF_ASSUME(!value || _impl_.inviteresponse_ != nullptr); + return value; } -inline void ReceiptMessage::set_timestamp(int index, uint64_t value) { - _impl_.timestamp_.Set(index, value); - // @@protoc_insertion_point(field_set:SessionProtos.ReceiptMessage.timestamp) +inline bool GroupUpdateMessage::has_inviteresponse() const { + return _internal_has_inviteresponse(); } -inline void ReceiptMessage::_internal_add_timestamp(uint64_t value) { - _impl_.timestamp_.Add(value); +inline void GroupUpdateMessage::clear_inviteresponse() { + if (_impl_.inviteresponse_ != nullptr) _impl_.inviteresponse_->Clear(); + _impl_._has_bits_[0] &= ~0x00000020u; } -inline void ReceiptMessage::add_timestamp(uint64_t value) { - _internal_add_timestamp(value); - // @@protoc_insertion_point(field_add:SessionProtos.ReceiptMessage.timestamp) +inline const ::SessionProtos::GroupUpdateInviteResponseMessage& GroupUpdateMessage::_internal_inviteresponse() const { + const ::SessionProtos::GroupUpdateInviteResponseMessage* p = _impl_.inviteresponse_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateInviteResponseMessage_default_instance_); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& -ReceiptMessage::_internal_timestamp() const { - return _impl_.timestamp_; +inline const ::SessionProtos::GroupUpdateInviteResponseMessage& GroupUpdateMessage::inviteresponse() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.inviteResponse) + return _internal_inviteresponse(); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >& -ReceiptMessage::timestamp() const { - // @@protoc_insertion_point(field_list:SessionProtos.ReceiptMessage.timestamp) - return _internal_timestamp(); +inline void GroupUpdateMessage::unsafe_arena_set_allocated_inviteresponse( + ::SessionProtos::GroupUpdateInviteResponseMessage* inviteresponse) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.inviteresponse_); + } + _impl_.inviteresponse_ = inviteresponse; + if (inviteresponse) { + _impl_._has_bits_[0] |= 0x00000020u; + } else { + _impl_._has_bits_[0] &= ~0x00000020u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.inviteResponse) } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* -ReceiptMessage::_internal_mutable_timestamp() { - return &_impl_.timestamp_; +inline ::SessionProtos::GroupUpdateInviteResponseMessage* GroupUpdateMessage::release_inviteresponse() { + _impl_._has_bits_[0] &= ~0x00000020u; + ::SessionProtos::GroupUpdateInviteResponseMessage* temp = _impl_.inviteresponse_; + _impl_.inviteresponse_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< uint64_t >* -ReceiptMessage::mutable_timestamp() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.ReceiptMessage.timestamp) - return _internal_mutable_timestamp(); +inline ::SessionProtos::GroupUpdateInviteResponseMessage* GroupUpdateMessage::unsafe_arena_release_inviteresponse() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.inviteResponse) + _impl_._has_bits_[0] &= ~0x00000020u; + ::SessionProtos::GroupUpdateInviteResponseMessage* temp = _impl_.inviteresponse_; + _impl_.inviteresponse_ = nullptr; + return temp; +} +inline ::SessionProtos::GroupUpdateInviteResponseMessage* GroupUpdateMessage::_internal_mutable_inviteresponse() { + _impl_._has_bits_[0] |= 0x00000020u; + if (_impl_.inviteresponse_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateInviteResponseMessage>(GetArenaForAllocation()); + _impl_.inviteresponse_ = p; + } + return _impl_.inviteresponse_; +} +inline ::SessionProtos::GroupUpdateInviteResponseMessage* GroupUpdateMessage::mutable_inviteresponse() { + ::SessionProtos::GroupUpdateInviteResponseMessage* _msg = _internal_mutable_inviteresponse(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.inviteResponse) + return _msg; +} +inline void GroupUpdateMessage::set_allocated_inviteresponse(::SessionProtos::GroupUpdateInviteResponseMessage* inviteresponse) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.inviteresponse_; + } + if (inviteresponse) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(inviteresponse); + if (message_arena != submessage_arena) { + inviteresponse = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, inviteresponse, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000020u; + } else { + _impl_._has_bits_[0] &= ~0x00000020u; + } + _impl_.inviteresponse_ = inviteresponse; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.inviteResponse) } -// ------------------------------------------------------------------- - -// AttachmentPointer +// optional .SessionProtos.GroupUpdateDeleteMemberContentMessage deleteMemberContent = 7; +inline bool GroupUpdateMessage::_internal_has_deletemembercontent() const { + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + PROTOBUF_ASSUME(!value || _impl_.deletemembercontent_ != nullptr); + return value; +} +inline bool GroupUpdateMessage::has_deletemembercontent() const { + return _internal_has_deletemembercontent(); +} +inline void GroupUpdateMessage::clear_deletemembercontent() { + if (_impl_.deletemembercontent_ != nullptr) _impl_.deletemembercontent_->Clear(); + _impl_._has_bits_[0] &= ~0x00000040u; +} +inline const ::SessionProtos::GroupUpdateDeleteMemberContentMessage& GroupUpdateMessage::_internal_deletemembercontent() const { + const ::SessionProtos::GroupUpdateDeleteMemberContentMessage* p = _impl_.deletemembercontent_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateDeleteMemberContentMessage_default_instance_); +} +inline const ::SessionProtos::GroupUpdateDeleteMemberContentMessage& GroupUpdateMessage::deletemembercontent() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.deleteMemberContent) + return _internal_deletemembercontent(); +} +inline void GroupUpdateMessage::unsafe_arena_set_allocated_deletemembercontent( + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* deletemembercontent) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.deletemembercontent_); + } + _impl_.deletemembercontent_ = deletemembercontent; + if (deletemembercontent) { + _impl_._has_bits_[0] |= 0x00000040u; + } else { + _impl_._has_bits_[0] &= ~0x00000040u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.deleteMemberContent) +} +inline ::SessionProtos::GroupUpdateDeleteMemberContentMessage* GroupUpdateMessage::release_deletemembercontent() { + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* temp = _impl_.deletemembercontent_; + _impl_.deletemembercontent_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::SessionProtos::GroupUpdateDeleteMemberContentMessage* GroupUpdateMessage::unsafe_arena_release_deletemembercontent() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.deleteMemberContent) + _impl_._has_bits_[0] &= ~0x00000040u; + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* temp = _impl_.deletemembercontent_; + _impl_.deletemembercontent_ = nullptr; + return temp; +} +inline ::SessionProtos::GroupUpdateDeleteMemberContentMessage* GroupUpdateMessage::_internal_mutable_deletemembercontent() { + _impl_._has_bits_[0] |= 0x00000040u; + if (_impl_.deletemembercontent_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateDeleteMemberContentMessage>(GetArenaForAllocation()); + _impl_.deletemembercontent_ = p; + } + return _impl_.deletemembercontent_; +} +inline ::SessionProtos::GroupUpdateDeleteMemberContentMessage* GroupUpdateMessage::mutable_deletemembercontent() { + ::SessionProtos::GroupUpdateDeleteMemberContentMessage* _msg = _internal_mutable_deletemembercontent(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.deleteMemberContent) + return _msg; +} +inline void GroupUpdateMessage::set_allocated_deletemembercontent(::SessionProtos::GroupUpdateDeleteMemberContentMessage* deletemembercontent) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.deletemembercontent_; + } + if (deletemembercontent) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(deletemembercontent); + if (message_arena != submessage_arena) { + deletemembercontent = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, deletemembercontent, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000040u; + } else { + _impl_._has_bits_[0] &= ~0x00000040u; + } + _impl_.deletemembercontent_ = deletemembercontent; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.deleteMemberContent) +} -// required fixed64 id = 1; -inline bool AttachmentPointer::_internal_has_id() const { +// optional .SessionProtos.GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8; +inline bool GroupUpdateMessage::_internal_has_memberleftnotificationmessage() const { bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + PROTOBUF_ASSUME(!value || _impl_.memberleftnotificationmessage_ != nullptr); return value; } -inline bool AttachmentPointer::has_id() const { - return _internal_has_id(); +inline bool GroupUpdateMessage::has_memberleftnotificationmessage() const { + return _internal_has_memberleftnotificationmessage(); +} +inline void GroupUpdateMessage::clear_memberleftnotificationmessage() { + if (_impl_.memberleftnotificationmessage_ != nullptr) _impl_.memberleftnotificationmessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000080u; +} +inline const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage& GroupUpdateMessage::_internal_memberleftnotificationmessage() const { + const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* p = _impl_.memberleftnotificationmessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_GroupUpdateMemberLeftNotificationMessage_default_instance_); +} +inline const ::SessionProtos::GroupUpdateMemberLeftNotificationMessage& GroupUpdateMessage::memberleftnotificationmessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMessage.memberLeftNotificationMessage) + return _internal_memberleftnotificationmessage(); +} +inline void GroupUpdateMessage::unsafe_arena_set_allocated_memberleftnotificationmessage( + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* memberleftnotificationmessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.memberleftnotificationmessage_); + } + _impl_.memberleftnotificationmessage_ = memberleftnotificationmessage; + if (memberleftnotificationmessage) { + _impl_._has_bits_[0] |= 0x00000080u; + } else { + _impl_._has_bits_[0] &= ~0x00000080u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.GroupUpdateMessage.memberLeftNotificationMessage) +} +inline ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* GroupUpdateMessage::release_memberleftnotificationmessage() { + _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* temp = _impl_.memberleftnotificationmessage_; + _impl_.memberleftnotificationmessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline void AttachmentPointer::clear_id() { - _impl_.id_ = uint64_t{0u}; +inline ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* GroupUpdateMessage::unsafe_arena_release_memberleftnotificationmessage() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMessage.memberLeftNotificationMessage) _impl_._has_bits_[0] &= ~0x00000080u; + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* temp = _impl_.memberleftnotificationmessage_; + _impl_.memberleftnotificationmessage_ = nullptr; + return temp; } -inline uint64_t AttachmentPointer::_internal_id() const { - return _impl_.id_; -} -inline uint64_t AttachmentPointer::id() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.id) - return _internal_id(); -} -inline void AttachmentPointer::_internal_set_id(uint64_t value) { +inline ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* GroupUpdateMessage::_internal_mutable_memberleftnotificationmessage() { _impl_._has_bits_[0] |= 0x00000080u; - _impl_.id_ = value; + if (_impl_.memberleftnotificationmessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::GroupUpdateMemberLeftNotificationMessage>(GetArenaForAllocation()); + _impl_.memberleftnotificationmessage_ = p; + } + return _impl_.memberleftnotificationmessage_; } -inline void AttachmentPointer::set_id(uint64_t value) { - _internal_set_id(value); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.id) +inline ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* GroupUpdateMessage::mutable_memberleftnotificationmessage() { + ::SessionProtos::GroupUpdateMemberLeftNotificationMessage* _msg = _internal_mutable_memberleftnotificationmessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMessage.memberLeftNotificationMessage) + return _msg; +} +inline void GroupUpdateMessage::set_allocated_memberleftnotificationmessage(::SessionProtos::GroupUpdateMemberLeftNotificationMessage* memberleftnotificationmessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.memberleftnotificationmessage_; + } + if (memberleftnotificationmessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(memberleftnotificationmessage); + if (message_arena != submessage_arena) { + memberleftnotificationmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, memberleftnotificationmessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000080u; + } else { + _impl_._has_bits_[0] &= ~0x00000080u; + } + _impl_.memberleftnotificationmessage_ = memberleftnotificationmessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMessage.memberLeftNotificationMessage) } -// optional string contentType = 2; -inline bool AttachmentPointer::_internal_has_contenttype() const { +// ------------------------------------------------------------------- + +// GroupUpdateInviteMessage + +// required string groupSessionId = 1; +inline bool GroupUpdateInviteMessage::_internal_has_groupsessionid() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool AttachmentPointer::has_contenttype() const { - return _internal_has_contenttype(); +inline bool GroupUpdateInviteMessage::has_groupsessionid() const { + return _internal_has_groupsessionid(); } -inline void AttachmentPointer::clear_contenttype() { - _impl_.contenttype_.ClearToEmpty(); +inline void GroupUpdateInviteMessage::clear_groupsessionid() { + _impl_.groupsessionid_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& AttachmentPointer::contenttype() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.contentType) - return _internal_contenttype(); +inline const std::string& GroupUpdateInviteMessage::groupsessionid() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInviteMessage.groupSessionId) + return _internal_groupsessionid(); } template inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_contenttype(ArgT0&& arg0, ArgT... args) { +void GroupUpdateInviteMessage::set_groupsessionid(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.contenttype_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.contentType) + _impl_.groupsessionid_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInviteMessage.groupSessionId) } -inline std::string* AttachmentPointer::mutable_contenttype() { - std::string* _s = _internal_mutable_contenttype(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.contentType) +inline std::string* GroupUpdateInviteMessage::mutable_groupsessionid() { + std::string* _s = _internal_mutable_groupsessionid(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateInviteMessage.groupSessionId) return _s; } -inline const std::string& AttachmentPointer::_internal_contenttype() const { - return _impl_.contenttype_.Get(); +inline const std::string& GroupUpdateInviteMessage::_internal_groupsessionid() const { + return _impl_.groupsessionid_.Get(); } -inline void AttachmentPointer::_internal_set_contenttype(const std::string& value) { +inline void GroupUpdateInviteMessage::_internal_set_groupsessionid(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.contenttype_.Set(value, GetArenaForAllocation()); + _impl_.groupsessionid_.Set(value, GetArenaForAllocation()); } -inline std::string* AttachmentPointer::_internal_mutable_contenttype() { +inline std::string* GroupUpdateInviteMessage::_internal_mutable_groupsessionid() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.contenttype_.Mutable(GetArenaForAllocation()); + return _impl_.groupsessionid_.Mutable(GetArenaForAllocation()); } -inline std::string* AttachmentPointer::release_contenttype() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.contentType) - if (!_internal_has_contenttype()) { +inline std::string* GroupUpdateInviteMessage::release_groupsessionid() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateInviteMessage.groupSessionId) + if (!_internal_has_groupsessionid()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.contenttype_.Release(); + auto* p = _impl_.groupsessionid_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.contenttype_.IsDefault()) { - _impl_.contenttype_.Set("", GetArenaForAllocation()); + if (_impl_.groupsessionid_.IsDefault()) { + _impl_.groupsessionid_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void AttachmentPointer::set_allocated_contenttype(std::string* contenttype) { - if (contenttype != nullptr) { +inline void GroupUpdateInviteMessage::set_allocated_groupsessionid(std::string* groupsessionid) { + if (groupsessionid != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.contenttype_.SetAllocated(contenttype, GetArenaForAllocation()); + _impl_.groupsessionid_.SetAllocated(groupsessionid, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.contenttype_.IsDefault()) { - _impl_.contenttype_.Set("", GetArenaForAllocation()); + if (_impl_.groupsessionid_.IsDefault()) { + _impl_.groupsessionid_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.contentType) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateInviteMessage.groupSessionId) } -// optional bytes key = 3; -inline bool AttachmentPointer::_internal_has_key() const { +// required string name = 2; +inline bool GroupUpdateInviteMessage::_internal_has_name() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool AttachmentPointer::has_key() const { - return _internal_has_key(); +inline bool GroupUpdateInviteMessage::has_name() const { + return _internal_has_name(); } -inline void AttachmentPointer::clear_key() { - _impl_.key_.ClearToEmpty(); +inline void GroupUpdateInviteMessage::clear_name() { + _impl_.name_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000002u; } -inline const std::string& AttachmentPointer::key() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.key) - return _internal_key(); +inline const std::string& GroupUpdateInviteMessage::name() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInviteMessage.name) + return _internal_name(); } template inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_key(ArgT0&& arg0, ArgT... args) { +void GroupUpdateInviteMessage::set_name(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.key_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.key) + _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInviteMessage.name) } -inline std::string* AttachmentPointer::mutable_key() { - std::string* _s = _internal_mutable_key(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.key) +inline std::string* GroupUpdateInviteMessage::mutable_name() { + std::string* _s = _internal_mutable_name(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateInviteMessage.name) return _s; } -inline const std::string& AttachmentPointer::_internal_key() const { - return _impl_.key_.Get(); +inline const std::string& GroupUpdateInviteMessage::_internal_name() const { + return _impl_.name_.Get(); } -inline void AttachmentPointer::_internal_set_key(const std::string& value) { +inline void GroupUpdateInviteMessage::_internal_set_name(const std::string& value) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.key_.Set(value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } -inline std::string* AttachmentPointer::_internal_mutable_key() { +inline std::string* GroupUpdateInviteMessage::_internal_mutable_name() { _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.key_.Mutable(GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } -inline std::string* AttachmentPointer::release_key() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.key) - if (!_internal_has_key()) { +inline std::string* GroupUpdateInviteMessage::release_name() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateInviteMessage.name) + if (!_internal_has_name()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.key_.Release(); + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.key_.IsDefault()) { - _impl_.key_.Set("", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void AttachmentPointer::set_allocated_key(std::string* key) { - if (key != nullptr) { +inline void GroupUpdateInviteMessage::set_allocated_name(std::string* name) { + if (name != nullptr) { _impl_._has_bits_[0] |= 0x00000002u; } else { _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.key_.SetAllocated(key, GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.key_.IsDefault()) { - _impl_.key_.Set("", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.key) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateInviteMessage.name) } -// optional uint32 size = 4; -inline bool AttachmentPointer::_internal_has_size() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; +// required bytes memberAuthData = 3; +inline bool GroupUpdateInviteMessage::_internal_has_memberauthdata() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool AttachmentPointer::has_size() const { - return _internal_has_size(); +inline bool GroupUpdateInviteMessage::has_memberauthdata() const { + return _internal_has_memberauthdata(); } -inline void AttachmentPointer::clear_size() { - _impl_.size_ = 0u; - _impl_._has_bits_[0] &= ~0x00000100u; +inline void GroupUpdateInviteMessage::clear_memberauthdata() { + _impl_.memberauthdata_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } -inline uint32_t AttachmentPointer::_internal_size() const { - return _impl_.size_; +inline const std::string& GroupUpdateInviteMessage::memberauthdata() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInviteMessage.memberAuthData) + return _internal_memberauthdata(); } -inline uint32_t AttachmentPointer::size() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.size) - return _internal_size(); +template +inline PROTOBUF_ALWAYS_INLINE +void GroupUpdateInviteMessage::set_memberauthdata(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.memberauthdata_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInviteMessage.memberAuthData) } -inline void AttachmentPointer::_internal_set_size(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000100u; - _impl_.size_ = value; +inline std::string* GroupUpdateInviteMessage::mutable_memberauthdata() { + std::string* _s = _internal_mutable_memberauthdata(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateInviteMessage.memberAuthData) + return _s; } -inline void AttachmentPointer::set_size(uint32_t value) { - _internal_set_size(value); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.size) +inline const std::string& GroupUpdateInviteMessage::_internal_memberauthdata() const { + return _impl_.memberauthdata_.Get(); +} +inline void GroupUpdateInviteMessage::_internal_set_memberauthdata(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.memberauthdata_.Set(value, GetArenaForAllocation()); +} +inline std::string* GroupUpdateInviteMessage::_internal_mutable_memberauthdata() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.memberauthdata_.Mutable(GetArenaForAllocation()); +} +inline std::string* GroupUpdateInviteMessage::release_memberauthdata() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateInviteMessage.memberAuthData) + if (!_internal_has_memberauthdata()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.memberauthdata_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.memberauthdata_.IsDefault()) { + _impl_.memberauthdata_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void GroupUpdateInviteMessage::set_allocated_memberauthdata(std::string* memberauthdata) { + if (memberauthdata != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.memberauthdata_.SetAllocated(memberauthdata, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.memberauthdata_.IsDefault()) { + _impl_.memberauthdata_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateInviteMessage.memberAuthData) } -// optional bytes thumbnail = 5; -inline bool AttachmentPointer::_internal_has_thumbnail() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; +// required bytes adminSignature = 4; +inline bool GroupUpdateInviteMessage::_internal_has_adminsignature() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } -inline bool AttachmentPointer::has_thumbnail() const { - return _internal_has_thumbnail(); +inline bool GroupUpdateInviteMessage::has_adminsignature() const { + return _internal_has_adminsignature(); } -inline void AttachmentPointer::clear_thumbnail() { - _impl_.thumbnail_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000004u; +inline void GroupUpdateInviteMessage::clear_adminsignature() { + _impl_.adminsignature_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000008u; } -inline const std::string& AttachmentPointer::thumbnail() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.thumbnail) - return _internal_thumbnail(); +inline const std::string& GroupUpdateInviteMessage::adminsignature() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInviteMessage.adminSignature) + return _internal_adminsignature(); } template inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_thumbnail(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.thumbnail_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.thumbnail) +void GroupUpdateInviteMessage::set_adminsignature(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.adminsignature_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInviteMessage.adminSignature) +} +inline std::string* GroupUpdateInviteMessage::mutable_adminsignature() { + std::string* _s = _internal_mutable_adminsignature(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateInviteMessage.adminSignature) + return _s; +} +inline const std::string& GroupUpdateInviteMessage::_internal_adminsignature() const { + return _impl_.adminsignature_.Get(); +} +inline void GroupUpdateInviteMessage::_internal_set_adminsignature(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.adminsignature_.Set(value, GetArenaForAllocation()); +} +inline std::string* GroupUpdateInviteMessage::_internal_mutable_adminsignature() { + _impl_._has_bits_[0] |= 0x00000008u; + return _impl_.adminsignature_.Mutable(GetArenaForAllocation()); +} +inline std::string* GroupUpdateInviteMessage::release_adminsignature() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateInviteMessage.adminSignature) + if (!_internal_has_adminsignature()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000008u; + auto* p = _impl_.adminsignature_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void GroupUpdateInviteMessage::set_allocated_adminsignature(std::string* adminsignature) { + if (adminsignature != nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; + } else { + _impl_._has_bits_[0] &= ~0x00000008u; + } + _impl_.adminsignature_.SetAllocated(adminsignature, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateInviteMessage.adminSignature) +} + +// ------------------------------------------------------------------- + +// GroupUpdatePromoteMessage + +// required bytes groupIdentitySeed = 1; +inline bool GroupUpdatePromoteMessage::_internal_has_groupidentityseed() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool GroupUpdatePromoteMessage::has_groupidentityseed() const { + return _internal_has_groupidentityseed(); +} +inline void GroupUpdatePromoteMessage::clear_groupidentityseed() { + _impl_.groupidentityseed_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& GroupUpdatePromoteMessage::groupidentityseed() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdatePromoteMessage.groupIdentitySeed) + return _internal_groupidentityseed(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void GroupUpdatePromoteMessage::set_groupidentityseed(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.groupidentityseed_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdatePromoteMessage.groupIdentitySeed) +} +inline std::string* GroupUpdatePromoteMessage::mutable_groupidentityseed() { + std::string* _s = _internal_mutable_groupidentityseed(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdatePromoteMessage.groupIdentitySeed) + return _s; +} +inline const std::string& GroupUpdatePromoteMessage::_internal_groupidentityseed() const { + return _impl_.groupidentityseed_.Get(); +} +inline void GroupUpdatePromoteMessage::_internal_set_groupidentityseed(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.groupidentityseed_.Set(value, GetArenaForAllocation()); +} +inline std::string* GroupUpdatePromoteMessage::_internal_mutable_groupidentityseed() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.groupidentityseed_.Mutable(GetArenaForAllocation()); +} +inline std::string* GroupUpdatePromoteMessage::release_groupidentityseed() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdatePromoteMessage.groupIdentitySeed) + if (!_internal_has_groupidentityseed()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.groupidentityseed_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.groupidentityseed_.IsDefault()) { + _impl_.groupidentityseed_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void GroupUpdatePromoteMessage::set_allocated_groupidentityseed(std::string* groupidentityseed) { + if (groupidentityseed != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.groupidentityseed_.SetAllocated(groupidentityseed, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.groupidentityseed_.IsDefault()) { + _impl_.groupidentityseed_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdatePromoteMessage.groupIdentitySeed) +} + +// required string name = 2; +inline bool GroupUpdatePromoteMessage::_internal_has_name() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool GroupUpdatePromoteMessage::has_name() const { + return _internal_has_name(); +} +inline void GroupUpdatePromoteMessage::clear_name() { + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& GroupUpdatePromoteMessage::name() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdatePromoteMessage.name) + return _internal_name(); } -inline std::string* AttachmentPointer::mutable_thumbnail() { - std::string* _s = _internal_mutable_thumbnail(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.thumbnail) +template +inline PROTOBUF_ALWAYS_INLINE +void GroupUpdatePromoteMessage::set_name(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.name_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdatePromoteMessage.name) +} +inline std::string* GroupUpdatePromoteMessage::mutable_name() { + std::string* _s = _internal_mutable_name(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdatePromoteMessage.name) return _s; } -inline const std::string& AttachmentPointer::_internal_thumbnail() const { - return _impl_.thumbnail_.Get(); +inline const std::string& GroupUpdatePromoteMessage::_internal_name() const { + return _impl_.name_.Get(); } -inline void AttachmentPointer::_internal_set_thumbnail(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.thumbnail_.Set(value, GetArenaForAllocation()); +inline void GroupUpdatePromoteMessage::_internal_set_name(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.name_.Set(value, GetArenaForAllocation()); } -inline std::string* AttachmentPointer::_internal_mutable_thumbnail() { - _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.thumbnail_.Mutable(GetArenaForAllocation()); +inline std::string* GroupUpdatePromoteMessage::_internal_mutable_name() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } -inline std::string* AttachmentPointer::release_thumbnail() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.thumbnail) - if (!_internal_has_thumbnail()) { +inline std::string* GroupUpdatePromoteMessage::release_name() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdatePromoteMessage.name) + if (!_internal_has_name()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.thumbnail_.Release(); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.thumbnail_.IsDefault()) { - _impl_.thumbnail_.Set("", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void AttachmentPointer::set_allocated_thumbnail(std::string* thumbnail) { - if (thumbnail != nullptr) { - _impl_._has_bits_[0] |= 0x00000004u; +inline void GroupUpdatePromoteMessage::set_allocated_name(std::string* name) { + if (name != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.thumbnail_.SetAllocated(thumbnail, GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.thumbnail_.IsDefault()) { - _impl_.thumbnail_.Set("", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.thumbnail) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdatePromoteMessage.name) } -// optional bytes digest = 6; -inline bool AttachmentPointer::_internal_has_digest() const { +// ------------------------------------------------------------------- + +// GroupUpdateInfoChangeMessage + +// required .SessionProtos.GroupUpdateInfoChangeMessage.Type type = 1; +inline bool GroupUpdateInfoChangeMessage::_internal_has_type() const { bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } -inline bool AttachmentPointer::has_digest() const { - return _internal_has_digest(); +inline bool GroupUpdateInfoChangeMessage::has_type() const { + return _internal_has_type(); } -inline void AttachmentPointer::clear_digest() { - _impl_.digest_.ClearToEmpty(); +inline void GroupUpdateInfoChangeMessage::clear_type() { + _impl_.type_ = 1; _impl_._has_bits_[0] &= ~0x00000008u; } -inline const std::string& AttachmentPointer::digest() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.digest) - return _internal_digest(); +inline ::SessionProtos::GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::_internal_type() const { + return static_cast< ::SessionProtos::GroupUpdateInfoChangeMessage_Type >(_impl_.type_); +} +inline ::SessionProtos::GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::type() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInfoChangeMessage.type) + return _internal_type(); +} +inline void GroupUpdateInfoChangeMessage::_internal_set_type(::SessionProtos::GroupUpdateInfoChangeMessage_Type value) { + assert(::SessionProtos::GroupUpdateInfoChangeMessage_Type_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.type_ = value; +} +inline void GroupUpdateInfoChangeMessage::set_type(::SessionProtos::GroupUpdateInfoChangeMessage_Type value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInfoChangeMessage.type) +} + +// optional string updatedName = 2; +inline bool GroupUpdateInfoChangeMessage::_internal_has_updatedname() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool GroupUpdateInfoChangeMessage::has_updatedname() const { + return _internal_has_updatedname(); +} +inline void GroupUpdateInfoChangeMessage::clear_updatedname() { + _impl_.updatedname_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& GroupUpdateInfoChangeMessage::updatedname() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInfoChangeMessage.updatedName) + return _internal_updatedname(); } template inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_digest(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.digest_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.digest) +void GroupUpdateInfoChangeMessage::set_updatedname(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.updatedname_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInfoChangeMessage.updatedName) } -inline std::string* AttachmentPointer::mutable_digest() { - std::string* _s = _internal_mutable_digest(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.digest) +inline std::string* GroupUpdateInfoChangeMessage::mutable_updatedname() { + std::string* _s = _internal_mutable_updatedname(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateInfoChangeMessage.updatedName) return _s; } -inline const std::string& AttachmentPointer::_internal_digest() const { - return _impl_.digest_.Get(); +inline const std::string& GroupUpdateInfoChangeMessage::_internal_updatedname() const { + return _impl_.updatedname_.Get(); } -inline void AttachmentPointer::_internal_set_digest(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.digest_.Set(value, GetArenaForAllocation()); +inline void GroupUpdateInfoChangeMessage::_internal_set_updatedname(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.updatedname_.Set(value, GetArenaForAllocation()); } -inline std::string* AttachmentPointer::_internal_mutable_digest() { - _impl_._has_bits_[0] |= 0x00000008u; - return _impl_.digest_.Mutable(GetArenaForAllocation()); +inline std::string* GroupUpdateInfoChangeMessage::_internal_mutable_updatedname() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.updatedname_.Mutable(GetArenaForAllocation()); } -inline std::string* AttachmentPointer::release_digest() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.digest) - if (!_internal_has_digest()) { +inline std::string* GroupUpdateInfoChangeMessage::release_updatedname() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateInfoChangeMessage.updatedName) + if (!_internal_has_updatedname()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000008u; - auto* p = _impl_.digest_.Release(); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.updatedname_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.digest_.IsDefault()) { - _impl_.digest_.Set("", GetArenaForAllocation()); + if (_impl_.updatedname_.IsDefault()) { + _impl_.updatedname_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void AttachmentPointer::set_allocated_digest(std::string* digest) { - if (digest != nullptr) { - _impl_._has_bits_[0] |= 0x00000008u; +inline void GroupUpdateInfoChangeMessage::set_allocated_updatedname(std::string* updatedname) { + if (updatedname != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; } else { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.digest_.SetAllocated(digest, GetArenaForAllocation()); + _impl_.updatedname_.SetAllocated(updatedname, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.digest_.IsDefault()) { - _impl_.digest_.Set("", GetArenaForAllocation()); + if (_impl_.updatedname_.IsDefault()) { + _impl_.updatedname_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.digest) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateInfoChangeMessage.updatedName) } -// optional string fileName = 7; -inline bool AttachmentPointer::_internal_has_filename() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; +// optional uint32 updatedExpiration = 3; +inline bool GroupUpdateInfoChangeMessage::_internal_has_updatedexpiration() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool AttachmentPointer::has_filename() const { - return _internal_has_filename(); +inline bool GroupUpdateInfoChangeMessage::has_updatedexpiration() const { + return _internal_has_updatedexpiration(); } -inline void AttachmentPointer::clear_filename() { - _impl_.filename_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000010u; +inline void GroupUpdateInfoChangeMessage::clear_updatedexpiration() { + _impl_.updatedexpiration_ = 0u; + _impl_._has_bits_[0] &= ~0x00000004u; } -inline const std::string& AttachmentPointer::filename() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.fileName) - return _internal_filename(); +inline uint32_t GroupUpdateInfoChangeMessage::_internal_updatedexpiration() const { + return _impl_.updatedexpiration_; +} +inline uint32_t GroupUpdateInfoChangeMessage::updatedexpiration() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInfoChangeMessage.updatedExpiration) + return _internal_updatedexpiration(); +} +inline void GroupUpdateInfoChangeMessage::_internal_set_updatedexpiration(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.updatedexpiration_ = value; +} +inline void GroupUpdateInfoChangeMessage::set_updatedexpiration(uint32_t value) { + _internal_set_updatedexpiration(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInfoChangeMessage.updatedExpiration) +} + +// required bytes adminSignature = 4; +inline bool GroupUpdateInfoChangeMessage::_internal_has_adminsignature() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool GroupUpdateInfoChangeMessage::has_adminsignature() const { + return _internal_has_adminsignature(); +} +inline void GroupUpdateInfoChangeMessage::clear_adminsignature() { + _impl_.adminsignature_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& GroupUpdateInfoChangeMessage::adminsignature() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInfoChangeMessage.adminSignature) + return _internal_adminsignature(); } template inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_filename(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.filename_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.fileName) +void GroupUpdateInfoChangeMessage::set_adminsignature(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.adminsignature_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInfoChangeMessage.adminSignature) } -inline std::string* AttachmentPointer::mutable_filename() { - std::string* _s = _internal_mutable_filename(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.fileName) +inline std::string* GroupUpdateInfoChangeMessage::mutable_adminsignature() { + std::string* _s = _internal_mutable_adminsignature(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateInfoChangeMessage.adminSignature) return _s; } -inline const std::string& AttachmentPointer::_internal_filename() const { - return _impl_.filename_.Get(); +inline const std::string& GroupUpdateInfoChangeMessage::_internal_adminsignature() const { + return _impl_.adminsignature_.Get(); } -inline void AttachmentPointer::_internal_set_filename(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.filename_.Set(value, GetArenaForAllocation()); +inline void GroupUpdateInfoChangeMessage::_internal_set_adminsignature(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.adminsignature_.Set(value, GetArenaForAllocation()); } -inline std::string* AttachmentPointer::_internal_mutable_filename() { - _impl_._has_bits_[0] |= 0x00000010u; - return _impl_.filename_.Mutable(GetArenaForAllocation()); +inline std::string* GroupUpdateInfoChangeMessage::_internal_mutable_adminsignature() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.adminsignature_.Mutable(GetArenaForAllocation()); } -inline std::string* AttachmentPointer::release_filename() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.fileName) - if (!_internal_has_filename()) { +inline std::string* GroupUpdateInfoChangeMessage::release_adminsignature() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateInfoChangeMessage.adminSignature) + if (!_internal_has_adminsignature()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000010u; - auto* p = _impl_.filename_.Release(); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.adminsignature_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.filename_.IsDefault()) { - _impl_.filename_.Set("", GetArenaForAllocation()); + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void AttachmentPointer::set_allocated_filename(std::string* filename) { - if (filename != nullptr) { - _impl_._has_bits_[0] |= 0x00000010u; +inline void GroupUpdateInfoChangeMessage::set_allocated_adminsignature(std::string* adminsignature) { + if (adminsignature != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000002u; } - _impl_.filename_.SetAllocated(filename, GetArenaForAllocation()); + _impl_.adminsignature_.SetAllocated(adminsignature, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.filename_.IsDefault()) { - _impl_.filename_.Set("", GetArenaForAllocation()); + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.fileName) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateInfoChangeMessage.adminSignature) } -// optional uint32 flags = 8; -inline bool AttachmentPointer::_internal_has_flags() const { - bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; +// ------------------------------------------------------------------- + +// GroupUpdateMemberChangeMessage + +// required .SessionProtos.GroupUpdateMemberChangeMessage.Type type = 1; +inline bool GroupUpdateMemberChangeMessage::_internal_has_type() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool AttachmentPointer::has_flags() const { - return _internal_has_flags(); +inline bool GroupUpdateMemberChangeMessage::has_type() const { + return _internal_has_type(); } -inline void AttachmentPointer::clear_flags() { - _impl_.flags_ = 0u; - _impl_._has_bits_[0] &= ~0x00000200u; +inline void GroupUpdateMemberChangeMessage::clear_type() { + _impl_.type_ = 1; + _impl_._has_bits_[0] &= ~0x00000004u; } -inline uint32_t AttachmentPointer::_internal_flags() const { - return _impl_.flags_; +inline ::SessionProtos::GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::_internal_type() const { + return static_cast< ::SessionProtos::GroupUpdateMemberChangeMessage_Type >(_impl_.type_); } -inline uint32_t AttachmentPointer::flags() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.flags) - return _internal_flags(); +inline ::SessionProtos::GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::type() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMemberChangeMessage.type) + return _internal_type(); } -inline void AttachmentPointer::_internal_set_flags(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000200u; - _impl_.flags_ = value; +inline void GroupUpdateMemberChangeMessage::_internal_set_type(::SessionProtos::GroupUpdateMemberChangeMessage_Type value) { + assert(::SessionProtos::GroupUpdateMemberChangeMessage_Type_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.type_ = value; } -inline void AttachmentPointer::set_flags(uint32_t value) { - _internal_set_flags(value); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.flags) +inline void GroupUpdateMemberChangeMessage::set_type(::SessionProtos::GroupUpdateMemberChangeMessage_Type value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateMemberChangeMessage.type) } -// optional uint32 width = 9; -inline bool AttachmentPointer::_internal_has_width() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; - return value; +// repeated string memberSessionIds = 2; +inline int GroupUpdateMemberChangeMessage::_internal_membersessionids_size() const { + return _impl_.membersessionids_.size(); } -inline bool AttachmentPointer::has_width() const { - return _internal_has_width(); +inline int GroupUpdateMemberChangeMessage::membersessionids_size() const { + return _internal_membersessionids_size(); } -inline void AttachmentPointer::clear_width() { - _impl_.width_ = 0u; - _impl_._has_bits_[0] &= ~0x00000400u; +inline void GroupUpdateMemberChangeMessage::clear_membersessionids() { + _impl_.membersessionids_.Clear(); } -inline uint32_t AttachmentPointer::_internal_width() const { - return _impl_.width_; +inline std::string* GroupUpdateMemberChangeMessage::add_membersessionids() { + std::string* _s = _internal_add_membersessionids(); + // @@protoc_insertion_point(field_add_mutable:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) + return _s; } -inline uint32_t AttachmentPointer::width() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.width) - return _internal_width(); +inline const std::string& GroupUpdateMemberChangeMessage::_internal_membersessionids(int index) const { + return _impl_.membersessionids_.Get(index); } -inline void AttachmentPointer::_internal_set_width(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000400u; - _impl_.width_ = value; +inline const std::string& GroupUpdateMemberChangeMessage::membersessionids(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) + return _internal_membersessionids(index); } -inline void AttachmentPointer::set_width(uint32_t value) { - _internal_set_width(value); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.width) +inline std::string* GroupUpdateMemberChangeMessage::mutable_membersessionids(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) + return _impl_.membersessionids_.Mutable(index); +} +inline void GroupUpdateMemberChangeMessage::set_membersessionids(int index, const std::string& value) { + _impl_.membersessionids_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline void GroupUpdateMemberChangeMessage::set_membersessionids(int index, std::string&& value) { + _impl_.membersessionids_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline void GroupUpdateMemberChangeMessage::set_membersessionids(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.membersessionids_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline void GroupUpdateMemberChangeMessage::set_membersessionids(int index, const char* value, size_t size) { + _impl_.membersessionids_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline std::string* GroupUpdateMemberChangeMessage::_internal_add_membersessionids() { + return _impl_.membersessionids_.Add(); +} +inline void GroupUpdateMemberChangeMessage::add_membersessionids(const std::string& value) { + _impl_.membersessionids_.Add()->assign(value); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline void GroupUpdateMemberChangeMessage::add_membersessionids(std::string&& value) { + _impl_.membersessionids_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline void GroupUpdateMemberChangeMessage::add_membersessionids(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.membersessionids_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline void GroupUpdateMemberChangeMessage::add_membersessionids(const char* value, size_t size) { + _impl_.membersessionids_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +GroupUpdateMemberChangeMessage::membersessionids() const { + // @@protoc_insertion_point(field_list:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) + return _impl_.membersessionids_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +GroupUpdateMemberChangeMessage::mutable_membersessionids() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds) + return &_impl_.membersessionids_; } -// optional uint32 height = 10; -inline bool AttachmentPointer::_internal_has_height() const { - bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; +// optional bool historyShared = 3; +inline bool GroupUpdateMemberChangeMessage::_internal_has_historyshared() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool AttachmentPointer::has_height() const { - return _internal_has_height(); +inline bool GroupUpdateMemberChangeMessage::has_historyshared() const { + return _internal_has_historyshared(); } -inline void AttachmentPointer::clear_height() { - _impl_.height_ = 0u; - _impl_._has_bits_[0] &= ~0x00000800u; +inline void GroupUpdateMemberChangeMessage::clear_historyshared() { + _impl_.historyshared_ = false; + _impl_._has_bits_[0] &= ~0x00000002u; } -inline uint32_t AttachmentPointer::_internal_height() const { - return _impl_.height_; +inline bool GroupUpdateMemberChangeMessage::_internal_historyshared() const { + return _impl_.historyshared_; } -inline uint32_t AttachmentPointer::height() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.height) - return _internal_height(); +inline bool GroupUpdateMemberChangeMessage::historyshared() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMemberChangeMessage.historyShared) + return _internal_historyshared(); } -inline void AttachmentPointer::_internal_set_height(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000800u; - _impl_.height_ = value; +inline void GroupUpdateMemberChangeMessage::_internal_set_historyshared(bool value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.historyshared_ = value; } -inline void AttachmentPointer::set_height(uint32_t value) { - _internal_set_height(value); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.height) +inline void GroupUpdateMemberChangeMessage::set_historyshared(bool value) { + _internal_set_historyshared(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateMemberChangeMessage.historyShared) } -// optional string caption = 11; -inline bool AttachmentPointer::_internal_has_caption() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; +// required bytes adminSignature = 4; +inline bool GroupUpdateMemberChangeMessage::_internal_has_adminsignature() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool AttachmentPointer::has_caption() const { - return _internal_has_caption(); +inline bool GroupUpdateMemberChangeMessage::has_adminsignature() const { + return _internal_has_adminsignature(); } -inline void AttachmentPointer::clear_caption() { - _impl_.caption_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000020u; +inline void GroupUpdateMemberChangeMessage::clear_adminsignature() { + _impl_.adminsignature_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& AttachmentPointer::caption() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.caption) - return _internal_caption(); +inline const std::string& GroupUpdateMemberChangeMessage::adminsignature() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateMemberChangeMessage.adminSignature) + return _internal_adminsignature(); } template inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_caption(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.caption_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.caption) +void GroupUpdateMemberChangeMessage::set_adminsignature(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.adminsignature_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateMemberChangeMessage.adminSignature) } -inline std::string* AttachmentPointer::mutable_caption() { - std::string* _s = _internal_mutable_caption(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.caption) +inline std::string* GroupUpdateMemberChangeMessage::mutable_adminsignature() { + std::string* _s = _internal_mutable_adminsignature(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateMemberChangeMessage.adminSignature) return _s; } -inline const std::string& AttachmentPointer::_internal_caption() const { - return _impl_.caption_.Get(); +inline const std::string& GroupUpdateMemberChangeMessage::_internal_adminsignature() const { + return _impl_.adminsignature_.Get(); } -inline void AttachmentPointer::_internal_set_caption(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.caption_.Set(value, GetArenaForAllocation()); +inline void GroupUpdateMemberChangeMessage::_internal_set_adminsignature(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.adminsignature_.Set(value, GetArenaForAllocation()); } -inline std::string* AttachmentPointer::_internal_mutable_caption() { - _impl_._has_bits_[0] |= 0x00000020u; - return _impl_.caption_.Mutable(GetArenaForAllocation()); +inline std::string* GroupUpdateMemberChangeMessage::_internal_mutable_adminsignature() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.adminsignature_.Mutable(GetArenaForAllocation()); } -inline std::string* AttachmentPointer::release_caption() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.caption) - if (!_internal_has_caption()) { +inline std::string* GroupUpdateMemberChangeMessage::release_adminsignature() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateMemberChangeMessage.adminSignature) + if (!_internal_has_adminsignature()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000020u; - auto* p = _impl_.caption_.Release(); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.adminsignature_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.caption_.IsDefault()) { - _impl_.caption_.Set("", GetArenaForAllocation()); + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void AttachmentPointer::set_allocated_caption(std::string* caption) { - if (caption != nullptr) { - _impl_._has_bits_[0] |= 0x00000020u; +inline void GroupUpdateMemberChangeMessage::set_allocated_adminsignature(std::string* adminsignature) { + if (adminsignature != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; } else { - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.caption_.SetAllocated(caption, GetArenaForAllocation()); + _impl_.adminsignature_.SetAllocated(adminsignature, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.caption_.IsDefault()) { - _impl_.caption_.Set("", GetArenaForAllocation()); + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.caption) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateMemberChangeMessage.adminSignature) } -// optional string url = 101; -inline bool AttachmentPointer::_internal_has_url() const { - bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; +// ------------------------------------------------------------------- + +// GroupUpdateMemberLeftMessage + +// ------------------------------------------------------------------- + +// GroupUpdateMemberLeftNotificationMessage + +// ------------------------------------------------------------------- + +// GroupUpdateInviteResponseMessage + +// required bool isApproved = 1; +inline bool GroupUpdateInviteResponseMessage::_internal_has_isapproved() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool AttachmentPointer::has_url() const { - return _internal_has_url(); +inline bool GroupUpdateInviteResponseMessage::has_isapproved() const { + return _internal_has_isapproved(); } -inline void AttachmentPointer::clear_url() { - _impl_.url_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000040u; +inline void GroupUpdateInviteResponseMessage::clear_isapproved() { + _impl_.isapproved_ = false; + _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& AttachmentPointer::url() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.url) - return _internal_url(); +inline bool GroupUpdateInviteResponseMessage::_internal_isapproved() const { + return _impl_.isapproved_; } -template -inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_url(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000040u; - _impl_.url_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.url) +inline bool GroupUpdateInviteResponseMessage::isapproved() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateInviteResponseMessage.isApproved) + return _internal_isapproved(); } -inline std::string* AttachmentPointer::mutable_url() { - std::string* _s = _internal_mutable_url(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.url) +inline void GroupUpdateInviteResponseMessage::_internal_set_isapproved(bool value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.isapproved_ = value; +} +inline void GroupUpdateInviteResponseMessage::set_isapproved(bool value) { + _internal_set_isapproved(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateInviteResponseMessage.isApproved) +} + +// ------------------------------------------------------------------- + +// GroupUpdateDeleteMemberContentMessage + +// repeated string memberSessionIds = 1; +inline int GroupUpdateDeleteMemberContentMessage::_internal_membersessionids_size() const { + return _impl_.membersessionids_.size(); +} +inline int GroupUpdateDeleteMemberContentMessage::membersessionids_size() const { + return _internal_membersessionids_size(); +} +inline void GroupUpdateDeleteMemberContentMessage::clear_membersessionids() { + _impl_.membersessionids_.Clear(); +} +inline std::string* GroupUpdateDeleteMemberContentMessage::add_membersessionids() { + std::string* _s = _internal_add_membersessionids(); + // @@protoc_insertion_point(field_add_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) return _s; } -inline const std::string& AttachmentPointer::_internal_url() const { - return _impl_.url_.Get(); +inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_membersessionids(int index) const { + return _impl_.membersessionids_.Get(index); } -inline void AttachmentPointer::_internal_set_url(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000040u; - _impl_.url_.Set(value, GetArenaForAllocation()); +inline const std::string& GroupUpdateDeleteMemberContentMessage::membersessionids(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) + return _internal_membersessionids(index); } -inline std::string* AttachmentPointer::_internal_mutable_url() { - _impl_._has_bits_[0] |= 0x00000040u; - return _impl_.url_.Mutable(GetArenaForAllocation()); +inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_membersessionids(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) + return _impl_.membersessionids_.Mutable(index); } -inline std::string* AttachmentPointer::release_url() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.url) - if (!_internal_has_url()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000040u; - auto* p = _impl_.url_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.url_.IsDefault()) { - _impl_.url_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; +inline void GroupUpdateDeleteMemberContentMessage::set_membersessionids(int index, const std::string& value) { + _impl_.membersessionids_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } -inline void AttachmentPointer::set_allocated_url(std::string* url) { - if (url != nullptr) { - _impl_._has_bits_[0] |= 0x00000040u; - } else { - _impl_._has_bits_[0] &= ~0x00000040u; - } - _impl_.url_.SetAllocated(url, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.url_.IsDefault()) { - _impl_.url_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.url) +inline void GroupUpdateDeleteMemberContentMessage::set_membersessionids(int index, std::string&& value) { + _impl_.membersessionids_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } - -// ------------------------------------------------------------------- - -// SharedConfigMessage - -// required .SessionProtos.SharedConfigMessage.Kind kind = 1; -inline bool SharedConfigMessage::_internal_has_kind() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; +inline void GroupUpdateDeleteMemberContentMessage::set_membersessionids(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.membersessionids_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } -inline bool SharedConfigMessage::has_kind() const { - return _internal_has_kind(); +inline void GroupUpdateDeleteMemberContentMessage::set_membersessionids(int index, const char* value, size_t size) { + _impl_.membersessionids_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } -inline void SharedConfigMessage::clear_kind() { - _impl_.kind_ = 1; - _impl_._has_bits_[0] &= ~0x00000004u; +inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_add_membersessionids() { + return _impl_.membersessionids_.Add(); } -inline ::SessionProtos::SharedConfigMessage_Kind SharedConfigMessage::_internal_kind() const { - return static_cast< ::SessionProtos::SharedConfigMessage_Kind >(_impl_.kind_); +inline void GroupUpdateDeleteMemberContentMessage::add_membersessionids(const std::string& value) { + _impl_.membersessionids_.Add()->assign(value); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } -inline ::SessionProtos::SharedConfigMessage_Kind SharedConfigMessage::kind() const { - // @@protoc_insertion_point(field_get:SessionProtos.SharedConfigMessage.kind) - return _internal_kind(); +inline void GroupUpdateDeleteMemberContentMessage::add_membersessionids(std::string&& value) { + _impl_.membersessionids_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } -inline void SharedConfigMessage::_internal_set_kind(::SessionProtos::SharedConfigMessage_Kind value) { - assert(::SessionProtos::SharedConfigMessage_Kind_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.kind_ = value; +inline void GroupUpdateDeleteMemberContentMessage::add_membersessionids(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.membersessionids_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) } -inline void SharedConfigMessage::set_kind(::SessionProtos::SharedConfigMessage_Kind value) { - _internal_set_kind(value); - // @@protoc_insertion_point(field_set:SessionProtos.SharedConfigMessage.kind) +inline void GroupUpdateDeleteMemberContentMessage::add_membersessionids(const char* value, size_t size) { + _impl_.membersessionids_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +GroupUpdateDeleteMemberContentMessage::membersessionids() const { + // @@protoc_insertion_point(field_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) + return _impl_.membersessionids_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +GroupUpdateDeleteMemberContentMessage::mutable_membersessionids() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) + return &_impl_.membersessionids_; } -// required int64 seqno = 2; -inline bool SharedConfigMessage::_internal_has_seqno() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; +// repeated string messageHashes = 2; +inline int GroupUpdateDeleteMemberContentMessage::_internal_messagehashes_size() const { + return _impl_.messagehashes_.size(); } -inline bool SharedConfigMessage::has_seqno() const { - return _internal_has_seqno(); +inline int GroupUpdateDeleteMemberContentMessage::messagehashes_size() const { + return _internal_messagehashes_size(); } -inline void SharedConfigMessage::clear_seqno() { - _impl_.seqno_ = int64_t{0}; - _impl_._has_bits_[0] &= ~0x00000002u; +inline void GroupUpdateDeleteMemberContentMessage::clear_messagehashes() { + _impl_.messagehashes_.Clear(); } -inline int64_t SharedConfigMessage::_internal_seqno() const { - return _impl_.seqno_; +inline std::string* GroupUpdateDeleteMemberContentMessage::add_messagehashes() { + std::string* _s = _internal_add_messagehashes(); + // @@protoc_insertion_point(field_add_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _s; } -inline int64_t SharedConfigMessage::seqno() const { - // @@protoc_insertion_point(field_get:SessionProtos.SharedConfigMessage.seqno) - return _internal_seqno(); +inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_messagehashes(int index) const { + return _impl_.messagehashes_.Get(index); } -inline void SharedConfigMessage::_internal_set_seqno(int64_t value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.seqno_ = value; +inline const std::string& GroupUpdateDeleteMemberContentMessage::messagehashes(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _internal_messagehashes(index); } -inline void SharedConfigMessage::set_seqno(int64_t value) { - _internal_set_seqno(value); - // @@protoc_insertion_point(field_set:SessionProtos.SharedConfigMessage.seqno) +inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_messagehashes(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _impl_.messagehashes_.Mutable(index); +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const std::string& value) { + _impl_.messagehashes_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, std::string&& value) { + _impl_.messagehashes_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.messagehashes_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const char* value, size_t size) { + _impl_.messagehashes_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_add_messagehashes() { + return _impl_.messagehashes_.Add(); +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const std::string& value) { + _impl_.messagehashes_.Add()->assign(value); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(std::string&& value) { + _impl_.messagehashes_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.messagehashes_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const char* value, size_t size) { + _impl_.messagehashes_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +GroupUpdateDeleteMemberContentMessage::messagehashes() const { + // @@protoc_insertion_point(field_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _impl_.messagehashes_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +GroupUpdateDeleteMemberContentMessage::mutable_messagehashes() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return &_impl_.messagehashes_; } -// required bytes data = 3; -inline bool SharedConfigMessage::_internal_has_data() const { +// optional bytes adminSignature = 3; +inline bool GroupUpdateDeleteMemberContentMessage::_internal_has_adminsignature() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool SharedConfigMessage::has_data() const { - return _internal_has_data(); +inline bool GroupUpdateDeleteMemberContentMessage::has_adminsignature() const { + return _internal_has_adminsignature(); } -inline void SharedConfigMessage::clear_data() { - _impl_.data_.ClearToEmpty(); +inline void GroupUpdateDeleteMemberContentMessage::clear_adminsignature() { + _impl_.adminsignature_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& SharedConfigMessage::data() const { - // @@protoc_insertion_point(field_get:SessionProtos.SharedConfigMessage.data) - return _internal_data(); +inline const std::string& GroupUpdateDeleteMemberContentMessage::adminsignature() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + return _internal_adminsignature(); } template inline PROTOBUF_ALWAYS_INLINE -void SharedConfigMessage::set_data(ArgT0&& arg0, ArgT... args) { +void GroupUpdateDeleteMemberContentMessage::set_adminsignature(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.data_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.SharedConfigMessage.data) + _impl_.adminsignature_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) } -inline std::string* SharedConfigMessage::mutable_data() { - std::string* _s = _internal_mutable_data(); - // @@protoc_insertion_point(field_mutable:SessionProtos.SharedConfigMessage.data) +inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_adminsignature() { + std::string* _s = _internal_mutable_adminsignature(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) return _s; } -inline const std::string& SharedConfigMessage::_internal_data() const { - return _impl_.data_.Get(); +inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_adminsignature() const { + return _impl_.adminsignature_.Get(); } -inline void SharedConfigMessage::_internal_set_data(const std::string& value) { +inline void GroupUpdateDeleteMemberContentMessage::_internal_set_adminsignature(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.data_.Set(value, GetArenaForAllocation()); + _impl_.adminsignature_.Set(value, GetArenaForAllocation()); } -inline std::string* SharedConfigMessage::_internal_mutable_data() { +inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_mutable_adminsignature() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.data_.Mutable(GetArenaForAllocation()); + return _impl_.adminsignature_.Mutable(GetArenaForAllocation()); } -inline std::string* SharedConfigMessage::release_data() { - // @@protoc_insertion_point(field_release:SessionProtos.SharedConfigMessage.data) - if (!_internal_has_data()) { +inline std::string* GroupUpdateDeleteMemberContentMessage::release_adminsignature() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + if (!_internal_has_adminsignature()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.data_.Release(); + auto* p = _impl_.adminsignature_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.data_.IsDefault()) { - _impl_.data_.Set("", GetArenaForAllocation()); + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void SharedConfigMessage::set_allocated_data(std::string* data) { - if (data != nullptr) { +inline void GroupUpdateDeleteMemberContentMessage::set_allocated_adminsignature(std::string* adminsignature) { + if (adminsignature != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.data_.SetAllocated(data, GetArenaForAllocation()); + _impl_.adminsignature_.SetAllocated(adminsignature, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.data_.IsDefault()) { - _impl_.data_.Set("", GetArenaForAllocation()); + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.SharedConfigMessage.data) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) } #ifdef __GNUC__ @@ -13623,6 +13415,8 @@ inline void SharedConfigMessage::set_allocated_data(std::string* data) { // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) @@ -13631,16 +13425,70 @@ inline void SharedConfigMessage::set_allocated_data(std::string* data) { PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::SessionProtos::Envelope_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::Envelope_Type>() { + return ::SessionProtos::Envelope_Type_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::TypingMessage_Action> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::TypingMessage_Action>() { + return ::SessionProtos::TypingMessage_Action_descriptor(); +} +template <> struct is_proto_enum< ::SessionProtos::Content_ExpirationType> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::Content_ExpirationType>() { + return ::SessionProtos::Content_ExpirationType_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::CallMessage_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::CallMessage_Type>() { + return ::SessionProtos::CallMessage_Type_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::DataExtractionNotification_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataExtractionNotification_Type>() { + return ::SessionProtos::DataExtractionNotification_Type_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::DataMessage_Quote_QuotedAttachment_Flags> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataMessage_Quote_QuotedAttachment_Flags>() { + return ::SessionProtos::DataMessage_Quote_QuotedAttachment_Flags_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::DataMessage_Reaction_Action> : ::std::true_type {}; -template <> struct is_proto_enum< ::SessionProtos::DataMessage_ClosedGroupControlMessage_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataMessage_Reaction_Action>() { + return ::SessionProtos::DataMessage_Reaction_Action_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::DataMessage_Flags> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataMessage_Flags>() { + return ::SessionProtos::DataMessage_Flags_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::ReceiptMessage_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::ReceiptMessage_Type>() { + return ::SessionProtos::ReceiptMessage_Type_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::AttachmentPointer_Flags> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::AttachmentPointer_Flags>() { + return ::SessionProtos::AttachmentPointer_Flags_descriptor(); +} template <> struct is_proto_enum< ::SessionProtos::SharedConfigMessage_Kind> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::SharedConfigMessage_Kind>() { + return ::SessionProtos::SharedConfigMessage_Kind_descriptor(); +} +template <> struct is_proto_enum< ::SessionProtos::GroupUpdateInfoChangeMessage_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::GroupUpdateInfoChangeMessage_Type>() { + return ::SessionProtos::GroupUpdateInfoChangeMessage_Type_descriptor(); +} +template <> struct is_proto_enum< ::SessionProtos::GroupUpdateMemberChangeMessage_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::GroupUpdateMemberChangeMessage_Type>() { + return ::SessionProtos::GroupUpdateMemberChangeMessage_Type_descriptor(); +} PROTOBUF_NAMESPACE_CLOSE diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index f1ab2da7..07dec5ec 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -4,8 +4,6 @@ syntax = "proto2"; // iOS - package name determines class prefix package SessionProtos; -option optimize_for = LITE_RUNTIME; - message Envelope { enum Type { @@ -50,34 +48,28 @@ message MessageRequestResponse { optional LokiProfile profile = 3; } -message ProProof { - required uint32 version = 1; - required bytes genIndexHash = 2; - required bytes rotatingPublicKey = 3; - required uint64 expiryUnixTs = 4; - required bytes sig = 5; -} - -message ProConfig { - required bytes rotatingPrivKey = 1; - required ProProof proof = 2; -} -message ProMessageConfig { - required ProProof proof = 1; - required uint32 flags = 2; -} - message Content { - optional DataMessage dataMessage = 1; - optional CallMessage callMessage = 3; - optional ReceiptMessage receiptMessage = 5; - optional TypingMessage typingMessage = 6; - optional ConfigurationMessage configurationMessage = 7; - optional DataExtractionNotification dataExtractionNotification = 8; - optional UnsendRequest unsendRequest = 9; - optional MessageRequestResponse messageRequestResponse = 10; - optional SharedConfigMessage sharedConfigMessage = 11; - optional ProMessageConfig proMessageConfig = 12; + + enum ExpirationType { + UNKNOWN = 0; + DELETE_AFTER_READ = 1; + DELETE_AFTER_SEND = 2; + } + + // reserved 7, 11, 15; + // reserved "configurationMessage", "sharedConfigMessage", "lastDisappearingMessageChangeTimestamp"; + + optional DataMessage dataMessage = 1; + optional CallMessage callMessage = 3; + optional ReceiptMessage receiptMessage = 5; + optional TypingMessage typingMessage = 6; + optional DataExtractionNotification dataExtractionNotification = 8; + optional UnsendRequest unsendRequest = 9; + optional MessageRequestResponse messageRequestResponse = 10; + optional SharedConfigMessage sharedConfigMessage = 11; + optional ExpirationType expirationType = 12; + optional uint32 expirationTimer = 13; + optional uint64 sigTimestamp = 15; } message CallMessage { @@ -181,42 +173,17 @@ message DataMessage { // @required required string name = 3; } - - message ClosedGroupControlMessage { - - enum Type { - NEW = 1; // publicKey, name, encryptionKeyPair, members, admins, expirationTimer - ENCRYPTION_KEY_PAIR = 3; // publicKey, wrappers - NAME_CHANGE = 4; // name - MEMBERS_ADDED = 5; // members - MEMBERS_REMOVED = 6; // members - MEMBER_LEFT = 7; - ENCRYPTION_KEY_PAIR_REQUEST = 8; - } - - message KeyPairWrapper { - // @required - required bytes publicKey = 1; // The public key of the user the key pair is meant for - // @required - required bytes encryptedKeyPair = 2; // The encrypted key pair - } - - // @required - required Type type = 1; - optional bytes publicKey = 2; - optional string name = 3; - optional KeyPair encryptionKeyPair = 4; - repeated bytes members = 5; - repeated bytes admins = 6; - repeated KeyPairWrapper wrappers = 7; - optional uint32 expirationTimer = 8; - } + + + // reserved 3; + // reserved "group"; + // reserved 104; + // reserved "closedGroupControlMessage"; optional string body = 1; repeated AttachmentPointer attachments = 2; - // optional GroupContext group = 3; // No longer used optional uint32 flags = 4; - optional uint32 expireTimer = 5; + // optional uint32 expireTimer = 5; // No longer used optional bytes profileKey = 6; optional uint64 timestamp = 7; optional Quote quote = 8; @@ -224,41 +191,9 @@ message DataMessage { optional Reaction reaction = 11; optional LokiProfile profile = 101; optional OpenGroupInvitation openGroupInvitation = 102; - optional ClosedGroupControlMessage closedGroupControlMessage = 104; optional string syncTarget = 105; optional bool blocksCommunityMessageRequests = 106; -} - -message ConfigurationMessage { - - message ClosedGroup { - optional bytes publicKey = 1; - optional string name = 2; - optional KeyPair encryptionKeyPair = 3; - repeated bytes members = 4; - repeated bytes admins = 5; - optional uint32 expirationTimer = 6; - } - - message Contact { - // @required - required bytes publicKey = 1; - // @required - required string name = 2; - optional string profilePicture = 3; - optional bytes profileKey = 4; - optional bool isApproved = 5; // added for msg requests - optional bool isBlocked = 6; // added for msg requests - optional bool didApproveMe = 7; // added for msg requests - } - - repeated ClosedGroup closedGroups = 1; - repeated string openGroups = 2; - optional string displayName = 3; - optional string profilePicture = 4; - optional bytes profileKey = 5; - repeated Contact contacts = 6; - optional ProConfig proConfig = 7; + optional GroupUpdateMessage groupUpdateMessage = 120; } message ReceiptMessage { @@ -303,9 +238,89 @@ message SharedConfigMessage { } // @required - required Kind kind = 1; + required Kind kind = 1; // @required - required int64 seqno = 2; + required int64 seqno = 2; // @required - required bytes data = 3; + required bytes data = 3; +} + +// Group Update Messages + +message GroupUpdateMessage { + optional GroupUpdateInviteMessage inviteMessage = 1; + optional GroupUpdateInfoChangeMessage infoChangeMessage = 2; + optional GroupUpdateMemberChangeMessage memberChangeMessage = 3; + optional GroupUpdatePromoteMessage promoteMessage = 4; + optional GroupUpdateMemberLeftMessage memberLeftMessage = 5; + optional GroupUpdateInviteResponseMessage inviteResponse = 6; + optional GroupUpdateDeleteMemberContentMessage deleteMemberContent = 7; + optional GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8; +} + +message GroupUpdateInviteMessage { + // @required + required string groupSessionId = 1; // The `groupIdentityPublicKey` with a `03` prefix + // @required + required string name = 2; + // @required + required bytes memberAuthData = 3; + // @required + required bytes adminSignature = 4; +} + +message GroupUpdatePromoteMessage { + // @required + required bytes groupIdentitySeed = 1; + // @required + required string name = 2; +} + +message GroupUpdateInfoChangeMessage { + enum Type { + NAME = 1; + AVATAR = 2; + DISAPPEARING_MESSAGES = 3; + } + + // @required + required Type type = 1; + optional string updatedName = 2; + optional uint32 updatedExpiration = 3; + // @required + required bytes adminSignature = 4; +} + +message GroupUpdateMemberChangeMessage { + enum Type { + ADDED = 1; + REMOVED = 2; + PROMOTED = 3; + } + + // @required + required Type type = 1; + repeated string memberSessionIds = 2; + optional bool historyShared = 3; + // @required + required bytes adminSignature = 4; +} + +message GroupUpdateMemberLeftMessage { + // the pubkey of the member left is included as part of the closed group encryption logic (senderIdentity on desktop) +} + +message GroupUpdateMemberLeftNotificationMessage { + // the pubkey of the member left is included as part of the closed group encryption logic (senderIdentity on desktop) +} + +message GroupUpdateInviteResponseMessage { + // @required + required bool isApproved = 1; // Whether the request was approved +} + +message GroupUpdateDeleteMemberContentMessage { + repeated string memberSessionIds = 1; + repeated string messageHashes = 2; + optional bytes adminSignature = 3; } From e899ef6b798e1e2c6f62c24e7103df29fcb77538 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 8 Aug 2025 11:32:49 +1000 Subject: [PATCH 014/171] Revise the PRO protobuf structures --- proto/SessionProtos.pb.cc | 1630 +++++++++++++++++++++++++---- proto/SessionProtos.pb.h | 2035 +++++++++++++++++++++++++++++++------ proto/SessionProtos.proto | 15 + 3 files changed, 3131 insertions(+), 549 deletions(-) diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index 7d80eabf..a55151c1 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -27,6 +27,7 @@ PROTOBUF_CONSTEXPR Envelope::Envelope( , /*decltype(_impl_._cached_size_)*/{} , /*decltype(_impl_.source_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.content_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.prosig_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.timestamp_)*/uint64_t{0u} , /*decltype(_impl_.servertimestamp_)*/uint64_t{0u} , /*decltype(_impl_.sourcedevice_)*/0u @@ -98,6 +99,7 @@ PROTOBUF_CONSTEXPR Content::Content( , /*decltype(_impl_.unsendrequest_)*/nullptr , /*decltype(_impl_.messagerequestresponse_)*/nullptr , /*decltype(_impl_.sharedconfigmessage_)*/nullptr + , /*decltype(_impl_.promessage_)*/nullptr , /*decltype(_impl_.expirationtype_)*/0 , /*decltype(_impl_.expirationtimer_)*/0u , /*decltype(_impl_.sigtimestamp_)*/uint64_t{0u}} {} @@ -476,8 +478,56 @@ struct GroupUpdateDeleteMemberContentMessageDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateDeleteMemberContentMessageDefaultTypeInternal _GroupUpdateDeleteMemberContentMessage_default_instance_; +PROTOBUF_CONSTEXPR ProProof::ProProof( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.genindexhash_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.rotatingpublickey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.sig_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.expiryunixts_)*/uint64_t{0u} + , /*decltype(_impl_.version_)*/0u} {} +struct ProProofDefaultTypeInternal { + PROTOBUF_CONSTEXPR ProProofDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ProProofDefaultTypeInternal() {} + union { + ProProof _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProProofDefaultTypeInternal _ProProof_default_instance_; +PROTOBUF_CONSTEXPR ProConfig::ProConfig( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.rotatingprivkey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.proof_)*/nullptr} {} +struct ProConfigDefaultTypeInternal { + PROTOBUF_CONSTEXPR ProConfigDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ProConfigDefaultTypeInternal() {} + union { + ProConfig _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProConfigDefaultTypeInternal _ProConfig_default_instance_; +PROTOBUF_CONSTEXPR ProMessage::ProMessage( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.proof_)*/nullptr + , /*decltype(_impl_.flags_)*/0u} {} +struct ProMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR ProMessageDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ProMessageDefaultTypeInternal() {} + union { + ProMessage _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProMessageDefaultTypeInternal _ProMessage_default_instance_; } // namespace SessionProtos -static ::_pb::Metadata file_level_metadata_SessionProtos_2eproto[27]; +static ::_pb::Metadata file_level_metadata_SessionProtos_2eproto[30]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_SessionProtos_2eproto[13]; static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_SessionProtos_2eproto = nullptr; @@ -494,12 +544,14 @@ const uint32_t TableStruct_SessionProtos_2eproto::offsets[] PROTOBUF_SECTION_VAR PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.timestamp_), PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.content_), PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.servertimestamp_), - 5, + PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.prosig_), + 6, 0, + 5, + 3, + 1, 4, 2, - 1, - 3, PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _internal_metadata_), ~0u, // no _extensions_ @@ -549,6 +601,7 @@ const uint32_t TableStruct_SessionProtos_2eproto::offsets[] PROTOBUF_SECTION_VAR PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.expirationtype_), PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.expirationtimer_), PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.sigtimestamp_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.promessage_), 0, 1, 2, @@ -557,9 +610,10 @@ const uint32_t TableStruct_SessionProtos_2eproto::offsets[] PROTOBUF_SECTION_VAR 5, 6, 7, - 8, 9, 10, + 11, + 8, PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _internal_metadata_), ~0u, // no _extensions_ @@ -860,35 +914,74 @@ const uint32_t TableStruct_SessionProtos_2eproto::offsets[] PROTOBUF_SECTION_VAR ~0u, ~0u, 0, + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.version_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.genindexhash_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.rotatingpublickey_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.expiryunixts_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.sig_), + 4, + 0, + 1, + 3, + 2, + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _impl_.rotatingprivkey_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _impl_.proof_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _impl_.proof_), + PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _impl_.flags_), + 0, + 1, }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 12, -1, sizeof(::SessionProtos::Envelope)}, - { 18, 26, -1, sizeof(::SessionProtos::TypingMessage)}, - { 28, 36, -1, sizeof(::SessionProtos::UnsendRequest)}, - { 38, 47, -1, sizeof(::SessionProtos::MessageRequestResponse)}, - { 50, 67, -1, sizeof(::SessionProtos::Content)}, - { 78, 89, -1, sizeof(::SessionProtos::CallMessage)}, - { 94, 102, -1, sizeof(::SessionProtos::KeyPair)}, - { 104, 112, -1, sizeof(::SessionProtos::DataExtractionNotification)}, - { 114, 122, -1, sizeof(::SessionProtos::LokiProfile)}, - { 124, 134, -1, sizeof(::SessionProtos::DataMessage_Quote_QuotedAttachment)}, - { 138, 148, -1, sizeof(::SessionProtos::DataMessage_Quote)}, - { 152, 161, -1, sizeof(::SessionProtos::DataMessage_Preview)}, - { 164, 174, -1, sizeof(::SessionProtos::DataMessage_Reaction)}, - { 178, 186, -1, sizeof(::SessionProtos::DataMessage_OpenGroupInvitation)}, - { 188, 207, -1, sizeof(::SessionProtos::DataMessage)}, - { 220, 228, -1, sizeof(::SessionProtos::ReceiptMessage)}, - { 230, 248, -1, sizeof(::SessionProtos::AttachmentPointer)}, - { 260, 269, -1, sizeof(::SessionProtos::SharedConfigMessage)}, - { 272, 286, -1, sizeof(::SessionProtos::GroupUpdateMessage)}, - { 294, 304, -1, sizeof(::SessionProtos::GroupUpdateInviteMessage)}, - { 308, 316, -1, sizeof(::SessionProtos::GroupUpdatePromoteMessage)}, - { 318, 328, -1, sizeof(::SessionProtos::GroupUpdateInfoChangeMessage)}, - { 332, 342, -1, sizeof(::SessionProtos::GroupUpdateMemberChangeMessage)}, - { 346, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftMessage)}, - { 352, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftNotificationMessage)}, - { 358, 365, -1, sizeof(::SessionProtos::GroupUpdateInviteResponseMessage)}, - { 366, 375, -1, sizeof(::SessionProtos::GroupUpdateDeleteMemberContentMessage)}, + { 0, 13, -1, sizeof(::SessionProtos::Envelope)}, + { 20, 28, -1, sizeof(::SessionProtos::TypingMessage)}, + { 30, 38, -1, sizeof(::SessionProtos::UnsendRequest)}, + { 40, 49, -1, sizeof(::SessionProtos::MessageRequestResponse)}, + { 52, 70, -1, sizeof(::SessionProtos::Content)}, + { 82, 93, -1, sizeof(::SessionProtos::CallMessage)}, + { 98, 106, -1, sizeof(::SessionProtos::KeyPair)}, + { 108, 116, -1, sizeof(::SessionProtos::DataExtractionNotification)}, + { 118, 126, -1, sizeof(::SessionProtos::LokiProfile)}, + { 128, 138, -1, sizeof(::SessionProtos::DataMessage_Quote_QuotedAttachment)}, + { 142, 152, -1, sizeof(::SessionProtos::DataMessage_Quote)}, + { 156, 165, -1, sizeof(::SessionProtos::DataMessage_Preview)}, + { 168, 178, -1, sizeof(::SessionProtos::DataMessage_Reaction)}, + { 182, 190, -1, sizeof(::SessionProtos::DataMessage_OpenGroupInvitation)}, + { 192, 211, -1, sizeof(::SessionProtos::DataMessage)}, + { 224, 232, -1, sizeof(::SessionProtos::ReceiptMessage)}, + { 234, 252, -1, sizeof(::SessionProtos::AttachmentPointer)}, + { 264, 273, -1, sizeof(::SessionProtos::SharedConfigMessage)}, + { 276, 290, -1, sizeof(::SessionProtos::GroupUpdateMessage)}, + { 298, 308, -1, sizeof(::SessionProtos::GroupUpdateInviteMessage)}, + { 312, 320, -1, sizeof(::SessionProtos::GroupUpdatePromoteMessage)}, + { 322, 332, -1, sizeof(::SessionProtos::GroupUpdateInfoChangeMessage)}, + { 336, 346, -1, sizeof(::SessionProtos::GroupUpdateMemberChangeMessage)}, + { 350, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftMessage)}, + { 356, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftNotificationMessage)}, + { 362, 369, -1, sizeof(::SessionProtos::GroupUpdateInviteResponseMessage)}, + { 370, 379, -1, sizeof(::SessionProtos::GroupUpdateDeleteMemberContentMessage)}, + { 382, 393, -1, sizeof(::SessionProtos::ProProof)}, + { 398, 406, -1, sizeof(::SessionProtos::ProConfig)}, + { 408, 416, -1, sizeof(::SessionProtos::ProMessage)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -919,138 +1012,149 @@ static const ::_pb::Message* const file_default_instances[] = { &::SessionProtos::_GroupUpdateMemberLeftNotificationMessage_default_instance_._instance, &::SessionProtos::_GroupUpdateInviteResponseMessage_default_instance_._instance, &::SessionProtos::_GroupUpdateDeleteMemberContentMessage_default_instance_._instance, + &::SessionProtos::_ProProof_default_instance_._instance, + &::SessionProtos::_ProConfig_default_instance_._instance, + &::SessionProtos::_ProMessage_default_instance_._instance, }; const char descriptor_table_protodef_SessionProtos_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n\023SessionProtos.proto\022\rSessionProtos\"\320\001\n" + "\n\023SessionProtos.proto\022\rSessionProtos\"\340\001\n" "\010Envelope\022*\n\004type\030\001 \002(\0162\034.SessionProtos." "Envelope.Type\022\016\n\006source\030\002 \001(\t\022\024\n\014sourceD" "evice\030\007 \001(\r\022\021\n\ttimestamp\030\005 \002(\004\022\017\n\007conten" - "t\030\010 \001(\014\022\027\n\017serverTimestamp\030\n \001(\004\"5\n\004Type" - "\022\023\n\017SESSION_MESSAGE\020\006\022\030\n\024CLOSED_GROUP_ME" - "SSAGE\020\007\"{\n\rTypingMessage\022\021\n\ttimestamp\030\001 " - "\002(\004\0223\n\006action\030\002 \002(\0162#.SessionProtos.Typi" - "ngMessage.Action\"\"\n\006Action\022\013\n\007STARTED\020\000\022" - "\013\n\007STOPPED\020\001\"2\n\rUnsendRequest\022\021\n\ttimesta" - "mp\030\001 \002(\004\022\016\n\006author\030\002 \002(\t\"m\n\026MessageReque" - "stResponse\022\022\n\nisApproved\030\001 \002(\010\022\022\n\nprofil" - "eKey\030\002 \001(\014\022+\n\007profile\030\003 \001(\0132\032.SessionPro" - "tos.LokiProfile\"\236\005\n\007Content\022/\n\013dataMessa" - "ge\030\001 \001(\0132\032.SessionProtos.DataMessage\022/\n\013" - "callMessage\030\003 \001(\0132\032.SessionProtos.CallMe" - "ssage\0225\n\016receiptMessage\030\005 \001(\0132\035.SessionP" - "rotos.ReceiptMessage\0223\n\rtypingMessage\030\006 " - "\001(\0132\034.SessionProtos.TypingMessage\022M\n\032dat" - "aExtractionNotification\030\010 \001(\0132).SessionP" - "rotos.DataExtractionNotification\0223\n\runse" - "ndRequest\030\t \001(\0132\034.SessionProtos.UnsendRe" - "quest\022E\n\026messageRequestResponse\030\n \001(\0132%." - "SessionProtos.MessageRequestResponse\022\?\n\023" - "sharedConfigMessage\030\013 \001(\0132\".SessionProto" - "s.SharedConfigMessage\022=\n\016expirationType\030" - "\014 \001(\0162%.SessionProtos.Content.Expiration" - "Type\022\027\n\017expirationTimer\030\r \001(\r\022\024\n\014sigTime" - "stamp\030\017 \001(\004\"K\n\016ExpirationType\022\013\n\007UNKNOWN" - "\020\000\022\025\n\021DELETE_AFTER_READ\020\001\022\025\n\021DELETE_AFTE" - "R_SEND\020\002\"\352\001\n\013CallMessage\022-\n\004type\030\001 \002(\0162\037" - ".SessionProtos.CallMessage.Type\022\014\n\004sdps\030" - "\002 \003(\t\022\027\n\017sdpMLineIndexes\030\003 \003(\r\022\017\n\007sdpMid" - "s\030\004 \003(\t\022\014\n\004uuid\030\005 \002(\t\"f\n\004Type\022\r\n\tPRE_OFF" - "ER\020\006\022\t\n\005OFFER\020\001\022\n\n\006ANSWER\020\002\022\026\n\022PROVISION" - "AL_ANSWER\020\003\022\022\n\016ICE_CANDIDATES\020\004\022\014\n\010END_C" - "ALL\020\005\"0\n\007KeyPair\022\021\n\tpublicKey\030\001 \002(\014\022\022\n\np" - "rivateKey\030\002 \002(\014\"\226\001\n\032DataExtractionNotifi" - "cation\022<\n\004type\030\001 \002(\0162..SessionProtos.Dat" - "aExtractionNotification.Type\022\021\n\ttimestam" - "p\030\002 \001(\004\"\'\n\004Type\022\016\n\nSCREENSHOT\020\001\022\017\n\013MEDIA" - "_SAVED\020\002\":\n\013LokiProfile\022\023\n\013displayName\030\001" - " \001(\t\022\026\n\016profilePicture\030\002 \001(\t\"\367\010\n\013DataMes" - "sage\022\014\n\004body\030\001 \001(\t\0225\n\013attachments\030\002 \003(\0132" - " .SessionProtos.AttachmentPointer\022\r\n\005fla" - "gs\030\004 \001(\r\022\022\n\nprofileKey\030\006 \001(\014\022\021\n\ttimestam" - "p\030\007 \001(\004\022/\n\005quote\030\010 \001(\0132 .SessionProtos.D" - "ataMessage.Quote\0223\n\007preview\030\n \003(\0132\".Sess" - "ionProtos.DataMessage.Preview\0225\n\010reactio" - "n\030\013 \001(\0132#.SessionProtos.DataMessage.Reac" - "tion\022+\n\007profile\030e \001(\0132\032.SessionProtos.Lo" - "kiProfile\022K\n\023openGroupInvitation\030f \001(\0132." - ".SessionProtos.DataMessage.OpenGroupInvi" - "tation\022\022\n\nsyncTarget\030i \001(\t\022&\n\036blocksComm" - "unityMessageRequests\030j \001(\010\022=\n\022groupUpdat" - "eMessage\030x \001(\0132!.SessionProtos.GroupUpda" - "teMessage\032\225\002\n\005Quote\022\n\n\002id\030\001 \002(\004\022\016\n\006autho" - "r\030\002 \002(\t\022\014\n\004text\030\003 \001(\t\022F\n\013attachments\030\004 \003" - "(\01321.SessionProtos.DataMessage.Quote.Quo" - "tedAttachment\032\231\001\n\020QuotedAttachment\022\023\n\013co" - "ntentType\030\001 \001(\t\022\020\n\010fileName\030\002 \001(\t\0223\n\tthu" - "mbnail\030\003 \001(\0132 .SessionProtos.AttachmentP" - "ointer\022\r\n\005flags\030\004 \001(\r\"\032\n\005Flags\022\021\n\rVOICE_" - "MESSAGE\020\001\032V\n\007Preview\022\013\n\003url\030\001 \002(\t\022\r\n\005tit" - "le\030\002 \001(\t\022/\n\005image\030\003 \001(\0132 .SessionProtos." - "AttachmentPointer\032\222\001\n\010Reaction\022\n\n\002id\030\001 \002" - "(\004\022\016\n\006author\030\002 \002(\t\022\r\n\005emoji\030\003 \001(\t\022:\n\006act" - "ion\030\004 \002(\0162*.SessionProtos.DataMessage.Re" - "action.Action\"\037\n\006Action\022\t\n\005REACT\020\000\022\n\n\006RE" - "MOVE\020\001\0320\n\023OpenGroupInvitation\022\013\n\003url\030\001 \002" - "(\t\022\014\n\004name\030\003 \002(\t\"$\n\005Flags\022\033\n\027EXPIRATION_" - "TIMER_UPDATE\020\002\"u\n\016ReceiptMessage\0220\n\004type" - "\030\001 \002(\0162\".SessionProtos.ReceiptMessage.Ty" - "pe\022\021\n\ttimestamp\030\002 \003(\004\"\036\n\004Type\022\014\n\010DELIVER" - "Y\020\000\022\010\n\004READ\020\001\"\354\001\n\021AttachmentPointer\022\n\n\002i" - "d\030\001 \002(\006\022\023\n\013contentType\030\002 \001(\t\022\013\n\003key\030\003 \001(" - "\014\022\014\n\004size\030\004 \001(\r\022\021\n\tthumbnail\030\005 \001(\014\022\016\n\006di" - "gest\030\006 \001(\014\022\020\n\010fileName\030\007 \001(\t\022\r\n\005flags\030\010 " - "\001(\r\022\r\n\005width\030\t \001(\r\022\016\n\006height\030\n \001(\r\022\017\n\007ca" - "ption\030\013 \001(\t\022\013\n\003url\030e \001(\t\"\032\n\005Flags\022\021\n\rVOI" - "CE_MESSAGE\020\001\"\273\001\n\023SharedConfigMessage\0225\n\004" - "kind\030\001 \002(\0162\'.SessionProtos.SharedConfigM" - "essage.Kind\022\r\n\005seqno\030\002 \002(\003\022\014\n\004data\030\003 \002(\014" - "\"P\n\004Kind\022\020\n\014USER_PROFILE\020\001\022\014\n\010CONTACTS\020\002" - "\022\027\n\023CONVO_INFO_VOLATILE\020\003\022\017\n\013USER_GROUPS" - "\020\004\"\356\004\n\022GroupUpdateMessage\022>\n\rinviteMessa" - "ge\030\001 \001(\0132\'.SessionProtos.GroupUpdateInvi" - "teMessage\022F\n\021infoChangeMessage\030\002 \001(\0132+.S" - "essionProtos.GroupUpdateInfoChangeMessag" - "e\022J\n\023memberChangeMessage\030\003 \001(\0132-.Session" - "Protos.GroupUpdateMemberChangeMessage\022@\n" - "\016promoteMessage\030\004 \001(\0132(.SessionProtos.Gr" - "oupUpdatePromoteMessage\022F\n\021memberLeftMes" - "sage\030\005 \001(\0132+.SessionProtos.GroupUpdateMe" - "mberLeftMessage\022G\n\016inviteResponse\030\006 \001(\0132" - "/.SessionProtos.GroupUpdateInviteRespons" - "eMessage\022Q\n\023deleteMemberContent\030\007 \001(\01324." - "SessionProtos.GroupUpdateDeleteMemberCon" - "tentMessage\022^\n\035memberLeftNotificationMes" - "sage\030\010 \001(\01327.SessionProtos.GroupUpdateMe" - "mberLeftNotificationMessage\"p\n\030GroupUpda" - "teInviteMessage\022\026\n\016groupSessionId\030\001 \002(\t\022" - "\014\n\004name\030\002 \002(\t\022\026\n\016memberAuthData\030\003 \002(\014\022\026\n" - "\016adminSignature\030\004 \002(\014\"D\n\031GroupUpdateProm" - "oteMessage\022\031\n\021groupIdentitySeed\030\001 \002(\014\022\014\n" - "\004name\030\002 \002(\t\"\337\001\n\034GroupUpdateInfoChangeMes" - "sage\022>\n\004type\030\001 \002(\01620.SessionProtos.Group" - "UpdateInfoChangeMessage.Type\022\023\n\013updatedN" - "ame\030\002 \001(\t\022\031\n\021updatedExpiration\030\003 \001(\r\022\026\n\016" - "adminSignature\030\004 \002(\014\"7\n\004Type\022\010\n\004NAME\020\001\022\n" - "\n\006AVATAR\020\002\022\031\n\025DISAPPEARING_MESSAGES\020\003\"\331\001" - "\n\036GroupUpdateMemberChangeMessage\022@\n\004type" - "\030\001 \002(\01622.SessionProtos.GroupUpdateMember" - "ChangeMessage.Type\022\030\n\020memberSessionIds\030\002" - " \003(\t\022\025\n\rhistoryShared\030\003 \001(\010\022\026\n\016adminSign" - "ature\030\004 \002(\014\",\n\004Type\022\t\n\005ADDED\020\001\022\013\n\007REMOVE" - "D\020\002\022\014\n\010PROMOTED\020\003\"\036\n\034GroupUpdateMemberLe" - "ftMessage\"*\n(GroupUpdateMemberLeftNotifi" - "cationMessage\"6\n GroupUpdateInviteRespon" - "seMessage\022\022\n\nisApproved\030\001 \002(\010\"p\n%GroupUp" - "dateDeleteMemberContentMessage\022\030\n\020member" - "SessionIds\030\001 \003(\t\022\025\n\rmessageHashes\030\002 \003(\t\022" - "\026\n\016adminSignature\030\003 \001(\014" + "t\030\010 \001(\014\022\027\n\017serverTimestamp\030\n \001(\004\022\016\n\006proS" + "ig\030\013 \001(\014\"5\n\004Type\022\023\n\017SESSION_MESSAGE\020\006\022\030\n" + "\024CLOSED_GROUP_MESSAGE\020\007\"{\n\rTypingMessage" + "\022\021\n\ttimestamp\030\001 \002(\004\0223\n\006action\030\002 \002(\0162#.Se" + "ssionProtos.TypingMessage.Action\"\"\n\006Acti" + "on\022\013\n\007STARTED\020\000\022\013\n\007STOPPED\020\001\"2\n\rUnsendRe" + "quest\022\021\n\ttimestamp\030\001 \002(\004\022\016\n\006author\030\002 \002(\t" + "\"m\n\026MessageRequestResponse\022\022\n\nisApproved" + "\030\001 \002(\010\022\022\n\nprofileKey\030\002 \001(\014\022+\n\007profile\030\003 " + "\001(\0132\032.SessionProtos.LokiProfile\"\315\005\n\007Cont" + "ent\022/\n\013dataMessage\030\001 \001(\0132\032.SessionProtos" + ".DataMessage\022/\n\013callMessage\030\003 \001(\0132\032.Sess" + "ionProtos.CallMessage\0225\n\016receiptMessage\030" + "\005 \001(\0132\035.SessionProtos.ReceiptMessage\0223\n\r" + "typingMessage\030\006 \001(\0132\034.SessionProtos.Typi" + "ngMessage\022M\n\032dataExtractionNotification\030" + "\010 \001(\0132).SessionProtos.DataExtractionNoti" + "fication\0223\n\runsendRequest\030\t \001(\0132\034.Sessio" + "nProtos.UnsendRequest\022E\n\026messageRequestR" + "esponse\030\n \001(\0132%.SessionProtos.MessageReq" + "uestResponse\022\?\n\023sharedConfigMessage\030\013 \001(" + "\0132\".SessionProtos.SharedConfigMessage\022=\n" + "\016expirationType\030\014 \001(\0162%.SessionProtos.Co" + "ntent.ExpirationType\022\027\n\017expirationTimer\030" + "\r \001(\r\022\024\n\014sigTimestamp\030\017 \001(\004\022-\n\nproMessag" + "e\030\020 \001(\0132\031.SessionProtos.ProMessage\"K\n\016Ex" + "pirationType\022\013\n\007UNKNOWN\020\000\022\025\n\021DELETE_AFTE" + "R_READ\020\001\022\025\n\021DELETE_AFTER_SEND\020\002\"\352\001\n\013Call" + "Message\022-\n\004type\030\001 \002(\0162\037.SessionProtos.Ca" + "llMessage.Type\022\014\n\004sdps\030\002 \003(\t\022\027\n\017sdpMLine" + "Indexes\030\003 \003(\r\022\017\n\007sdpMids\030\004 \003(\t\022\014\n\004uuid\030\005" + " \002(\t\"f\n\004Type\022\r\n\tPRE_OFFER\020\006\022\t\n\005OFFER\020\001\022\n" + "\n\006ANSWER\020\002\022\026\n\022PROVISIONAL_ANSWER\020\003\022\022\n\016IC" + "E_CANDIDATES\020\004\022\014\n\010END_CALL\020\005\"0\n\007KeyPair\022" + "\021\n\tpublicKey\030\001 \002(\014\022\022\n\nprivateKey\030\002 \002(\014\"\226" + "\001\n\032DataExtractionNotification\022<\n\004type\030\001 " + "\002(\0162..SessionProtos.DataExtractionNotifi" + "cation.Type\022\021\n\ttimestamp\030\002 \001(\004\"\'\n\004Type\022\016" + "\n\nSCREENSHOT\020\001\022\017\n\013MEDIA_SAVED\020\002\":\n\013LokiP" + "rofile\022\023\n\013displayName\030\001 \001(\t\022\026\n\016profilePi" + "cture\030\002 \001(\t\"\367\010\n\013DataMessage\022\014\n\004body\030\001 \001(" + "\t\0225\n\013attachments\030\002 \003(\0132 .SessionProtos.A" + "ttachmentPointer\022\r\n\005flags\030\004 \001(\r\022\022\n\nprofi" + "leKey\030\006 \001(\014\022\021\n\ttimestamp\030\007 \001(\004\022/\n\005quote\030" + "\010 \001(\0132 .SessionProtos.DataMessage.Quote\022" + "3\n\007preview\030\n \003(\0132\".SessionProtos.DataMes" + "sage.Preview\0225\n\010reaction\030\013 \001(\0132#.Session" + "Protos.DataMessage.Reaction\022+\n\007profile\030e" + " \001(\0132\032.SessionProtos.LokiProfile\022K\n\023open" + "GroupInvitation\030f \001(\0132..SessionProtos.Da" + "taMessage.OpenGroupInvitation\022\022\n\nsyncTar" + "get\030i \001(\t\022&\n\036blocksCommunityMessageReque" + "sts\030j \001(\010\022=\n\022groupUpdateMessage\030x \001(\0132!." + "SessionProtos.GroupUpdateMessage\032\225\002\n\005Quo" + "te\022\n\n\002id\030\001 \002(\004\022\016\n\006author\030\002 \002(\t\022\014\n\004text\030\003" + " \001(\t\022F\n\013attachments\030\004 \003(\01321.SessionProto" + "s.DataMessage.Quote.QuotedAttachment\032\231\001\n" + "\020QuotedAttachment\022\023\n\013contentType\030\001 \001(\t\022\020" + "\n\010fileName\030\002 \001(\t\0223\n\tthumbnail\030\003 \001(\0132 .Se" + "ssionProtos.AttachmentPointer\022\r\n\005flags\030\004" + " \001(\r\"\032\n\005Flags\022\021\n\rVOICE_MESSAGE\020\001\032V\n\007Prev" + "iew\022\013\n\003url\030\001 \002(\t\022\r\n\005title\030\002 \001(\t\022/\n\005image" + "\030\003 \001(\0132 .SessionProtos.AttachmentPointer" + "\032\222\001\n\010Reaction\022\n\n\002id\030\001 \002(\004\022\016\n\006author\030\002 \002(" + "\t\022\r\n\005emoji\030\003 \001(\t\022:\n\006action\030\004 \002(\0162*.Sessi" + "onProtos.DataMessage.Reaction.Action\"\037\n\006" + "Action\022\t\n\005REACT\020\000\022\n\n\006REMOVE\020\001\0320\n\023OpenGro" + "upInvitation\022\013\n\003url\030\001 \002(\t\022\014\n\004name\030\003 \002(\t\"" + "$\n\005Flags\022\033\n\027EXPIRATION_TIMER_UPDATE\020\002\"u\n" + "\016ReceiptMessage\0220\n\004type\030\001 \002(\0162\".SessionP" + "rotos.ReceiptMessage.Type\022\021\n\ttimestamp\030\002" + " \003(\004\"\036\n\004Type\022\014\n\010DELIVERY\020\000\022\010\n\004READ\020\001\"\354\001\n" + "\021AttachmentPointer\022\n\n\002id\030\001 \002(\006\022\023\n\013conten" + "tType\030\002 \001(\t\022\013\n\003key\030\003 \001(\014\022\014\n\004size\030\004 \001(\r\022\021" + "\n\tthumbnail\030\005 \001(\014\022\016\n\006digest\030\006 \001(\014\022\020\n\010fil" + "eName\030\007 \001(\t\022\r\n\005flags\030\010 \001(\r\022\r\n\005width\030\t \001(" + "\r\022\016\n\006height\030\n \001(\r\022\017\n\007caption\030\013 \001(\t\022\013\n\003ur" + "l\030e \001(\t\"\032\n\005Flags\022\021\n\rVOICE_MESSAGE\020\001\"\273\001\n\023" + "SharedConfigMessage\0225\n\004kind\030\001 \002(\0162\'.Sess" + "ionProtos.SharedConfigMessage.Kind\022\r\n\005se" + "qno\030\002 \002(\003\022\014\n\004data\030\003 \002(\014\"P\n\004Kind\022\020\n\014USER_" + "PROFILE\020\001\022\014\n\010CONTACTS\020\002\022\027\n\023CONVO_INFO_VO" + "LATILE\020\003\022\017\n\013USER_GROUPS\020\004\"\356\004\n\022GroupUpdat" + "eMessage\022>\n\rinviteMessage\030\001 \001(\0132\'.Sessio" + "nProtos.GroupUpdateInviteMessage\022F\n\021info" + "ChangeMessage\030\002 \001(\0132+.SessionProtos.Grou" + "pUpdateInfoChangeMessage\022J\n\023memberChange" + "Message\030\003 \001(\0132-.SessionProtos.GroupUpdat" + "eMemberChangeMessage\022@\n\016promoteMessage\030\004" + " \001(\0132(.SessionProtos.GroupUpdatePromoteM" + "essage\022F\n\021memberLeftMessage\030\005 \001(\0132+.Sess" + "ionProtos.GroupUpdateMemberLeftMessage\022G" + "\n\016inviteResponse\030\006 \001(\0132/.SessionProtos.G" + "roupUpdateInviteResponseMessage\022Q\n\023delet" + "eMemberContent\030\007 \001(\01324.SessionProtos.Gro" + "upUpdateDeleteMemberContentMessage\022^\n\035me" + "mberLeftNotificationMessage\030\010 \001(\01327.Sess" + "ionProtos.GroupUpdateMemberLeftNotificat" + "ionMessage\"p\n\030GroupUpdateInviteMessage\022\026" + "\n\016groupSessionId\030\001 \002(\t\022\014\n\004name\030\002 \002(\t\022\026\n\016" + "memberAuthData\030\003 \002(\014\022\026\n\016adminSignature\030\004" + " \002(\014\"D\n\031GroupUpdatePromoteMessage\022\031\n\021gro" + "upIdentitySeed\030\001 \002(\014\022\014\n\004name\030\002 \002(\t\"\337\001\n\034G" + "roupUpdateInfoChangeMessage\022>\n\004type\030\001 \002(" + "\01620.SessionProtos.GroupUpdateInfoChangeM" + "essage.Type\022\023\n\013updatedName\030\002 \001(\t\022\031\n\021upda" + "tedExpiration\030\003 \001(\r\022\026\n\016adminSignature\030\004 " + "\002(\014\"7\n\004Type\022\010\n\004NAME\020\001\022\n\n\006AVATAR\020\002\022\031\n\025DIS" + "APPEARING_MESSAGES\020\003\"\331\001\n\036GroupUpdateMemb" + "erChangeMessage\022@\n\004type\030\001 \002(\01622.SessionP" + "rotos.GroupUpdateMemberChangeMessage.Typ" + "e\022\030\n\020memberSessionIds\030\002 \003(\t\022\025\n\rhistorySh" + "ared\030\003 \001(\010\022\026\n\016adminSignature\030\004 \002(\014\",\n\004Ty" + "pe\022\t\n\005ADDED\020\001\022\013\n\007REMOVED\020\002\022\014\n\010PROMOTED\020\003" + "\"\036\n\034GroupUpdateMemberLeftMessage\"*\n(Grou" + "pUpdateMemberLeftNotificationMessage\"6\n " + "GroupUpdateInviteResponseMessage\022\022\n\nisAp" + "proved\030\001 \002(\010\"p\n%GroupUpdateDeleteMemberC" + "ontentMessage\022\030\n\020memberSessionIds\030\001 \003(\t\022" + "\025\n\rmessageHashes\030\002 \003(\t\022\026\n\016adminSignature" + "\030\003 \001(\014\"o\n\010ProProof\022\017\n\007version\030\001 \002(\r\022\024\n\014g" + "enIndexHash\030\002 \002(\014\022\031\n\021rotatingPublicKey\030\003" + " \002(\014\022\024\n\014expiryUnixTs\030\004 \002(\004\022\013\n\003sig\030\005 \002(\014\"" + "L\n\tProConfig\022\027\n\017rotatingPrivKey\030\001 \002(\014\022&\n" + "\005proof\030\002 \002(\0132\027.SessionProtos.ProProof\"C\n" + "\nProMessage\022&\n\005proof\030\001 \002(\0132\027.SessionProt" + "os.ProProof\022\r\n\005flags\030\002 \002(\r" ; static ::_pbi::once_flag descriptor_table_SessionProtos_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_SessionProtos_2eproto = { - false, false, 4903, descriptor_table_protodef_SessionProtos_2eproto, + false, false, 5226, descriptor_table_protodef_SessionProtos_2eproto, "SessionProtos.proto", - &descriptor_table_SessionProtos_2eproto_once, nullptr, 0, 27, + &descriptor_table_SessionProtos_2eproto_once, nullptr, 0, 30, schemas, file_default_instances, TableStruct_SessionProtos_2eproto::offsets, file_level_metadata_SessionProtos_2eproto, file_level_enum_descriptors_SessionProtos_2eproto, file_level_service_descriptors_SessionProtos_2eproto, @@ -1354,25 +1458,28 @@ class Envelope::_Internal { public: using HasBits = decltype(std::declval()._impl_._has_bits_); static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 32u; + (*has_bits)[0] |= 64u; } static void set_has_source(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_sourcedevice(HasBits* has_bits) { - (*has_bits)[0] |= 16u; + (*has_bits)[0] |= 32u; } static void set_has_timestamp(HasBits* has_bits) { - (*has_bits)[0] |= 4u; + (*has_bits)[0] |= 8u; } static void set_has_content(HasBits* has_bits) { (*has_bits)[0] |= 2u; } static void set_has_servertimestamp(HasBits* has_bits) { - (*has_bits)[0] |= 8u; + (*has_bits)[0] |= 16u; + } + static void set_has_prosig(HasBits* has_bits) { + (*has_bits)[0] |= 4u; } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000024) ^ 0x00000024) != 0; + return ((has_bits[0] & 0x00000048) ^ 0x00000048) != 0; } }; @@ -1390,6 +1497,7 @@ Envelope::Envelope(const Envelope& from) , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.source_){} , decltype(_impl_.content_){} + , decltype(_impl_.prosig_){} , decltype(_impl_.timestamp_){} , decltype(_impl_.servertimestamp_){} , decltype(_impl_.sourcedevice_){} @@ -1412,6 +1520,14 @@ Envelope::Envelope(const Envelope& from) _this->_impl_.content_.Set(from._internal_content(), _this->GetArenaForAllocation()); } + _impl_.prosig_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.prosig_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_prosig()) { + _this->_impl_.prosig_.Set(from._internal_prosig(), + _this->GetArenaForAllocation()); + } ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, static_cast(reinterpret_cast(&_impl_.type_) - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.type_)); @@ -1427,6 +1543,7 @@ inline void Envelope::SharedCtor( , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.source_){} , decltype(_impl_.content_){} + , decltype(_impl_.prosig_){} , decltype(_impl_.timestamp_){uint64_t{0u}} , decltype(_impl_.servertimestamp_){uint64_t{0u}} , decltype(_impl_.sourcedevice_){0u} @@ -1440,6 +1557,10 @@ inline void Envelope::SharedCtor( #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.content_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.prosig_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.prosig_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Envelope::~Envelope() { @@ -1455,6 +1576,7 @@ inline void Envelope::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); _impl_.source_.Destroy(); _impl_.content_.Destroy(); + _impl_.prosig_.Destroy(); } void Envelope::SetCachedSize(int size) const { @@ -1468,15 +1590,18 @@ void Envelope::Clear() { (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { _impl_.source_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { _impl_.content_.ClearNonDefaultToEmpty(); } + if (cached_has_bits & 0x00000004u) { + _impl_.prosig_.ClearNonDefaultToEmpty(); + } } - if (cached_has_bits & 0x0000003cu) { + if (cached_has_bits & 0x00000078u) { ::memset(&_impl_.timestamp_, 0, static_cast( reinterpret_cast(&_impl_.sourcedevice_) - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.sourcedevice_)); @@ -1554,6 +1679,15 @@ const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; + // optional bytes proSig = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { + auto str = _internal_mutable_prosig(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -1586,7 +1720,7 @@ uint8_t* Envelope::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // required .SessionProtos.Envelope.Type type = 1; - if (cached_has_bits & 0x00000020u) { + if (cached_has_bits & 0x00000040u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( 1, this->_internal_type(), target); @@ -1603,13 +1737,13 @@ uint8_t* Envelope::_InternalSerialize( } // required uint64 timestamp = 5; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt64ToArray(5, this->_internal_timestamp(), target); } // optional uint32 sourceDevice = 7; - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000020u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(7, this->_internal_sourcedevice(), target); } @@ -1621,11 +1755,17 @@ uint8_t* Envelope::_InternalSerialize( } // optional uint64 serverTimestamp = 10; - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000010u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt64ToArray(10, this->_internal_servertimestamp(), target); } + // optional bytes proSig = 11; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 11, this->_internal_prosig(), target); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -1655,7 +1795,7 @@ size_t Envelope::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:SessionProtos.Envelope) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000024) ^ 0x00000024) == 0) { // All required fields are present. + if (((_impl_._has_bits_[0] & 0x00000048) ^ 0x00000048) == 0) { // All required fields are present. // required uint64 timestamp = 5; total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); @@ -1671,7 +1811,7 @@ size_t Envelope::ByteSizeLong() const { (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000007u) { // optional string source = 2; if (cached_has_bits & 0x00000001u) { total_size += 1 + @@ -1686,15 +1826,22 @@ size_t Envelope::ByteSizeLong() const { this->_internal_content()); } + // optional bytes proSig = 11; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_prosig()); + } + } - if (cached_has_bits & 0x00000018u) { + if (cached_has_bits & 0x00000030u) { // optional uint64 serverTimestamp = 10; - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000010u) { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_servertimestamp()); } // optional uint32 sourceDevice = 7; - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000020u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_sourcedevice()); } @@ -1718,7 +1865,7 @@ void Envelope::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTO (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000003fu) { + if (cached_has_bits & 0x0000007fu) { if (cached_has_bits & 0x00000001u) { _this->_internal_set_source(from._internal_source()); } @@ -1726,15 +1873,18 @@ void Envelope::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTO _this->_internal_set_content(from._internal_content()); } if (cached_has_bits & 0x00000004u) { - _this->_impl_.timestamp_ = from._impl_.timestamp_; + _this->_internal_set_prosig(from._internal_prosig()); } if (cached_has_bits & 0x00000008u) { - _this->_impl_.servertimestamp_ = from._impl_.servertimestamp_; + _this->_impl_.timestamp_ = from._impl_.timestamp_; } if (cached_has_bits & 0x00000010u) { - _this->_impl_.sourcedevice_ = from._impl_.sourcedevice_; + _this->_impl_.servertimestamp_ = from._impl_.servertimestamp_; } if (cached_has_bits & 0x00000020u) { + _this->_impl_.sourcedevice_ = from._impl_.sourcedevice_; + } + if (cached_has_bits & 0x00000040u) { _this->_impl_.type_ = from._impl_.type_; } _this->_impl_._has_bits_[0] |= cached_has_bits; @@ -1768,6 +1918,10 @@ void Envelope::InternalSwap(Envelope* other) { &_impl_.content_, lhs_arena, &other->_impl_.content_, rhs_arena ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.prosig_, lhs_arena, + &other->_impl_.prosig_, rhs_arena + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Envelope, _impl_.sourcedevice_) + sizeof(Envelope::_impl_.sourcedevice_) @@ -2662,13 +2816,17 @@ class Content::_Internal { (*has_bits)[0] |= 128u; } static void set_has_expirationtype(HasBits* has_bits) { - (*has_bits)[0] |= 256u; + (*has_bits)[0] |= 512u; } static void set_has_expirationtimer(HasBits* has_bits) { - (*has_bits)[0] |= 512u; + (*has_bits)[0] |= 1024u; } static void set_has_sigtimestamp(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; + (*has_bits)[0] |= 2048u; + } + static const ::SessionProtos::ProMessage& promessage(const Content* msg); + static void set_has_promessage(HasBits* has_bits) { + (*has_bits)[0] |= 256u; } }; @@ -2704,6 +2862,10 @@ const ::SessionProtos::SharedConfigMessage& Content::_Internal::sharedconfigmessage(const Content* msg) { return *msg->_impl_.sharedconfigmessage_; } +const ::SessionProtos::ProMessage& +Content::_Internal::promessage(const Content* msg) { + return *msg->_impl_.promessage_; +} Content::Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { @@ -2724,6 +2886,7 @@ Content::Content(const Content& from) , decltype(_impl_.unsendrequest_){nullptr} , decltype(_impl_.messagerequestresponse_){nullptr} , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.promessage_){nullptr} , decltype(_impl_.expirationtype_){} , decltype(_impl_.expirationtimer_){} , decltype(_impl_.sigtimestamp_){}}; @@ -2753,6 +2916,9 @@ Content::Content(const Content& from) if (from._internal_has_sharedconfigmessage()) { _this->_impl_.sharedconfigmessage_ = new ::SessionProtos::SharedConfigMessage(*from._impl_.sharedconfigmessage_); } + if (from._internal_has_promessage()) { + _this->_impl_.promessage_ = new ::SessionProtos::ProMessage(*from._impl_.promessage_); + } ::memcpy(&_impl_.expirationtype_, &from._impl_.expirationtype_, static_cast(reinterpret_cast(&_impl_.sigtimestamp_) - reinterpret_cast(&_impl_.expirationtype_)) + sizeof(_impl_.sigtimestamp_)); @@ -2774,6 +2940,7 @@ inline void Content::SharedCtor( , decltype(_impl_.unsendrequest_){nullptr} , decltype(_impl_.messagerequestresponse_){nullptr} , decltype(_impl_.sharedconfigmessage_){nullptr} + , decltype(_impl_.promessage_){nullptr} , decltype(_impl_.expirationtype_){0} , decltype(_impl_.expirationtimer_){0u} , decltype(_impl_.sigtimestamp_){uint64_t{0u}} @@ -2799,6 +2966,7 @@ inline void Content::SharedDtor() { if (this != internal_default_instance()) delete _impl_.unsendrequest_; if (this != internal_default_instance()) delete _impl_.messagerequestresponse_; if (this != internal_default_instance()) delete _impl_.sharedconfigmessage_; + if (this != internal_default_instance()) delete _impl_.promessage_; } void Content::SetCachedSize(int size) const { @@ -2846,7 +3014,11 @@ void Content::Clear() { _impl_.sharedconfigmessage_->Clear(); } } - if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000100u) { + GOOGLE_DCHECK(_impl_.promessage_ != nullptr); + _impl_.promessage_->Clear(); + } + if (cached_has_bits & 0x00000e00u) { ::memset(&_impl_.expirationtype_, 0, static_cast( reinterpret_cast(&_impl_.sigtimestamp_) - reinterpret_cast(&_impl_.expirationtype_)) + sizeof(_impl_.sigtimestamp_)); @@ -2957,6 +3129,14 @@ const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; + // optional .SessionProtos.ProMessage proMessage = 16; + case 16: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 130)) { + ptr = ctx->ParseMessage(_internal_mutable_promessage(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -3045,24 +3225,31 @@ uint8_t* Content::_InternalSerialize( } // optional .SessionProtos.Content.ExpirationType expirationType = 12; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( 12, this->_internal_expirationtype(), target); } // optional uint32 expirationTimer = 13; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(13, this->_internal_expirationtimer(), target); } // optional uint64 sigTimestamp = 15; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt64ToArray(15, this->_internal_sigtimestamp(), target); } + // optional .SessionProtos.ProMessage proMessage = 16; + if (cached_has_bits & 0x00000100u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(16, _Internal::promessage(this), + _Internal::promessage(this).GetCachedSize(), target, stream); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -3138,20 +3325,27 @@ size_t Content::ByteSizeLong() const { } } - if (cached_has_bits & 0x00000700u) { - // optional .SessionProtos.Content.ExpirationType expirationType = 12; + if (cached_has_bits & 0x00000f00u) { + // optional .SessionProtos.ProMessage proMessage = 16; if (cached_has_bits & 0x00000100u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.promessage_); + } + + // optional .SessionProtos.Content.ExpirationType expirationType = 12; + if (cached_has_bits & 0x00000200u) { total_size += 1 + ::_pbi::WireFormatLite::EnumSize(this->_internal_expirationtype()); } // optional uint32 expirationTimer = 13; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); } // optional uint64 sigTimestamp = 15; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_sigtimestamp()); } @@ -3209,14 +3403,18 @@ void Content::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB from._internal_sharedconfigmessage()); } } - if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000f00u) { if (cached_has_bits & 0x00000100u) { - _this->_impl_.expirationtype_ = from._impl_.expirationtype_; + _this->_internal_mutable_promessage()->::SessionProtos::ProMessage::MergeFrom( + from._internal_promessage()); } if (cached_has_bits & 0x00000200u) { - _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; + _this->_impl_.expirationtype_ = from._impl_.expirationtype_; } if (cached_has_bits & 0x00000400u) { + _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; + } + if (cached_has_bits & 0x00000800u) { _this->_impl_.sigtimestamp_ = from._impl_.sigtimestamp_; } _this->_impl_._has_bits_[0] |= cached_has_bits; @@ -3256,6 +3454,9 @@ bool Content::IsInitialized() const { if (_internal_has_sharedconfigmessage()) { if (!_impl_.sharedconfigmessage_->IsInitialized()) return false; } + if (_internal_has_promessage()) { + if (!_impl_.promessage_->IsInitialized()) return false; + } return true; } @@ -10806,42 +11007,1023 @@ ::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateDeleteMemberContentMessage::GetMeta file_level_metadata_SessionProtos_2eproto[26]); } -// @@protoc_insertion_point(namespace_scope) -} // namespace SessionProtos -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::SessionProtos::Envelope* -Arena::CreateMaybeMessage< ::SessionProtos::Envelope >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::Envelope >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::TypingMessage* -Arena::CreateMaybeMessage< ::SessionProtos::TypingMessage >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::TypingMessage >(arena); -} -template<> PROTOBUF_NOINLINE ::SessionProtos::UnsendRequest* -Arena::CreateMaybeMessage< ::SessionProtos::UnsendRequest >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::UnsendRequest >(arena); +// =================================================================== + +class ProProof::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_version(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_genindexhash(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_rotatingpublickey(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_expiryunixts(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_sig(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000001f) ^ 0x0000001f) != 0; + } +}; + +ProProof::ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.ProProof) } -template<> PROTOBUF_NOINLINE ::SessionProtos::MessageRequestResponse* -Arena::CreateMaybeMessage< ::SessionProtos::MessageRequestResponse >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::MessageRequestResponse >(arena); +ProProof::ProProof(const ProProof& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + ProProof* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.genindexhash_){} + , decltype(_impl_.rotatingpublickey_){} + , decltype(_impl_.sig_){} + , decltype(_impl_.expiryunixts_){} + , decltype(_impl_.version_){}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.genindexhash_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_genindexhash()) { + _this->_impl_.genindexhash_.Set(from._internal_genindexhash(), + _this->GetArenaForAllocation()); + } + _impl_.rotatingpublickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_rotatingpublickey()) { + _this->_impl_.rotatingpublickey_.Set(from._internal_rotatingpublickey(), + _this->GetArenaForAllocation()); + } + _impl_.sig_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.sig_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_sig()) { + _this->_impl_.sig_.Set(from._internal_sig(), + _this->GetArenaForAllocation()); + } + ::memcpy(&_impl_.expiryunixts_, &from._impl_.expiryunixts_, + static_cast(reinterpret_cast(&_impl_.version_) - + reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); + // @@protoc_insertion_point(copy_constructor:SessionProtos.ProProof) } -template<> PROTOBUF_NOINLINE ::SessionProtos::Content* -Arena::CreateMaybeMessage< ::SessionProtos::Content >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::Content >(arena); + +inline void ProProof::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.genindexhash_){} + , decltype(_impl_.rotatingpublickey_){} + , decltype(_impl_.sig_){} + , decltype(_impl_.expiryunixts_){uint64_t{0u}} + , decltype(_impl_.version_){0u} + }; + _impl_.genindexhash_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingpublickey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.sig_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.sig_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } -template<> PROTOBUF_NOINLINE ::SessionProtos::CallMessage* -Arena::CreateMaybeMessage< ::SessionProtos::CallMessage >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::CallMessage >(arena); + +ProProof::~ProProof() { + // @@protoc_insertion_point(destructor:SessionProtos.ProProof) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); } -template<> PROTOBUF_NOINLINE ::SessionProtos::KeyPair* -Arena::CreateMaybeMessage< ::SessionProtos::KeyPair >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::KeyPair >(arena); + +inline void ProProof::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.genindexhash_.Destroy(); + _impl_.rotatingpublickey_.Destroy(); + _impl_.sig_.Destroy(); } -template<> PROTOBUF_NOINLINE ::SessionProtos::DataExtractionNotification* -Arena::CreateMaybeMessage< ::SessionProtos::DataExtractionNotification >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::DataExtractionNotification >(arena); + +void ProProof::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); } -template<> PROTOBUF_NOINLINE ::SessionProtos::LokiProfile* + +void ProProof::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ProProof) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + _impl_.genindexhash_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.rotatingpublickey_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + _impl_.sig_.ClearNonDefaultToEmpty(); + } + } + if (cached_has_bits & 0x00000018u) { + ::memset(&_impl_.expiryunixts_, 0, static_cast( + reinterpret_cast(&_impl_.version_) - + reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required uint32 version = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _Internal::set_has_version(&has_bits); + _impl_.version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bytes genIndexHash = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_genindexhash(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bytes rotatingPublicKey = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_rotatingpublickey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required uint64 expiryUnixTs = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _Internal::set_has_expiryunixts(&has_bits); + _impl_.expiryunixts_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bytes sig = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + auto str = _internal_mutable_sig(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* ProProof::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProProof) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // required uint32 version = 1; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_version(), target); + } + + // required bytes genIndexHash = 2; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_genindexhash(), target); + } + + // required bytes rotatingPublicKey = 3; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_rotatingpublickey(), target); + } + + // required uint64 expiryUnixTs = 4; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_expiryunixts(), target); + } + + // required bytes sig = 5; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 5, this->_internal_sig(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProProof) + return target; +} + +size_t ProProof::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProProof) + size_t total_size = 0; + + if (_internal_has_genindexhash()) { + // required bytes genIndexHash = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); + } + + if (_internal_has_rotatingpublickey()) { + // required bytes rotatingPublicKey = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); + } + + if (_internal_has_sig()) { + // required bytes sig = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); + } + + if (_internal_has_expiryunixts()) { + // required uint64 expiryUnixTs = 4; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + } + + if (_internal_has_version()) { + // required uint32 version = 1; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + } + + return total_size; +} +size_t ProProof::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProProof) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x0000001f) ^ 0x0000001f) == 0) { // All required fields are present. + // required bytes genIndexHash = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); + + // required bytes rotatingPublicKey = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); + + // required bytes sig = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); + + // required uint64 expiryUnixTs = 4; + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + + // required uint32 version = 1; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ProProof::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + ProProof::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ProProof::GetClassData() const { return &_class_data_; } + + +void ProProof::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProProof) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_genindexhash(from._internal_genindexhash()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_rotatingpublickey(from._internal_rotatingpublickey()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_sig(from._internal_sig()); + } + if (cached_has_bits & 0x00000008u) { + _this->_impl_.expiryunixts_ = from._impl_.expiryunixts_; + } + if (cached_has_bits & 0x00000010u) { + _this->_impl_.version_ = from._impl_.version_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void ProProof::CopyFrom(const ProProof& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProProof) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ProProof::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + return true; +} + +void ProProof::InternalSwap(ProProof* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.genindexhash_, lhs_arena, + &other->_impl_.genindexhash_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.rotatingpublickey_, lhs_arena, + &other->_impl_.rotatingpublickey_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.sig_, lhs_arena, + &other->_impl_.sig_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ProProof, _impl_.version_) + + sizeof(ProProof::_impl_.version_) + - PROTOBUF_FIELD_OFFSET(ProProof, _impl_.expiryunixts_)>( + reinterpret_cast(&_impl_.expiryunixts_), + reinterpret_cast(&other->_impl_.expiryunixts_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ProProof::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[27]); +} + +// =================================================================== + +class ProConfig::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static void set_has_rotatingprivkey(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::SessionProtos::ProProof& proof(const ProConfig* msg); + static void set_has_proof(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +const ::SessionProtos::ProProof& +ProConfig::_Internal::proof(const ProConfig* msg) { + return *msg->_impl_.proof_; +} +ProConfig::ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.ProConfig) +} +ProConfig::ProConfig(const ProConfig& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + ProConfig* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.rotatingprivkey_){} + , decltype(_impl_.proof_){nullptr}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.rotatingprivkey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_rotatingprivkey()) { + _this->_impl_.rotatingprivkey_.Set(from._internal_rotatingprivkey(), + _this->GetArenaForAllocation()); + } + if (from._internal_has_proof()) { + _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); + } + // @@protoc_insertion_point(copy_constructor:SessionProtos.ProConfig) +} + +inline void ProConfig::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.rotatingprivkey_){} + , decltype(_impl_.proof_){nullptr} + }; + _impl_.rotatingprivkey_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +ProConfig::~ProConfig() { + // @@protoc_insertion_point(destructor:SessionProtos.ProConfig) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void ProConfig::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.rotatingprivkey_.Destroy(); + if (this != internal_default_instance()) delete _impl_.proof_; +} + +void ProConfig::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void ProConfig::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ProConfig) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _impl_.rotatingprivkey_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(_impl_.proof_ != nullptr); + _impl_.proof_->Clear(); + } + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ProConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required bytes rotatingPrivKey = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_rotatingprivkey(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required .SessionProtos.ProProof proof = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* ProConfig::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProConfig) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // required bytes rotatingPrivKey = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteBytesMaybeAliased( + 1, this->_internal_rotatingprivkey(), target); + } + + // required .SessionProtos.ProProof proof = 2; + if (cached_has_bits & 0x00000002u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, _Internal::proof(this), + _Internal::proof(this).GetCachedSize(), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProConfig) + return target; +} + +size_t ProConfig::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProConfig) + size_t total_size = 0; + + if (_internal_has_rotatingprivkey()) { + // required bytes rotatingPrivKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingprivkey()); + } + + if (_internal_has_proof()) { + // required .SessionProtos.ProProof proof = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); + } + + return total_size; +} +size_t ProConfig::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProConfig) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required bytes rotatingPrivKey = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingprivkey()); + + // required .SessionProtos.ProProof proof = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ProConfig::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + ProConfig::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ProConfig::GetClassData() const { return &_class_data_; } + + +void ProConfig::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProConfig) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_rotatingprivkey(from._internal_rotatingprivkey()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( + from._internal_proof()); + } + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void ProConfig::CopyFrom(const ProConfig& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProConfig) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ProConfig::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (_internal_has_proof()) { + if (!_impl_.proof_->IsInitialized()) return false; + } + return true; +} + +void ProConfig::InternalSwap(ProConfig* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.rotatingprivkey_, lhs_arena, + &other->_impl_.rotatingprivkey_, rhs_arena + ); + swap(_impl_.proof_, other->_impl_.proof_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ProConfig::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[28]); +} + +// =================================================================== + +class ProMessage::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static const ::SessionProtos::ProProof& proof(const ProMessage* msg); + static void set_has_proof(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_flags(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +const ::SessionProtos::ProProof& +ProMessage::_Internal::proof(const ProMessage* msg) { + return *msg->_impl_.proof_; +} +ProMessage::ProMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:SessionProtos.ProMessage) +} +ProMessage::ProMessage(const ProMessage& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + ProMessage* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.proof_){nullptr} + , decltype(_impl_.flags_){}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_proof()) { + _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); + } + _this->_impl_.flags_ = from._impl_.flags_; + // @@protoc_insertion_point(copy_constructor:SessionProtos.ProMessage) +} + +inline void ProMessage::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.proof_){nullptr} + , decltype(_impl_.flags_){0u} + }; +} + +ProMessage::~ProMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.ProMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void ProMessage::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + if (this != internal_default_instance()) delete _impl_.proof_; +} + +void ProMessage::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void ProMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.ProMessage) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(_impl_.proof_ != nullptr); + _impl_.proof_->Clear(); + } + _impl_.flags_ = 0u; + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ProMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required .SessionProtos.ProProof proof = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required uint32 flags = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_flags(&has_bits); + _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* ProMessage::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProMessage) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // required .SessionProtos.ProProof proof = 1; + if (cached_has_bits & 0x00000001u) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::proof(this), + _Internal::proof(this).GetCachedSize(), target, stream); + } + + // required uint32 flags = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_flags(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProMessage) + return target; +} + +size_t ProMessage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProMessage) + size_t total_size = 0; + + if (_internal_has_proof()) { + // required .SessionProtos.ProProof proof = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); + } + + if (_internal_has_flags()) { + // required uint32 flags = 2; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + + return total_size; +} +size_t ProMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProMessage) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required .SessionProtos.ProProof proof = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); + + // required uint32 flags = 2; + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ProMessage::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + ProMessage::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ProMessage::GetClassData() const { return &_class_data_; } + + +void ProMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProMessage) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( + from._internal_proof()); + } + if (cached_has_bits & 0x00000002u) { + _this->_impl_.flags_ = from._impl_.flags_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void ProMessage::CopyFrom(const ProMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ProMessage::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + if (_internal_has_proof()) { + if (!_impl_.proof_->IsInitialized()) return false; + } + return true; +} + +void ProMessage::InternalSwap(ProMessage* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ProMessage, _impl_.flags_) + + sizeof(ProMessage::_impl_.flags_) + - PROTOBUF_FIELD_OFFSET(ProMessage, _impl_.proof_)>( + reinterpret_cast(&_impl_.proof_), + reinterpret_cast(&other->_impl_.proof_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ProMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, + file_level_metadata_SessionProtos_2eproto[29]); +} + +// @@protoc_insertion_point(namespace_scope) +} // namespace SessionProtos +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::SessionProtos::Envelope* +Arena::CreateMaybeMessage< ::SessionProtos::Envelope >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::Envelope >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::TypingMessage* +Arena::CreateMaybeMessage< ::SessionProtos::TypingMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::TypingMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::UnsendRequest* +Arena::CreateMaybeMessage< ::SessionProtos::UnsendRequest >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::UnsendRequest >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::MessageRequestResponse* +Arena::CreateMaybeMessage< ::SessionProtos::MessageRequestResponse >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::MessageRequestResponse >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::Content* +Arena::CreateMaybeMessage< ::SessionProtos::Content >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::Content >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::CallMessage* +Arena::CreateMaybeMessage< ::SessionProtos::CallMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::CallMessage >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::KeyPair* +Arena::CreateMaybeMessage< ::SessionProtos::KeyPair >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::KeyPair >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::DataExtractionNotification* +Arena::CreateMaybeMessage< ::SessionProtos::DataExtractionNotification >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::DataExtractionNotification >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::LokiProfile* Arena::CreateMaybeMessage< ::SessionProtos::LokiProfile >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::LokiProfile >(arena); } @@ -10917,6 +12099,18 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::GroupUpdateDeleteMemberContentMess Arena::CreateMaybeMessage< ::SessionProtos::GroupUpdateDeleteMemberContentMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::GroupUpdateDeleteMemberContentMessage >(arena); } +template<> PROTOBUF_NOINLINE ::SessionProtos::ProProof* +Arena::CreateMaybeMessage< ::SessionProtos::ProProof >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ProProof >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::ProConfig* +Arena::CreateMaybeMessage< ::SessionProtos::ProConfig >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ProConfig >(arena); +} +template<> PROTOBUF_NOINLINE ::SessionProtos::ProMessage* +Arena::CreateMaybeMessage< ::SessionProtos::ProMessage >(Arena* arena) { + return Arena::CreateMessageInternal< ::SessionProtos::ProMessage >(arena); +} PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index faea8749..c73bb3d0 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -116,6 +116,15 @@ extern LokiProfileDefaultTypeInternal _LokiProfile_default_instance_; class MessageRequestResponse; struct MessageRequestResponseDefaultTypeInternal; extern MessageRequestResponseDefaultTypeInternal _MessageRequestResponse_default_instance_; +class ProConfig; +struct ProConfigDefaultTypeInternal; +extern ProConfigDefaultTypeInternal _ProConfig_default_instance_; +class ProMessage; +struct ProMessageDefaultTypeInternal; +extern ProMessageDefaultTypeInternal _ProMessage_default_instance_; +class ProProof; +struct ProProofDefaultTypeInternal; +extern ProProofDefaultTypeInternal _ProProof_default_instance_; class ReceiptMessage; struct ReceiptMessageDefaultTypeInternal; extern ReceiptMessageDefaultTypeInternal _ReceiptMessage_default_instance_; @@ -153,6 +162,9 @@ template<> ::SessionProtos::GroupUpdatePromoteMessage* Arena::CreateMaybeMessage template<> ::SessionProtos::KeyPair* Arena::CreateMaybeMessage<::SessionProtos::KeyPair>(Arena*); template<> ::SessionProtos::LokiProfile* Arena::CreateMaybeMessage<::SessionProtos::LokiProfile>(Arena*); template<> ::SessionProtos::MessageRequestResponse* Arena::CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(Arena*); +template<> ::SessionProtos::ProConfig* Arena::CreateMaybeMessage<::SessionProtos::ProConfig>(Arena*); +template<> ::SessionProtos::ProMessage* Arena::CreateMaybeMessage<::SessionProtos::ProMessage>(Arena*); +template<> ::SessionProtos::ProProof* Arena::CreateMaybeMessage<::SessionProtos::ProProof>(Arena*); template<> ::SessionProtos::ReceiptMessage* Arena::CreateMaybeMessage<::SessionProtos::ReceiptMessage>(Arena*); template<> ::SessionProtos::SharedConfigMessage* Arena::CreateMaybeMessage<::SessionProtos::SharedConfigMessage>(Arena*); template<> ::SessionProtos::TypingMessage* Arena::CreateMaybeMessage<::SessionProtos::TypingMessage>(Arena*); @@ -627,6 +639,7 @@ class Envelope final : enum : int { kSourceFieldNumber = 2, kContentFieldNumber = 8, + kProSigFieldNumber = 11, kTimestampFieldNumber = 5, kServerTimestampFieldNumber = 10, kSourceDeviceFieldNumber = 7, @@ -668,6 +681,24 @@ class Envelope final : std::string* _internal_mutable_content(); public: + // optional bytes proSig = 11; + bool has_prosig() const; + private: + bool _internal_has_prosig() const; + public: + void clear_prosig(); + const std::string& prosig() const; + template + void set_prosig(ArgT0&& arg0, ArgT... args); + std::string* mutable_prosig(); + PROTOBUF_NODISCARD std::string* release_prosig(); + void set_allocated_prosig(std::string* prosig); + private: + const std::string& _internal_prosig() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_prosig(const std::string& value); + std::string* _internal_mutable_prosig(); + public: + // required uint64 timestamp = 5; bool has_timestamp() const; private: @@ -735,6 +766,7 @@ class Envelope final : mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr source_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr prosig_; uint64_t timestamp_; uint64_t servertimestamp_; uint32_t sourcedevice_; @@ -1504,6 +1536,7 @@ class Content final : kUnsendRequestFieldNumber = 9, kMessageRequestResponseFieldNumber = 10, kSharedConfigMessageFieldNumber = 11, + kProMessageFieldNumber = 16, kExpirationTypeFieldNumber = 12, kExpirationTimerFieldNumber = 13, kSigTimestampFieldNumber = 15, @@ -1652,6 +1685,24 @@ class Content final : ::SessionProtos::SharedConfigMessage* sharedconfigmessage); ::SessionProtos::SharedConfigMessage* unsafe_arena_release_sharedconfigmessage(); + // optional .SessionProtos.ProMessage proMessage = 16; + bool has_promessage() const; + private: + bool _internal_has_promessage() const; + public: + void clear_promessage(); + const ::SessionProtos::ProMessage& promessage() const; + PROTOBUF_NODISCARD ::SessionProtos::ProMessage* release_promessage(); + ::SessionProtos::ProMessage* mutable_promessage(); + void set_allocated_promessage(::SessionProtos::ProMessage* promessage); + private: + const ::SessionProtos::ProMessage& _internal_promessage() const; + ::SessionProtos::ProMessage* _internal_mutable_promessage(); + public: + void unsafe_arena_set_allocated_promessage( + ::SessionProtos::ProMessage* promessage); + ::SessionProtos::ProMessage* unsafe_arena_release_promessage(); + // optional .SessionProtos.Content.ExpirationType expirationType = 12; bool has_expirationtype() const; private: @@ -1709,6 +1760,7 @@ class Content final : ::SessionProtos::UnsendRequest* unsendrequest_; ::SessionProtos::MessageRequestResponse* messagerequestresponse_; ::SessionProtos::SharedConfigMessage* sharedconfigmessage_; + ::SessionProtos::ProMessage* promessage_; int expirationtype_; uint32_t expirationtimer_; uint64_t sigtimestamp_; @@ -6816,233 +6868,842 @@ class GroupUpdateDeleteMemberContentMessage final : union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; -// =================================================================== - - -// =================================================================== +// ------------------------------------------------------------------- -#ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// Envelope +class ProProof final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ProProof) */ { + public: + inline ProProof() : ProProof(nullptr) {} + ~ProProof() override; + explicit PROTOBUF_CONSTEXPR ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); -// required .SessionProtos.Envelope.Type type = 1; -inline bool Envelope::_internal_has_type() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; - return value; -} -inline bool Envelope::has_type() const { - return _internal_has_type(); -} -inline void Envelope::clear_type() { - _impl_.type_ = 6; - _impl_._has_bits_[0] &= ~0x00000020u; -} -inline ::SessionProtos::Envelope_Type Envelope::_internal_type() const { - return static_cast< ::SessionProtos::Envelope_Type >(_impl_.type_); -} -inline ::SessionProtos::Envelope_Type Envelope::type() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.type) - return _internal_type(); -} -inline void Envelope::_internal_set_type(::SessionProtos::Envelope_Type value) { - assert(::SessionProtos::Envelope_Type_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.type_ = value; -} -inline void Envelope::set_type(::SessionProtos::Envelope_Type value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.type) -} + ProProof(const ProProof& from); + ProProof(ProProof&& from) noexcept + : ProProof() { + *this = ::std::move(from); + } -// optional string source = 2; -inline bool Envelope::_internal_has_source() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool Envelope::has_source() const { - return _internal_has_source(); -} -inline void Envelope::clear_source() { - _impl_.source_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& Envelope::source() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.source) - return _internal_source(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Envelope::set_source(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.source_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.source) -} -inline std::string* Envelope::mutable_source() { - std::string* _s = _internal_mutable_source(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.source) - return _s; -} -inline const std::string& Envelope::_internal_source() const { - return _impl_.source_.Get(); -} -inline void Envelope::_internal_set_source(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.source_.Set(value, GetArenaForAllocation()); -} -inline std::string* Envelope::_internal_mutable_source() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.source_.Mutable(GetArenaForAllocation()); -} -inline std::string* Envelope::release_source() { - // @@protoc_insertion_point(field_release:SessionProtos.Envelope.source) - if (!_internal_has_source()) { - return nullptr; + inline ProProof& operator=(const ProProof& from) { + CopyFrom(from); + return *this; } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.source_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.source_.IsDefault()) { - _impl_.source_.Set("", GetArenaForAllocation()); + inline ProProof& operator=(ProProof&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void Envelope::set_allocated_source(std::string* source) { - if (source != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); } - _impl_.source_.SetAllocated(source, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.source_.IsDefault()) { - _impl_.source_.Set("", GetArenaForAllocation()); + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.source) -} - -// optional uint32 sourceDevice = 7; -inline bool Envelope::_internal_has_sourcedevice() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; - return value; -} -inline bool Envelope::has_sourcedevice() const { - return _internal_has_sourcedevice(); -} -inline void Envelope::clear_sourcedevice() { - _impl_.sourcedevice_ = 0u; - _impl_._has_bits_[0] &= ~0x00000010u; -} -inline uint32_t Envelope::_internal_sourcedevice() const { - return _impl_.sourcedevice_; -} -inline uint32_t Envelope::sourcedevice() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.sourceDevice) - return _internal_sourcedevice(); -} -inline void Envelope::_internal_set_sourcedevice(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000010u; - _impl_.sourcedevice_ = value; -} -inline void Envelope::set_sourcedevice(uint32_t value) { - _internal_set_sourcedevice(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.sourceDevice) -} - -// required uint64 timestamp = 5; -inline bool Envelope::_internal_has_timestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool Envelope::has_timestamp() const { - return _internal_has_timestamp(); -} -inline void Envelope::clear_timestamp() { - _impl_.timestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline uint64_t Envelope::_internal_timestamp() const { - return _impl_.timestamp_; -} -inline uint64_t Envelope::timestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.timestamp) - return _internal_timestamp(); -} -inline void Envelope::_internal_set_timestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.timestamp_ = value; -} -inline void Envelope::set_timestamp(uint64_t value) { - _internal_set_timestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.timestamp) -} -// optional bytes content = 8; -inline bool Envelope::_internal_has_content() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool Envelope::has_content() const { - return _internal_has_content(); -} -inline void Envelope::clear_content() { - _impl_.content_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const std::string& Envelope::content() const { - // @@protoc_insertion_point(field_get:SessionProtos.Envelope.content) - return _internal_content(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Envelope::set_content(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.content_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.Envelope.content) -} -inline std::string* Envelope::mutable_content() { - std::string* _s = _internal_mutable_content(); - // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.content) - return _s; -} -inline const std::string& Envelope::_internal_content() const { - return _impl_.content_.Get(); -} -inline void Envelope::_internal_set_content(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.content_.Set(value, GetArenaForAllocation()); -} -inline std::string* Envelope::_internal_mutable_content() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.content_.Mutable(GetArenaForAllocation()); -} -inline std::string* Envelope::release_content() { - // @@protoc_insertion_point(field_release:SessionProtos.Envelope.content) - if (!_internal_has_content()) { - return nullptr; + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.content_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void Envelope::set_allocated_content(std::string* content) { - if (content != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; } - _impl_.content_.SetAllocated(content, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); + static const ProProof& default_instance() { + return *internal_default_instance(); + } + static inline const ProProof* internal_default_instance() { + return reinterpret_cast( + &_ProProof_default_instance_); + } + static constexpr int kIndexInFileMessages = + 27; + + friend void swap(ProProof& a, ProProof& b) { + a.Swap(&b); + } + inline void Swap(ProProof* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ProProof* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const ProProof& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const ProProof& from) { + ProProof::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ProProof* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.ProProof"; + } + protected: + explicit ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kGenIndexHashFieldNumber = 2, + kRotatingPublicKeyFieldNumber = 3, + kSigFieldNumber = 5, + kExpiryUnixTsFieldNumber = 4, + kVersionFieldNumber = 1, + }; + // required bytes genIndexHash = 2; + bool has_genindexhash() const; + private: + bool _internal_has_genindexhash() const; + public: + void clear_genindexhash(); + const std::string& genindexhash() const; + template + void set_genindexhash(ArgT0&& arg0, ArgT... args); + std::string* mutable_genindexhash(); + PROTOBUF_NODISCARD std::string* release_genindexhash(); + void set_allocated_genindexhash(std::string* genindexhash); + private: + const std::string& _internal_genindexhash() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); + std::string* _internal_mutable_genindexhash(); + public: + + // required bytes rotatingPublicKey = 3; + bool has_rotatingpublickey() const; + private: + bool _internal_has_rotatingpublickey() const; + public: + void clear_rotatingpublickey(); + const std::string& rotatingpublickey() const; + template + void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingpublickey(); + PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); + void set_allocated_rotatingpublickey(std::string* rotatingpublickey); + private: + const std::string& _internal_rotatingpublickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); + std::string* _internal_mutable_rotatingpublickey(); + public: + + // required bytes sig = 5; + bool has_sig() const; + private: + bool _internal_has_sig() const; + public: + void clear_sig(); + const std::string& sig() const; + template + void set_sig(ArgT0&& arg0, ArgT... args); + std::string* mutable_sig(); + PROTOBUF_NODISCARD std::string* release_sig(); + void set_allocated_sig(std::string* sig); + private: + const std::string& _internal_sig() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); + std::string* _internal_mutable_sig(); + public: + + // required uint64 expiryUnixTs = 4; + bool has_expiryunixts() const; + private: + bool _internal_has_expiryunixts() const; + public: + void clear_expiryunixts(); + uint64_t expiryunixts() const; + void set_expiryunixts(uint64_t value); + private: + uint64_t _internal_expiryunixts() const; + void _internal_set_expiryunixts(uint64_t value); + public: + + // required uint32 version = 1; + bool has_version() const; + private: + bool _internal_has_version() const; + public: + void clear_version(); + uint32_t version() const; + void set_version(uint32_t value); + private: + uint32_t _internal_version() const; + void _internal_set_version(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.ProProof) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; + uint64_t expiryunixts_; + uint32_t version_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + +class ProConfig final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ProConfig) */ { + public: + inline ProConfig() : ProConfig(nullptr) {} + ~ProConfig() override; + explicit PROTOBUF_CONSTEXPR ProConfig(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + ProConfig(const ProConfig& from); + ProConfig(ProConfig&& from) noexcept + : ProConfig() { + *this = ::std::move(from); + } + + inline ProConfig& operator=(const ProConfig& from) { + CopyFrom(from); + return *this; + } + inline ProConfig& operator=(ProConfig&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ProConfig& default_instance() { + return *internal_default_instance(); + } + static inline const ProConfig* internal_default_instance() { + return reinterpret_cast( + &_ProConfig_default_instance_); + } + static constexpr int kIndexInFileMessages = + 28; + + friend void swap(ProConfig& a, ProConfig& b) { + a.Swap(&b); + } + inline void Swap(ProConfig* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ProConfig* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ProConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const ProConfig& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const ProConfig& from) { + ProConfig::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ProConfig* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.ProConfig"; + } + protected: + explicit ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRotatingPrivKeyFieldNumber = 1, + kProofFieldNumber = 2, + }; + // required bytes rotatingPrivKey = 1; + bool has_rotatingprivkey() const; + private: + bool _internal_has_rotatingprivkey() const; + public: + void clear_rotatingprivkey(); + const std::string& rotatingprivkey() const; + template + void set_rotatingprivkey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingprivkey(); + PROTOBUF_NODISCARD std::string* release_rotatingprivkey(); + void set_allocated_rotatingprivkey(std::string* rotatingprivkey); + private: + const std::string& _internal_rotatingprivkey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingprivkey(const std::string& value); + std::string* _internal_mutable_rotatingprivkey(); + public: + + // required .SessionProtos.ProProof proof = 2; + bool has_proof() const; + private: + bool _internal_has_proof() const; + public: + void clear_proof(); + const ::SessionProtos::ProProof& proof() const; + PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); + ::SessionProtos::ProProof* mutable_proof(); + void set_allocated_proof(::SessionProtos::ProProof* proof); + private: + const ::SessionProtos::ProProof& _internal_proof() const; + ::SessionProtos::ProProof* _internal_mutable_proof(); + public: + void unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof); + ::SessionProtos::ProProof* unsafe_arena_release_proof(); + + // @@protoc_insertion_point(class_scope:SessionProtos.ProConfig) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingprivkey_; + ::SessionProtos::ProProof* proof_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// ------------------------------------------------------------------- + +class ProMessage final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ProMessage) */ { + public: + inline ProMessage() : ProMessage(nullptr) {} + ~ProMessage() override; + explicit PROTOBUF_CONSTEXPR ProMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + ProMessage(const ProMessage& from); + ProMessage(ProMessage&& from) noexcept + : ProMessage() { + *this = ::std::move(from); + } + + inline ProMessage& operator=(const ProMessage& from) { + CopyFrom(from); + return *this; + } + inline ProMessage& operator=(ProMessage&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ProMessage& default_instance() { + return *internal_default_instance(); + } + static inline const ProMessage* internal_default_instance() { + return reinterpret_cast( + &_ProMessage_default_instance_); + } + static constexpr int kIndexInFileMessages = + 29; + + friend void swap(ProMessage& a, ProMessage& b) { + a.Swap(&b); + } + inline void Swap(ProMessage* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ProMessage* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ProMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const ProMessage& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const ProMessage& from) { + ProMessage::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ProMessage* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SessionProtos.ProMessage"; + } + protected: + explicit ProMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kProofFieldNumber = 1, + kFlagsFieldNumber = 2, + }; + // required .SessionProtos.ProProof proof = 1; + bool has_proof() const; + private: + bool _internal_has_proof() const; + public: + void clear_proof(); + const ::SessionProtos::ProProof& proof() const; + PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); + ::SessionProtos::ProProof* mutable_proof(); + void set_allocated_proof(::SessionProtos::ProProof* proof); + private: + const ::SessionProtos::ProProof& _internal_proof() const; + ::SessionProtos::ProProof* _internal_mutable_proof(); + public: + void unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof); + ::SessionProtos::ProProof* unsafe_arena_release_proof(); + + // required uint32 flags = 2; + bool has_flags() const; + private: + bool _internal_has_flags() const; + public: + void clear_flags(); + uint32_t flags() const; + void set_flags(uint32_t value); + private: + uint32_t _internal_flags() const; + void _internal_set_flags(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:SessionProtos.ProMessage) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::SessionProtos::ProProof* proof_; + uint32_t flags_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_SessionProtos_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Envelope + +// required .SessionProtos.Envelope.Type type = 1; +inline bool Envelope::_internal_has_type() const { + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + return value; +} +inline bool Envelope::has_type() const { + return _internal_has_type(); +} +inline void Envelope::clear_type() { + _impl_.type_ = 6; + _impl_._has_bits_[0] &= ~0x00000040u; +} +inline ::SessionProtos::Envelope_Type Envelope::_internal_type() const { + return static_cast< ::SessionProtos::Envelope_Type >(_impl_.type_); +} +inline ::SessionProtos::Envelope_Type Envelope::type() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.type) + return _internal_type(); +} +inline void Envelope::_internal_set_type(::SessionProtos::Envelope_Type value) { + assert(::SessionProtos::Envelope_Type_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.type_ = value; +} +inline void Envelope::set_type(::SessionProtos::Envelope_Type value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.type) +} + +// optional string source = 2; +inline bool Envelope::_internal_has_source() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Envelope::has_source() const { + return _internal_has_source(); +} +inline void Envelope::clear_source() { + _impl_.source_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Envelope::source() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.source) + return _internal_source(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Envelope::set_source(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.source_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.source) +} +inline std::string* Envelope::mutable_source() { + std::string* _s = _internal_mutable_source(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.source) + return _s; +} +inline const std::string& Envelope::_internal_source() const { + return _impl_.source_.Get(); +} +inline void Envelope::_internal_set_source(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.source_.Set(value, GetArenaForAllocation()); +} +inline std::string* Envelope::_internal_mutable_source() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.source_.Mutable(GetArenaForAllocation()); +} +inline std::string* Envelope::release_source() { + // @@protoc_insertion_point(field_release:SessionProtos.Envelope.source) + if (!_internal_has_source()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.source_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.source_.IsDefault()) { + _impl_.source_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Envelope::set_allocated_source(std::string* source) { + if (source != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.source_.SetAllocated(source, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.source_.IsDefault()) { + _impl_.source_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.source) +} + +// optional uint32 sourceDevice = 7; +inline bool Envelope::_internal_has_sourcedevice() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + return value; +} +inline bool Envelope::has_sourcedevice() const { + return _internal_has_sourcedevice(); +} +inline void Envelope::clear_sourcedevice() { + _impl_.sourcedevice_ = 0u; + _impl_._has_bits_[0] &= ~0x00000020u; +} +inline uint32_t Envelope::_internal_sourcedevice() const { + return _impl_.sourcedevice_; +} +inline uint32_t Envelope::sourcedevice() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.sourceDevice) + return _internal_sourcedevice(); +} +inline void Envelope::_internal_set_sourcedevice(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.sourcedevice_ = value; +} +inline void Envelope::set_sourcedevice(uint32_t value) { + _internal_set_sourcedevice(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.sourceDevice) +} + +// required uint64 timestamp = 5; +inline bool Envelope::_internal_has_timestamp() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool Envelope::has_timestamp() const { + return _internal_has_timestamp(); +} +inline void Envelope::clear_timestamp() { + _impl_.timestamp_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline uint64_t Envelope::_internal_timestamp() const { + return _impl_.timestamp_; +} +inline uint64_t Envelope::timestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.timestamp) + return _internal_timestamp(); +} +inline void Envelope::_internal_set_timestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.timestamp_ = value; +} +inline void Envelope::set_timestamp(uint64_t value) { + _internal_set_timestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.timestamp) +} + +// optional bytes content = 8; +inline bool Envelope::_internal_has_content() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Envelope::has_content() const { + return _internal_has_content(); +} +inline void Envelope::clear_content() { + _impl_.content_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& Envelope::content() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.content) + return _internal_content(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Envelope::set_content(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.content_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.content) +} +inline std::string* Envelope::mutable_content() { + std::string* _s = _internal_mutable_content(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.content) + return _s; +} +inline const std::string& Envelope::_internal_content() const { + return _impl_.content_.Get(); +} +inline void Envelope::_internal_set_content(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.content_.Set(value, GetArenaForAllocation()); +} +inline std::string* Envelope::_internal_mutable_content() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.content_.Mutable(GetArenaForAllocation()); +} +inline std::string* Envelope::release_content() { + // @@protoc_insertion_point(field_release:SessionProtos.Envelope.content) + if (!_internal_has_content()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.content_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.content_.IsDefault()) { + _impl_.content_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Envelope::set_allocated_content(std::string* content) { + if (content != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.content_.SetAllocated(content, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.content_.IsDefault()) { + _impl_.content_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.content) @@ -7050,7 +7711,7 @@ inline void Envelope::set_allocated_content(std::string* content) { // optional uint64 serverTimestamp = 10; inline bool Envelope::_internal_has_servertimestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } inline bool Envelope::has_servertimestamp() const { @@ -7058,7 +7719,7 @@ inline bool Envelope::has_servertimestamp() const { } inline void Envelope::clear_servertimestamp() { _impl_.servertimestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } inline uint64_t Envelope::_internal_servertimestamp() const { return _impl_.servertimestamp_; @@ -7068,7 +7729,7 @@ inline uint64_t Envelope::servertimestamp() const { return _internal_servertimestamp(); } inline void Envelope::_internal_set_servertimestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000010u; _impl_.servertimestamp_ = value; } inline void Envelope::set_servertimestamp(uint64_t value) { @@ -7076,6 +7737,74 @@ inline void Envelope::set_servertimestamp(uint64_t value) { // @@protoc_insertion_point(field_set:SessionProtos.Envelope.serverTimestamp) } +// optional bytes proSig = 11; +inline bool Envelope::_internal_has_prosig() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool Envelope::has_prosig() const { + return _internal_has_prosig(); +} +inline void Envelope::clear_prosig() { + _impl_.prosig_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline const std::string& Envelope::prosig() const { + // @@protoc_insertion_point(field_get:SessionProtos.Envelope.proSig) + return _internal_prosig(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Envelope::set_prosig(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.prosig_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.Envelope.proSig) +} +inline std::string* Envelope::mutable_prosig() { + std::string* _s = _internal_mutable_prosig(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Envelope.proSig) + return _s; +} +inline const std::string& Envelope::_internal_prosig() const { + return _impl_.prosig_.Get(); +} +inline void Envelope::_internal_set_prosig(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.prosig_.Set(value, GetArenaForAllocation()); +} +inline std::string* Envelope::_internal_mutable_prosig() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.prosig_.Mutable(GetArenaForAllocation()); +} +inline std::string* Envelope::release_prosig() { + // @@protoc_insertion_point(field_release:SessionProtos.Envelope.proSig) + if (!_internal_has_prosig()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.prosig_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.prosig_.IsDefault()) { + _impl_.prosig_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Envelope::set_allocated_prosig(std::string* prosig) { + if (prosig != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.prosig_.SetAllocated(prosig, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.prosig_.IsDefault()) { + _impl_.prosig_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Envelope.proSig) +} + // ------------------------------------------------------------------- // TypingMessage @@ -8153,7 +8882,7 @@ inline void Content::set_allocated_sharedconfigmessage(::SessionProtos::SharedCo // optional .SessionProtos.Content.ExpirationType expirationType = 12; inline bool Content::_internal_has_expirationtype() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; return value; } inline bool Content::has_expirationtype() const { @@ -8161,7 +8890,7 @@ inline bool Content::has_expirationtype() const { } inline void Content::clear_expirationtype() { _impl_.expirationtype_ = 0; - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; } inline ::SessionProtos::Content_ExpirationType Content::_internal_expirationtype() const { return static_cast< ::SessionProtos::Content_ExpirationType >(_impl_.expirationtype_); @@ -8172,7 +8901,7 @@ inline ::SessionProtos::Content_ExpirationType Content::expirationtype() const { } inline void Content::_internal_set_expirationtype(::SessionProtos::Content_ExpirationType value) { assert(::SessionProtos::Content_ExpirationType_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000200u; _impl_.expirationtype_ = value; } inline void Content::set_expirationtype(::SessionProtos::Content_ExpirationType value) { @@ -8182,7 +8911,7 @@ inline void Content::set_expirationtype(::SessionProtos::Content_ExpirationType // optional uint32 expirationTimer = 13; inline bool Content::_internal_has_expirationtimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } inline bool Content::has_expirationtimer() const { @@ -8190,7 +8919,7 @@ inline bool Content::has_expirationtimer() const { } inline void Content::clear_expirationtimer() { _impl_.expirationtimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000200u; + _impl_._has_bits_[0] &= ~0x00000400u; } inline uint32_t Content::_internal_expirationtimer() const { return _impl_.expirationtimer_; @@ -8200,7 +8929,7 @@ inline uint32_t Content::expirationtimer() const { return _internal_expirationtimer(); } inline void Content::_internal_set_expirationtimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000200u; + _impl_._has_bits_[0] |= 0x00000400u; _impl_.expirationtimer_ = value; } inline void Content::set_expirationtimer(uint32_t value) { @@ -8210,7 +8939,7 @@ inline void Content::set_expirationtimer(uint32_t value) { // optional uint64 sigTimestamp = 15; inline bool Content::_internal_has_sigtimestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; return value; } inline bool Content::has_sigtimestamp() const { @@ -8218,22 +8947,112 @@ inline bool Content::has_sigtimestamp() const { } inline void Content::clear_sigtimestamp() { _impl_.sigtimestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000400u; + _impl_._has_bits_[0] &= ~0x00000800u; +} +inline uint64_t Content::_internal_sigtimestamp() const { + return _impl_.sigtimestamp_; +} +inline uint64_t Content::sigtimestamp() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.sigTimestamp) + return _internal_sigtimestamp(); +} +inline void Content::_internal_set_sigtimestamp(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000800u; + _impl_.sigtimestamp_ = value; +} +inline void Content::set_sigtimestamp(uint64_t value) { + _internal_set_sigtimestamp(value); + // @@protoc_insertion_point(field_set:SessionProtos.Content.sigTimestamp) +} + +// optional .SessionProtos.ProMessage proMessage = 16; +inline bool Content::_internal_has_promessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; + PROTOBUF_ASSUME(!value || _impl_.promessage_ != nullptr); + return value; +} +inline bool Content::has_promessage() const { + return _internal_has_promessage(); +} +inline void Content::clear_promessage() { + if (_impl_.promessage_ != nullptr) _impl_.promessage_->Clear(); + _impl_._has_bits_[0] &= ~0x00000100u; +} +inline const ::SessionProtos::ProMessage& Content::_internal_promessage() const { + const ::SessionProtos::ProMessage* p = _impl_.promessage_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProMessage_default_instance_); +} +inline const ::SessionProtos::ProMessage& Content::promessage() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.proMessage) + return _internal_promessage(); +} +inline void Content::unsafe_arena_set_allocated_promessage( + ::SessionProtos::ProMessage* promessage) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.promessage_); + } + _impl_.promessage_ = promessage; + if (promessage) { + _impl_._has_bits_[0] |= 0x00000100u; + } else { + _impl_._has_bits_[0] &= ~0x00000100u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.proMessage) +} +inline ::SessionProtos::ProMessage* Content::release_promessage() { + _impl_._has_bits_[0] &= ~0x00000100u; + ::SessionProtos::ProMessage* temp = _impl_.promessage_; + _impl_.promessage_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; } -inline uint64_t Content::_internal_sigtimestamp() const { - return _impl_.sigtimestamp_; +inline ::SessionProtos::ProMessage* Content::unsafe_arena_release_promessage() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.proMessage) + _impl_._has_bits_[0] &= ~0x00000100u; + ::SessionProtos::ProMessage* temp = _impl_.promessage_; + _impl_.promessage_ = nullptr; + return temp; } -inline uint64_t Content::sigtimestamp() const { - // @@protoc_insertion_point(field_get:SessionProtos.Content.sigTimestamp) - return _internal_sigtimestamp(); +inline ::SessionProtos::ProMessage* Content::_internal_mutable_promessage() { + _impl_._has_bits_[0] |= 0x00000100u; + if (_impl_.promessage_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProMessage>(GetArenaForAllocation()); + _impl_.promessage_ = p; + } + return _impl_.promessage_; } -inline void Content::_internal_set_sigtimestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000400u; - _impl_.sigtimestamp_ = value; +inline ::SessionProtos::ProMessage* Content::mutable_promessage() { + ::SessionProtos::ProMessage* _msg = _internal_mutable_promessage(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.proMessage) + return _msg; } -inline void Content::set_sigtimestamp(uint64_t value) { - _internal_set_sigtimestamp(value); - // @@protoc_insertion_point(field_set:SessionProtos.Content.sigTimestamp) +inline void Content::set_allocated_promessage(::SessionProtos::ProMessage* promessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.promessage_; + } + if (promessage) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(promessage); + if (message_arena != submessage_arena) { + promessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, promessage, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000100u; + } else { + _impl_._has_bits_[0] &= ~0x00000100u; + } + _impl_.promessage_ = promessage; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.proMessage) } // ------------------------------------------------------------------- @@ -13213,153 +14032,701 @@ GroupUpdateDeleteMemberContentMessage::membersessionids() const { // @@protoc_insertion_point(field_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) return _impl_.membersessionids_; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -GroupUpdateDeleteMemberContentMessage::mutable_membersessionids() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) - return &_impl_.membersessionids_; +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +GroupUpdateDeleteMemberContentMessage::mutable_membersessionids() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds) + return &_impl_.membersessionids_; +} + +// repeated string messageHashes = 2; +inline int GroupUpdateDeleteMemberContentMessage::_internal_messagehashes_size() const { + return _impl_.messagehashes_.size(); +} +inline int GroupUpdateDeleteMemberContentMessage::messagehashes_size() const { + return _internal_messagehashes_size(); +} +inline void GroupUpdateDeleteMemberContentMessage::clear_messagehashes() { + _impl_.messagehashes_.Clear(); +} +inline std::string* GroupUpdateDeleteMemberContentMessage::add_messagehashes() { + std::string* _s = _internal_add_messagehashes(); + // @@protoc_insertion_point(field_add_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _s; +} +inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_messagehashes(int index) const { + return _impl_.messagehashes_.Get(index); +} +inline const std::string& GroupUpdateDeleteMemberContentMessage::messagehashes(int index) const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _internal_messagehashes(index); +} +inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_messagehashes(int index) { + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _impl_.messagehashes_.Mutable(index); +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const std::string& value) { + _impl_.messagehashes_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, std::string&& value) { + _impl_.messagehashes_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.messagehashes_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const char* value, size_t size) { + _impl_.messagehashes_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_add_messagehashes() { + return _impl_.messagehashes_.Add(); +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const std::string& value) { + _impl_.messagehashes_.Add()->assign(value); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(std::string&& value) { + _impl_.messagehashes_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _impl_.messagehashes_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const char* value, size_t size) { + _impl_.messagehashes_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +GroupUpdateDeleteMemberContentMessage::messagehashes() const { + // @@protoc_insertion_point(field_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return _impl_.messagehashes_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +GroupUpdateDeleteMemberContentMessage::mutable_messagehashes() { + // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + return &_impl_.messagehashes_; +} + +// optional bytes adminSignature = 3; +inline bool GroupUpdateDeleteMemberContentMessage::_internal_has_adminsignature() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool GroupUpdateDeleteMemberContentMessage::has_adminsignature() const { + return _internal_has_adminsignature(); +} +inline void GroupUpdateDeleteMemberContentMessage::clear_adminsignature() { + _impl_.adminsignature_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& GroupUpdateDeleteMemberContentMessage::adminsignature() const { + // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + return _internal_adminsignature(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void GroupUpdateDeleteMemberContentMessage::set_adminsignature(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.adminsignature_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) +} +inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_adminsignature() { + std::string* _s = _internal_mutable_adminsignature(); + // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + return _s; +} +inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_adminsignature() const { + return _impl_.adminsignature_.Get(); +} +inline void GroupUpdateDeleteMemberContentMessage::_internal_set_adminsignature(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.adminsignature_.Set(value, GetArenaForAllocation()); +} +inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_mutable_adminsignature() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.adminsignature_.Mutable(GetArenaForAllocation()); +} +inline std::string* GroupUpdateDeleteMemberContentMessage::release_adminsignature() { + // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + if (!_internal_has_adminsignature()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.adminsignature_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void GroupUpdateDeleteMemberContentMessage::set_allocated_adminsignature(std::string* adminsignature) { + if (adminsignature != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.adminsignature_.SetAllocated(adminsignature, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.adminsignature_.IsDefault()) { + _impl_.adminsignature_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) +} + +// ------------------------------------------------------------------- + +// ProProof + +// required uint32 version = 1; +inline bool ProProof::_internal_has_version() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool ProProof::has_version() const { + return _internal_has_version(); +} +inline void ProProof::clear_version() { + _impl_.version_ = 0u; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline uint32_t ProProof::_internal_version() const { + return _impl_.version_; +} +inline uint32_t ProProof::version() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.version) + return _internal_version(); +} +inline void ProProof::_internal_set_version(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.version_ = value; +} +inline void ProProof::set_version(uint32_t value) { + _internal_set_version(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.version) +} + +// required bytes genIndexHash = 2; +inline bool ProProof::_internal_has_genindexhash() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool ProProof::has_genindexhash() const { + return _internal_has_genindexhash(); +} +inline void ProProof::clear_genindexhash() { + _impl_.genindexhash_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& ProProof::genindexhash() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.genIndexHash) + return _internal_genindexhash(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ProProof::set_genindexhash(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.genindexhash_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.genIndexHash) +} +inline std::string* ProProof::mutable_genindexhash() { + std::string* _s = _internal_mutable_genindexhash(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.genIndexHash) + return _s; +} +inline const std::string& ProProof::_internal_genindexhash() const { + return _impl_.genindexhash_.Get(); +} +inline void ProProof::_internal_set_genindexhash(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.genindexhash_.Set(value, GetArenaForAllocation()); +} +inline std::string* ProProof::_internal_mutable_genindexhash() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.genindexhash_.Mutable(GetArenaForAllocation()); +} +inline std::string* ProProof::release_genindexhash() { + // @@protoc_insertion_point(field_release:SessionProtos.ProProof.genIndexHash) + if (!_internal_has_genindexhash()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.genindexhash_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.genindexhash_.IsDefault()) { + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ProProof::set_allocated_genindexhash(std::string* genindexhash) { + if (genindexhash != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.genindexhash_.SetAllocated(genindexhash, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.genindexhash_.IsDefault()) { + _impl_.genindexhash_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.genIndexHash) +} + +// required bytes rotatingPublicKey = 3; +inline bool ProProof::_internal_has_rotatingpublickey() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool ProProof::has_rotatingpublickey() const { + return _internal_has_rotatingpublickey(); +} +inline void ProProof::clear_rotatingpublickey() { + _impl_.rotatingpublickey_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& ProProof::rotatingpublickey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.rotatingPublicKey) + return _internal_rotatingpublickey(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void ProProof::set_rotatingpublickey(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.rotatingpublickey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.rotatingPublicKey) +} +inline std::string* ProProof::mutable_rotatingpublickey() { + std::string* _s = _internal_mutable_rotatingpublickey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.rotatingPublicKey) + return _s; +} +inline const std::string& ProProof::_internal_rotatingpublickey() const { + return _impl_.rotatingpublickey_.Get(); +} +inline void ProProof::_internal_set_rotatingpublickey(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.rotatingpublickey_.Set(value, GetArenaForAllocation()); +} +inline std::string* ProProof::_internal_mutable_rotatingpublickey() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.rotatingpublickey_.Mutable(GetArenaForAllocation()); +} +inline std::string* ProProof::release_rotatingpublickey() { + // @@protoc_insertion_point(field_release:SessionProtos.ProProof.rotatingPublicKey) + if (!_internal_has_rotatingpublickey()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.rotatingpublickey_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.rotatingpublickey_.IsDefault()) { + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void ProProof::set_allocated_rotatingpublickey(std::string* rotatingpublickey) { + if (rotatingpublickey != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.rotatingpublickey_.SetAllocated(rotatingpublickey, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.rotatingpublickey_.IsDefault()) { + _impl_.rotatingpublickey_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.rotatingPublicKey) } -// repeated string messageHashes = 2; -inline int GroupUpdateDeleteMemberContentMessage::_internal_messagehashes_size() const { - return _impl_.messagehashes_.size(); +// required uint64 expiryUnixTs = 4; +inline bool ProProof::_internal_has_expiryunixts() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; } -inline int GroupUpdateDeleteMemberContentMessage::messagehashes_size() const { - return _internal_messagehashes_size(); +inline bool ProProof::has_expiryunixts() const { + return _internal_has_expiryunixts(); } -inline void GroupUpdateDeleteMemberContentMessage::clear_messagehashes() { - _impl_.messagehashes_.Clear(); +inline void ProProof::clear_expiryunixts() { + _impl_.expiryunixts_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000008u; } -inline std::string* GroupUpdateDeleteMemberContentMessage::add_messagehashes() { - std::string* _s = _internal_add_messagehashes(); - // @@protoc_insertion_point(field_add_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) - return _s; +inline uint64_t ProProof::_internal_expiryunixts() const { + return _impl_.expiryunixts_; } -inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_messagehashes(int index) const { - return _impl_.messagehashes_.Get(index); +inline uint64_t ProProof::expiryunixts() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.expiryUnixTs) + return _internal_expiryunixts(); } -inline const std::string& GroupUpdateDeleteMemberContentMessage::messagehashes(int index) const { - // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) - return _internal_messagehashes(index); +inline void ProProof::_internal_set_expiryunixts(uint64_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.expiryunixts_ = value; } -inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_messagehashes(int index) { - // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) - return _impl_.messagehashes_.Mutable(index); +inline void ProProof::set_expiryunixts(uint64_t value) { + _internal_set_expiryunixts(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.expiryUnixTs) } -inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const std::string& value) { - _impl_.messagehashes_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) + +// required bytes sig = 5; +inline bool ProProof::_internal_has_sig() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; } -inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, std::string&& value) { - _impl_.messagehashes_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline bool ProProof::has_sig() const { + return _internal_has_sig(); } -inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.messagehashes_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline void ProProof::clear_sig() { + _impl_.sig_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } -inline void GroupUpdateDeleteMemberContentMessage::set_messagehashes(int index, const char* value, size_t size) { - _impl_.messagehashes_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline const std::string& ProProof::sig() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProProof.sig) + return _internal_sig(); } -inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_add_messagehashes() { - return _impl_.messagehashes_.Add(); +template +inline PROTOBUF_ALWAYS_INLINE +void ProProof::set_sig(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.sig_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProProof.sig) } -inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const std::string& value) { - _impl_.messagehashes_.Add()->assign(value); - // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline std::string* ProProof::mutable_sig() { + std::string* _s = _internal_mutable_sig(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProProof.sig) + return _s; } -inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(std::string&& value) { - _impl_.messagehashes_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline const std::string& ProProof::_internal_sig() const { + return _impl_.sig_.Get(); } -inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.messagehashes_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline void ProProof::_internal_set_sig(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.sig_.Set(value, GetArenaForAllocation()); } -inline void GroupUpdateDeleteMemberContentMessage::add_messagehashes(const char* value, size_t size) { - _impl_.messagehashes_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) +inline std::string* ProProof::_internal_mutable_sig() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.sig_.Mutable(GetArenaForAllocation()); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -GroupUpdateDeleteMemberContentMessage::messagehashes() const { - // @@protoc_insertion_point(field_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) - return _impl_.messagehashes_; +inline std::string* ProProof::release_sig() { + // @@protoc_insertion_point(field_release:SessionProtos.ProProof.sig) + if (!_internal_has_sig()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.sig_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.sig_.IsDefault()) { + _impl_.sig_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -GroupUpdateDeleteMemberContentMessage::mutable_messagehashes() { - // @@protoc_insertion_point(field_mutable_list:SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes) - return &_impl_.messagehashes_; +inline void ProProof::set_allocated_sig(std::string* sig) { + if (sig != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.sig_.SetAllocated(sig, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.sig_.IsDefault()) { + _impl_.sig_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.sig) } -// optional bytes adminSignature = 3; -inline bool GroupUpdateDeleteMemberContentMessage::_internal_has_adminsignature() const { +// ------------------------------------------------------------------- + +// ProConfig + +// required bytes rotatingPrivKey = 1; +inline bool ProConfig::_internal_has_rotatingprivkey() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool GroupUpdateDeleteMemberContentMessage::has_adminsignature() const { - return _internal_has_adminsignature(); +inline bool ProConfig::has_rotatingprivkey() const { + return _internal_has_rotatingprivkey(); } -inline void GroupUpdateDeleteMemberContentMessage::clear_adminsignature() { - _impl_.adminsignature_.ClearToEmpty(); +inline void ProConfig::clear_rotatingprivkey() { + _impl_.rotatingprivkey_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& GroupUpdateDeleteMemberContentMessage::adminsignature() const { - // @@protoc_insertion_point(field_get:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) - return _internal_adminsignature(); +inline const std::string& ProConfig::rotatingprivkey() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.rotatingPrivKey) + return _internal_rotatingprivkey(); } template inline PROTOBUF_ALWAYS_INLINE -void GroupUpdateDeleteMemberContentMessage::set_adminsignature(ArgT0&& arg0, ArgT... args) { +void ProConfig::set_rotatingprivkey(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.adminsignature_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + _impl_.rotatingprivkey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.ProConfig.rotatingPrivKey) } -inline std::string* GroupUpdateDeleteMemberContentMessage::mutable_adminsignature() { - std::string* _s = _internal_mutable_adminsignature(); - // @@protoc_insertion_point(field_mutable:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) +inline std::string* ProConfig::mutable_rotatingprivkey() { + std::string* _s = _internal_mutable_rotatingprivkey(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.rotatingPrivKey) return _s; } -inline const std::string& GroupUpdateDeleteMemberContentMessage::_internal_adminsignature() const { - return _impl_.adminsignature_.Get(); +inline const std::string& ProConfig::_internal_rotatingprivkey() const { + return _impl_.rotatingprivkey_.Get(); } -inline void GroupUpdateDeleteMemberContentMessage::_internal_set_adminsignature(const std::string& value) { +inline void ProConfig::_internal_set_rotatingprivkey(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.adminsignature_.Set(value, GetArenaForAllocation()); + _impl_.rotatingprivkey_.Set(value, GetArenaForAllocation()); } -inline std::string* GroupUpdateDeleteMemberContentMessage::_internal_mutable_adminsignature() { +inline std::string* ProConfig::_internal_mutable_rotatingprivkey() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.adminsignature_.Mutable(GetArenaForAllocation()); + return _impl_.rotatingprivkey_.Mutable(GetArenaForAllocation()); } -inline std::string* GroupUpdateDeleteMemberContentMessage::release_adminsignature() { - // @@protoc_insertion_point(field_release:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) - if (!_internal_has_adminsignature()) { +inline std::string* ProConfig::release_rotatingprivkey() { + // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.rotatingPrivKey) + if (!_internal_has_rotatingprivkey()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.adminsignature_.Release(); + auto* p = _impl_.rotatingprivkey_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.adminsignature_.IsDefault()) { - _impl_.adminsignature_.Set("", GetArenaForAllocation()); + if (_impl_.rotatingprivkey_.IsDefault()) { + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void GroupUpdateDeleteMemberContentMessage::set_allocated_adminsignature(std::string* adminsignature) { - if (adminsignature != nullptr) { +inline void ProConfig::set_allocated_rotatingprivkey(std::string* rotatingprivkey) { + if (rotatingprivkey != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.adminsignature_.SetAllocated(adminsignature, GetArenaForAllocation()); + _impl_.rotatingprivkey_.SetAllocated(rotatingprivkey, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.adminsignature_.IsDefault()) { - _impl_.adminsignature_.Set("", GetArenaForAllocation()); + if (_impl_.rotatingprivkey_.IsDefault()) { + _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.GroupUpdateDeleteMemberContentMessage.adminSignature) + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.rotatingPrivKey) +} + +// required .SessionProtos.ProProof proof = 2; +inline bool ProConfig::_internal_has_proof() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); + return value; +} +inline bool ProConfig::has_proof() const { + return _internal_has_proof(); +} +inline void ProConfig::clear_proof() { + if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const ::SessionProtos::ProProof& ProConfig::_internal_proof() const { + const ::SessionProtos::ProProof* p = _impl_.proof_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProProof_default_instance_); +} +inline const ::SessionProtos::ProProof& ProConfig::proof() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.proof) + return _internal_proof(); +} +inline void ProConfig::unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); + } + _impl_.proof_ = proof; + if (proof) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProConfig.proof) +} +inline ::SessionProtos::ProProof* ProConfig::release_proof() { + _impl_._has_bits_[0] &= ~0x00000002u; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::SessionProtos::ProProof* ProConfig::unsafe_arena_release_proof() { + // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.proof) + _impl_._has_bits_[0] &= ~0x00000002u; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; + return temp; +} +inline ::SessionProtos::ProProof* ProConfig::_internal_mutable_proof() { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.proof_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); + _impl_.proof_ = p; + } + return _impl_.proof_; +} +inline ::SessionProtos::ProProof* ProConfig::mutable_proof() { + ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.proof) + return _msg; +} +inline void ProConfig::set_allocated_proof(::SessionProtos::ProProof* proof) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.proof_; + } + if (proof) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); + if (message_arena != submessage_arena) { + proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, proof, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.proof_ = proof; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.proof) +} + +// ------------------------------------------------------------------- + +// ProMessage + +// required .SessionProtos.ProProof proof = 1; +inline bool ProMessage::_internal_has_proof() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); + return value; +} +inline bool ProMessage::has_proof() const { + return _internal_has_proof(); +} +inline void ProMessage::clear_proof() { + if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::SessionProtos::ProProof& ProMessage::_internal_proof() const { + const ::SessionProtos::ProProof* p = _impl_.proof_; + return p != nullptr ? *p : reinterpret_cast( + ::SessionProtos::_ProProof_default_instance_); +} +inline const ::SessionProtos::ProProof& ProMessage::proof() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProMessage.proof) + return _internal_proof(); +} +inline void ProMessage::unsafe_arena_set_allocated_proof( + ::SessionProtos::ProProof* proof) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); + } + _impl_.proof_ = proof; + if (proof) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProMessage.proof) +} +inline ::SessionProtos::ProProof* ProMessage::release_proof() { + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::SessionProtos::ProProof* ProMessage::unsafe_arena_release_proof() { + // @@protoc_insertion_point(field_release:SessionProtos.ProMessage.proof) + _impl_._has_bits_[0] &= ~0x00000001u; + ::SessionProtos::ProProof* temp = _impl_.proof_; + _impl_.proof_ = nullptr; + return temp; +} +inline ::SessionProtos::ProProof* ProMessage::_internal_mutable_proof() { + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.proof_ == nullptr) { + auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); + _impl_.proof_ = p; + } + return _impl_.proof_; +} +inline ::SessionProtos::ProProof* ProMessage::mutable_proof() { + ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); + // @@protoc_insertion_point(field_mutable:SessionProtos.ProMessage.proof) + return _msg; +} +inline void ProMessage::set_allocated_proof(::SessionProtos::ProProof* proof) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.proof_; + } + if (proof) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); + if (message_arena != submessage_arena) { + proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, proof, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.proof_ = proof; + // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProMessage.proof) +} + +// required uint32 flags = 2; +inline bool ProMessage::_internal_has_flags() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool ProMessage::has_flags() const { + return _internal_has_flags(); +} +inline void ProMessage::clear_flags() { + _impl_.flags_ = 0u; + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline uint32_t ProMessage::_internal_flags() const { + return _impl_.flags_; +} +inline uint32_t ProMessage::flags() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProMessage.flags) + return _internal_flags(); +} +inline void ProMessage::_internal_set_flags(uint32_t value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.flags_ = value; +} +inline void ProMessage::set_flags(uint32_t value) { + _internal_set_flags(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProMessage.flags) } #ifdef __GNUC__ @@ -13417,6 +14784,12 @@ inline void GroupUpdateDeleteMemberContentMessage::set_allocated_adminsignature( // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 07dec5ec..98dcf025 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -19,6 +19,7 @@ message Envelope { required uint64 timestamp = 5; optional bytes content = 8; optional uint64 serverTimestamp = 10; + optional bytes proSig = 11; } message TypingMessage { @@ -70,6 +71,7 @@ message Content { optional ExpirationType expirationType = 12; optional uint32 expirationTimer = 13; optional uint64 sigTimestamp = 15; + optional ProMessage proMessage = 16; } message CallMessage { @@ -324,3 +326,16 @@ message GroupUpdateDeleteMemberContentMessage { repeated string messageHashes = 2; optional bytes adminSignature = 3; } + +message ProProof { + required uint32 version = 1; + required bytes genIndexHash = 2; + required bytes rotatingPublicKey = 3; + required uint64 expiryUnixTs = 4; + required bytes sig = 5; +} + +message ProMessage { + required ProProof proof = 1; + required uint32 flags = 2; +} From d1c3f58a100eb67491d3be50c0e1c693182e451e Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 8 Aug 2025 16:29:31 +1000 Subject: [PATCH 015/171] Port encrypt for namespace into libsession --- include/session/config/namespaces.hpp | 6 + include/session/config/pro.h | 11 +- include/session/config/user_profile.h | 43 + include/session/config/user_profile.hpp | 4 +- include/session/pro.hpp | 72 - include/session/pro_backend.hpp | 52 + include/session/session_protocol.h | 33 + include/session/session_protocol.hpp | 93 + include/session/types.hpp | 10 + proto/SessionProtos.pb.cc | 3330 ++++++++++------------- proto/SessionProtos.pb.h | 1906 +++---------- proto/SessionProtos.proto | 2 + src/CMakeLists.txt | 3 +- src/config/internal.hpp | 9 - src/config/pro.cpp | 6 +- src/config/user_profile.cpp | 45 +- src/{pro.cpp => pro_backend.cpp} | 73 +- src/session_encrypt.cpp | 2 +- src/session_protocol.cpp | 305 +++ 19 files changed, 2528 insertions(+), 3477 deletions(-) delete mode 100644 include/session/pro.hpp create mode 100644 include/session/pro_backend.hpp create mode 100644 include/session/session_protocol.h create mode 100644 include/session/session_protocol.hpp rename src/{pro.cpp => pro_backend.cpp} (55%) create mode 100644 src/session_protocol.cpp diff --git a/include/session/config/namespaces.hpp b/include/session/config/namespaces.hpp index 690f6cba..1383ebac 100644 --- a/include/session/config/namespaces.hpp +++ b/include/session/config/namespaces.hpp @@ -5,6 +5,12 @@ namespace session::config { enum class Namespace : std::int16_t { + // Messages sent to an updated closed group which should be able to be retrieved by revoked + // members are stored in this namespace + RevokedRetrievableGroupMessages = -11, + + // Messages sent to one-to-one conversations are stored in this namespace + Default = 0, UserProfile = 2, Contacts = 3, ConvoInfoVolatile = 4, diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 06d2f3c7..cd5c8bc7 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -4,6 +4,7 @@ extern "C" { #endif +#include #include #include @@ -17,14 +18,18 @@ struct pro_proof { uint8_t sig[64]; }; -struct pro_pro { +struct pro_pro_config { uint8_t rotating_privkey[64]; pro_proof proof; }; -LIBSESSION_EXPORT bool proof_verify(pro_proof const *proof, uint8_t const *verify_pubkey); +LIBSESSION_EXPORT pro_proof pro_proof_init(char const *dump, size_t dump_len); -LIBSESSION_EXPORT bool pro_verify(pro_pro const *pro, uint8_t const *verify_pubkey); +LIBSESSION_EXPORT pro_pro_config pro_pro_init(char const *dump, size_t dump_len); + +LIBSESSION_EXPORT bool pro_proof_verify(pro_proof const *proof, uint8_t const *verify_pubkey); + +LIBSESSION_EXPORT bool pro_pro_verify(pro_pro_config const *pro, uint8_t const *verify_pubkey); #ifdef __cplusplus } // extern "C" diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index 94d3531c..61df3434 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -6,6 +6,7 @@ extern "C" { #include "base.h" #include "profile_pic.h" +#include "pro.h" /// API: user_profile/user_profile_init /// @@ -279,6 +280,48 @@ LIBSESSION_EXPORT void user_profile_set_blinded_msgreqs(config_object* conf, int /// information. Will be `0` if it's never been updated. LIBSESSION_EXPORT int64_t user_profile_get_profile_updated(config_object* conf); +/// API: user_profile/user_profile_get_pro_config +/// +/// Get the Pro data for the user profile if it exists which includes the users rotating private key +/// and their last authorised proof. +/// +/// Declaration: +/// ```cpp +/// BOOL user_profile_get_pro_config( +/// [in] const config_object* conf +/// [out] pro_pro* pro +/// ); +/// ``` +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `pro` -- [out] Pointer to the pro object where the retrieved details are written +/// +/// Outputs: +/// - `bool` -- True if the user profile had Pro data associated with it. Otherwise false and the +/// pro structure will remain untouched. +LIBSESSION_EXPORT bool user_profile_get_pro_config(const config_object* conf, pro_pro_config *pro); + +/// API: user_profile/user_profile_set_pro_config +/// +/// Update the pro data associated with the user profile. +/// +/// Declaration: +/// ```cpp +/// VOID user_profile_set_pro_config( +/// [in] config_object* conf, +/// [in] pro_pro* pro +/// ); +/// ``` +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `pro` -- [in] Pointer to the Pro data to write to the user profile +/// +/// Outputs: +/// - `void` -- Returns nothing +LIBSESSION_EXPORT void user_profile_set_pro_config(config_object* conf, const pro_pro_config *pro); + #ifdef __cplusplus } // extern "C" #endif diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index d7c9cb71..8314ea91 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -250,7 +250,7 @@ class UserProfile : public ConfigBase { /// user does not have any entitlement to Session Pro data. /// /// Inputs: None - std::optional get_pro_data() const; + std::optional get_pro_config() const; /// API: user_profile/UserProfile::set_pro_data /// @@ -261,7 +261,7 @@ class UserProfile : public ConfigBase { /// Inputs: /// - `pro` -- The Session Pro components to assign to the current user profile. This will /// overwrite any existing Session Pro data if it exists. No verification of `pro` is done. - void set_pro_data(const ProConfig& pro); + void set_pro_config(const ProConfig& pro); }; } // namespace session::config diff --git a/include/session/pro.hpp b/include/session/pro.hpp deleted file mode 100644 index 92d1b2e1..00000000 --- a/include/session/pro.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include - -namespace session::pro { - -struct add_payment_request { - std::uint8_t version; - array_uc32 master_pkey; - array_uc32 rotating_pkey; - array_uc32 payment_token; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; - -struct get_proof_request { - std::uint8_t version; - array_uc32 master_pkey; - array_uc32 rotating_pkey; - std::chrono::seconds unix_ts_s; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; - -struct master_rotating_sigs { - array_uc64 master_sig; - array_uc64 rotating_sig; -}; - -struct revocation_item { - array_uc32 gen_index_hash; - std::chrono::seconds expiry_unix_ts; -}; - -enum class Status { - Nil, // Pro proof was not set - Invalid, // Pro proof was set; signature validation failed - Valid, // Pro proof was set, is verified; has not expired - Expired, // Pro proof was set, is verified; has expired -}; - -typedef std::uint32_t FeatureFlag; -enum FeatureFlag_ { - FeatureFlag_HigherCharacterLimit = 0 << 1, - FeatureFlag_ProBadge = 1 << 1, - FeatureFlag_AnimatedAvatar = 2 << 1, - FeatureFlag_All = - FeatureFlag_HigherCharacterLimit | FeatureFlag_ProBadge | FeatureFlag_AnimatedAvatar, -}; - -struct DecryptIncomingWithPro -{ - std::vector plaintext; - std::vector ed25519_pubkey; - config::ProProof pro_proof; - Status pro_status; - FeatureFlag pro_flags; -}; - -master_rotating_sigs build_get_proof_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts); -master_rotating_sigs build_add_payment_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); - -constexpr array_uc32 BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - -} // namespace session::pro diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp new file mode 100644 index 00000000..0504f664 --- /dev/null +++ b/include/session/pro_backend.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include + +namespace session::pro_backend { + +constexpr array_uc32 PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +struct add_payment_request { + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + array_uc32 payment_token; + array_uc32 master_sig; + array_uc32 rotating_sig; + std::string to_json() const; +}; + +struct get_proof_request { + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + std::chrono::seconds unix_ts_s; + array_uc32 master_sig; + array_uc32 rotating_sig; + std::string to_json() const; +}; + +struct master_rotating_sigs { + array_uc64 master_sig; + array_uc64 rotating_sig; +}; + +struct revocation_item { + array_uc32 gen_index_hash; + std::chrono::seconds expiry_unix_ts; +}; + +master_rotating_sigs build_get_proof_sigs( + const array_uc64& master_privkey, + const array_uc64& rotating_privkey, + std::chrono::seconds unix_ts); +master_rotating_sigs build_add_payment_sigs( + const array_uc64& master_privkey, + const array_uc64& rotating_privkey, + const array_uc32& payment_token_hash, + std::chrono::seconds unix_ts); + +} // namespace session::pro diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h new file mode 100644 index 00000000..f8872ef8 --- /dev/null +++ b/include/session/session_protocol.h @@ -0,0 +1,33 @@ +#include + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + SESSION_PRO_10k_CHARACTER_LIMIT = 10'000, +}; + +typedef uint64_t session_pro_extra_features; +enum session_pro_extra_features_ { + session_pro_extra_nil = 0, + session_pro_extra_features_pro_badge = 0 << 1, + session_pro_extra_features_animated_avatar = 1 << 1, +}; + +typedef uint64_t session_pro_features; +enum session_pro_features_ { + session_pro_features_nil = 0, + session_pro_features_10k_character_limit = 1 << 0, + session_pro_features_pro_badge = 1 << 1, + session_pro_features_animated_avatar = 1 << 2, + session_pro_features_all = session_pro_features_10k_character_limit | + session_pro_features_pro_badge | + session_pro_features_animated_avatar, +}; + +#ifdef __cplusplus +} +#endif diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp new file mode 100644 index 00000000..5296a80f --- /dev/null +++ b/include/session/session_protocol.hpp @@ -0,0 +1,93 @@ +#pragma once + +#include +#include +#include +#include + +/// A complimentary file to session encrypt which has the low level encryption function for Session +/// protocol types. This file contains high-level helper functions for decoding payloads on the +/// Session protocol. Prefer functions here before resorting to the lower-level cryptography. +namespace session { + +namespace config::groups { + class Keys; +} + +enum class ProStatus { + Nil, // Pro proof was not set + Invalid, // Pro proof was set; signature validation failed + Valid, // Pro proof was set, is verified; has not expired + Expired, // Pro proof was set, is verified; has expired +}; + + +enum class DestinationType { + Contact, + SyncMessage, + ClosedGroup, + OpenGroup, + OpenGroupInbox, +}; + +struct Destination { + DestinationType type; + + // Signature over the plaintext with the user's Session Pro rotating public key if they have + // Session Pro and opt into sending a message with pro features. + std::optional pro_sig; + + // Set to the recipient of the message if it requires one. Ignored otherwise (for example + // ignored in OpenGroup) + array_uc32 recipient_pubkey; + + // The timestamp to assign to the message envelope if the message requires one. Ignored otherwise + std::chrono::milliseconds sent_timestamp_ms; + + // When type => OpenGroupInbox: set this pubkey to the server's key + array_uc32 open_group_inbox_server_pubkey; + + // When type => ClosedGroup: set the following 'closed_group' prefixed fields + array_uc33 closed_group_pubkey; + const session::config::groups::Keys *closed_group_keys; + + // Set to the closed group's swarm public key (needed for Android) for a non 0x03 prefixed + // `closed_group_pubkey`. Ignored otherwise. This will be set as the envelope source. See: + // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 + std::optional closed_group_swarm_public_key; +}; + +using ProFeatures = session_pro_features; +using ProExtraFeatures = session_pro_extra_features; + +struct DecryptIncomingWithPro +{ + std::vector plaintext; + std::vector ed25519_pubkey; + config::ProProof pro_proof; + ProStatus pro_status; + session_pro_features pro_flags; + array_uc64 pro_sig; +}; + +struct PrepareMsgForPro { + ProFeatures flags; + array_uc64 sig; +}; + +ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures flags); + +array_uc64 sign_msg_for_pro( + std::span msg, const array_uc64& rotating_priv_key); + +std::vector encrypt_for_namespaced_destination( + std::span plaintext, + std::span ed25519_privkey, + const Destination& dest, + config::Namespace space); + +DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( + std::span ed25519_privkey, + std::span ciphertext, + std::chrono::sys_seconds unix_ts); +} // namespace session diff --git a/include/session/types.hpp b/include/session/types.hpp index a33aaaf8..4cd9022f 100644 --- a/include/session/types.hpp +++ b/include/session/types.hpp @@ -5,8 +5,18 @@ namespace session { using array_uc32 = std::array; +using array_uc33 = std::array; using array_uc64 = std::array; +enum class SessionIDPrefix { + standard = 0, + group = 0x3, + community_blinded_legacy = 0x5, + community_blinded = 0x15, + version_blinded = 0x25, + unblinded = 0x7, +}; + namespace config { using seqno_t = std::int64_t; } diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index a55151c1..b5029232 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -8,10 +8,7 @@ #include #include #include -#include -#include -#include -#include +#include // @@protoc_insertion_point(includes) #include @@ -427,7 +424,8 @@ struct GroupUpdateMemberChangeMessageDefaultTypeInternal { }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateMemberChangeMessageDefaultTypeInternal _GroupUpdateMemberChangeMessage_default_instance_; PROTOBUF_CONSTEXPR GroupUpdateMemberLeftMessage::GroupUpdateMemberLeftMessage( - ::_pbi::ConstantInitialized) {} + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._cached_size_)*/{}} {} struct GroupUpdateMemberLeftMessageDefaultTypeInternal { PROTOBUF_CONSTEXPR GroupUpdateMemberLeftMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -438,7 +436,8 @@ struct GroupUpdateMemberLeftMessageDefaultTypeInternal { }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GroupUpdateMemberLeftMessageDefaultTypeInternal _GroupUpdateMemberLeftMessage_default_instance_; PROTOBUF_CONSTEXPR GroupUpdateMemberLeftNotificationMessage::GroupUpdateMemberLeftNotificationMessage( - ::_pbi::ConstantInitialized) {} + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._cached_size_)*/{}} {} struct GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal { PROTOBUF_CONSTEXPR GroupUpdateMemberLeftNotificationMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -496,21 +495,6 @@ struct ProProofDefaultTypeInternal { }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProProofDefaultTypeInternal _ProProof_default_instance_; -PROTOBUF_CONSTEXPR ProConfig::ProConfig( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_._has_bits_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.rotatingprivkey_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.proof_)*/nullptr} {} -struct ProConfigDefaultTypeInternal { - PROTOBUF_CONSTEXPR ProConfigDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} - ~ProConfigDefaultTypeInternal() {} - union { - ProConfig _instance; - }; -}; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProConfigDefaultTypeInternal _ProConfig_default_instance_; PROTOBUF_CONSTEXPR ProMessage::ProMessage( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -527,649 +511,7 @@ struct ProMessageDefaultTypeInternal { }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ProMessageDefaultTypeInternal _ProMessage_default_instance_; } // namespace SessionProtos -static ::_pb::Metadata file_level_metadata_SessionProtos_2eproto[30]; -static const ::_pb::EnumDescriptor* file_level_enum_descriptors_SessionProtos_2eproto[13]; -static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_SessionProtos_2eproto = nullptr; - -const uint32_t TableStruct_SessionProtos_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.source_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.sourcedevice_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.timestamp_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.content_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.servertimestamp_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Envelope, _impl_.prosig_), - 6, - 0, - 5, - 3, - 1, - 4, - 2, - PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_.timestamp_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::TypingMessage, _impl_.action_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _impl_.timestamp_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::UnsendRequest, _impl_.author_), - 1, - 0, - PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_.isapproved_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_.profilekey_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::MessageRequestResponse, _impl_.profile_), - 2, - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.datamessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.callmessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.receiptmessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.typingmessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.dataextractionnotification_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.unsendrequest_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.messagerequestresponse_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.sharedconfigmessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.expirationtype_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.expirationtimer_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.sigtimestamp_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::Content, _impl_.promessage_), - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 10, - 11, - 8, - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.sdps_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.sdpmlineindexes_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.sdpmids_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::CallMessage, _impl_.uuid_), - 1, - ~0u, - ~0u, - ~0u, - 0, - PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _impl_.publickey_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::KeyPair, _impl_.privatekey_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataExtractionNotification, _impl_.timestamp_), - 1, - 0, - PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _impl_.displayname_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::LokiProfile, _impl_.profilepicture_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.contenttype_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.filename_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.thumbnail_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote_QuotedAttachment, _impl_.flags_), - 0, - 1, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.id_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.author_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.text_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Quote, _impl_.attachments_), - 2, - 0, - 1, - ~0u, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_.url_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_.title_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Preview, _impl_.image_), - 0, - 1, - 2, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.id_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.author_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.emoji_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_Reaction, _impl_.action_), - 2, - 0, - 1, - 3, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _impl_.url_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage_OpenGroupInvitation, _impl_.name_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.body_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.attachments_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.flags_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.profilekey_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.timestamp_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.quote_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.preview_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.reaction_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.profile_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.opengroupinvitation_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.synctarget_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.blockscommunitymessagerequests_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::DataMessage, _impl_.groupupdatemessage_), - 0, - ~0u, - 9, - 1, - 8, - 3, - ~0u, - 4, - 5, - 6, - 2, - 10, - 7, - PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ReceiptMessage, _impl_.timestamp_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.id_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.contenttype_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.key_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.size_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.thumbnail_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.digest_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.filename_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.flags_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.width_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.height_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.caption_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::AttachmentPointer, _impl_.url_), - 7, - 0, - 1, - 8, - 2, - 3, - 4, - 9, - 10, - 11, - 5, - 6, - PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_.kind_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_.seqno_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::SharedConfigMessage, _impl_.data_), - 2, - 1, - 0, - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.invitemessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.infochangemessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.memberchangemessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.promotemessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.memberleftmessage_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.inviteresponse_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.deletemembercontent_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMessage, _impl_.memberleftnotificationmessage_), - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.groupsessionid_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.memberauthdata_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteMessage, _impl_.adminsignature_), - 0, - 1, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _impl_.groupidentityseed_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdatePromoteMessage, _impl_.name_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.updatedname_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.updatedexpiration_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInfoChangeMessage, _impl_.adminsignature_), - 3, - 0, - 2, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.membersessionids_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.historyshared_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberChangeMessage, _impl_.adminsignature_), - 2, - ~0u, - 1, - 0, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberLeftMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateMemberLeftNotificationMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteResponseMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteResponseMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateInviteResponseMessage, _impl_.isapproved_), - 0, - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_.membersessionids_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_.messagehashes_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::GroupUpdateDeleteMemberContentMessage, _impl_.adminsignature_), - ~0u, - ~0u, - 0, - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.version_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.genindexhash_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.rotatingpublickey_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.expiryunixts_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProProof, _impl_.sig_), - 4, - 0, - 1, - 3, - 2, - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _impl_.rotatingprivkey_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProConfig, _impl_.proof_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _impl_.proof_), - PROTOBUF_FIELD_OFFSET(::SessionProtos::ProMessage, _impl_.flags_), - 0, - 1, -}; -static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 13, -1, sizeof(::SessionProtos::Envelope)}, - { 20, 28, -1, sizeof(::SessionProtos::TypingMessage)}, - { 30, 38, -1, sizeof(::SessionProtos::UnsendRequest)}, - { 40, 49, -1, sizeof(::SessionProtos::MessageRequestResponse)}, - { 52, 70, -1, sizeof(::SessionProtos::Content)}, - { 82, 93, -1, sizeof(::SessionProtos::CallMessage)}, - { 98, 106, -1, sizeof(::SessionProtos::KeyPair)}, - { 108, 116, -1, sizeof(::SessionProtos::DataExtractionNotification)}, - { 118, 126, -1, sizeof(::SessionProtos::LokiProfile)}, - { 128, 138, -1, sizeof(::SessionProtos::DataMessage_Quote_QuotedAttachment)}, - { 142, 152, -1, sizeof(::SessionProtos::DataMessage_Quote)}, - { 156, 165, -1, sizeof(::SessionProtos::DataMessage_Preview)}, - { 168, 178, -1, sizeof(::SessionProtos::DataMessage_Reaction)}, - { 182, 190, -1, sizeof(::SessionProtos::DataMessage_OpenGroupInvitation)}, - { 192, 211, -1, sizeof(::SessionProtos::DataMessage)}, - { 224, 232, -1, sizeof(::SessionProtos::ReceiptMessage)}, - { 234, 252, -1, sizeof(::SessionProtos::AttachmentPointer)}, - { 264, 273, -1, sizeof(::SessionProtos::SharedConfigMessage)}, - { 276, 290, -1, sizeof(::SessionProtos::GroupUpdateMessage)}, - { 298, 308, -1, sizeof(::SessionProtos::GroupUpdateInviteMessage)}, - { 312, 320, -1, sizeof(::SessionProtos::GroupUpdatePromoteMessage)}, - { 322, 332, -1, sizeof(::SessionProtos::GroupUpdateInfoChangeMessage)}, - { 336, 346, -1, sizeof(::SessionProtos::GroupUpdateMemberChangeMessage)}, - { 350, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftMessage)}, - { 356, -1, -1, sizeof(::SessionProtos::GroupUpdateMemberLeftNotificationMessage)}, - { 362, 369, -1, sizeof(::SessionProtos::GroupUpdateInviteResponseMessage)}, - { 370, 379, -1, sizeof(::SessionProtos::GroupUpdateDeleteMemberContentMessage)}, - { 382, 393, -1, sizeof(::SessionProtos::ProProof)}, - { 398, 406, -1, sizeof(::SessionProtos::ProConfig)}, - { 408, 416, -1, sizeof(::SessionProtos::ProMessage)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::SessionProtos::_Envelope_default_instance_._instance, - &::SessionProtos::_TypingMessage_default_instance_._instance, - &::SessionProtos::_UnsendRequest_default_instance_._instance, - &::SessionProtos::_MessageRequestResponse_default_instance_._instance, - &::SessionProtos::_Content_default_instance_._instance, - &::SessionProtos::_CallMessage_default_instance_._instance, - &::SessionProtos::_KeyPair_default_instance_._instance, - &::SessionProtos::_DataExtractionNotification_default_instance_._instance, - &::SessionProtos::_LokiProfile_default_instance_._instance, - &::SessionProtos::_DataMessage_Quote_QuotedAttachment_default_instance_._instance, - &::SessionProtos::_DataMessage_Quote_default_instance_._instance, - &::SessionProtos::_DataMessage_Preview_default_instance_._instance, - &::SessionProtos::_DataMessage_Reaction_default_instance_._instance, - &::SessionProtos::_DataMessage_OpenGroupInvitation_default_instance_._instance, - &::SessionProtos::_DataMessage_default_instance_._instance, - &::SessionProtos::_ReceiptMessage_default_instance_._instance, - &::SessionProtos::_AttachmentPointer_default_instance_._instance, - &::SessionProtos::_SharedConfigMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateInviteMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdatePromoteMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateInfoChangeMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateMemberChangeMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateMemberLeftMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateMemberLeftNotificationMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateInviteResponseMessage_default_instance_._instance, - &::SessionProtos::_GroupUpdateDeleteMemberContentMessage_default_instance_._instance, - &::SessionProtos::_ProProof_default_instance_._instance, - &::SessionProtos::_ProConfig_default_instance_._instance, - &::SessionProtos::_ProMessage_default_instance_._instance, -}; - -const char descriptor_table_protodef_SessionProtos_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n\023SessionProtos.proto\022\rSessionProtos\"\340\001\n" - "\010Envelope\022*\n\004type\030\001 \002(\0162\034.SessionProtos." - "Envelope.Type\022\016\n\006source\030\002 \001(\t\022\024\n\014sourceD" - "evice\030\007 \001(\r\022\021\n\ttimestamp\030\005 \002(\004\022\017\n\007conten" - "t\030\010 \001(\014\022\027\n\017serverTimestamp\030\n \001(\004\022\016\n\006proS" - "ig\030\013 \001(\014\"5\n\004Type\022\023\n\017SESSION_MESSAGE\020\006\022\030\n" - "\024CLOSED_GROUP_MESSAGE\020\007\"{\n\rTypingMessage" - "\022\021\n\ttimestamp\030\001 \002(\004\0223\n\006action\030\002 \002(\0162#.Se" - "ssionProtos.TypingMessage.Action\"\"\n\006Acti" - "on\022\013\n\007STARTED\020\000\022\013\n\007STOPPED\020\001\"2\n\rUnsendRe" - "quest\022\021\n\ttimestamp\030\001 \002(\004\022\016\n\006author\030\002 \002(\t" - "\"m\n\026MessageRequestResponse\022\022\n\nisApproved" - "\030\001 \002(\010\022\022\n\nprofileKey\030\002 \001(\014\022+\n\007profile\030\003 " - "\001(\0132\032.SessionProtos.LokiProfile\"\315\005\n\007Cont" - "ent\022/\n\013dataMessage\030\001 \001(\0132\032.SessionProtos" - ".DataMessage\022/\n\013callMessage\030\003 \001(\0132\032.Sess" - "ionProtos.CallMessage\0225\n\016receiptMessage\030" - "\005 \001(\0132\035.SessionProtos.ReceiptMessage\0223\n\r" - "typingMessage\030\006 \001(\0132\034.SessionProtos.Typi" - "ngMessage\022M\n\032dataExtractionNotification\030" - "\010 \001(\0132).SessionProtos.DataExtractionNoti" - "fication\0223\n\runsendRequest\030\t \001(\0132\034.Sessio" - "nProtos.UnsendRequest\022E\n\026messageRequestR" - "esponse\030\n \001(\0132%.SessionProtos.MessageReq" - "uestResponse\022\?\n\023sharedConfigMessage\030\013 \001(" - "\0132\".SessionProtos.SharedConfigMessage\022=\n" - "\016expirationType\030\014 \001(\0162%.SessionProtos.Co" - "ntent.ExpirationType\022\027\n\017expirationTimer\030" - "\r \001(\r\022\024\n\014sigTimestamp\030\017 \001(\004\022-\n\nproMessag" - "e\030\020 \001(\0132\031.SessionProtos.ProMessage\"K\n\016Ex" - "pirationType\022\013\n\007UNKNOWN\020\000\022\025\n\021DELETE_AFTE" - "R_READ\020\001\022\025\n\021DELETE_AFTER_SEND\020\002\"\352\001\n\013Call" - "Message\022-\n\004type\030\001 \002(\0162\037.SessionProtos.Ca" - "llMessage.Type\022\014\n\004sdps\030\002 \003(\t\022\027\n\017sdpMLine" - "Indexes\030\003 \003(\r\022\017\n\007sdpMids\030\004 \003(\t\022\014\n\004uuid\030\005" - " \002(\t\"f\n\004Type\022\r\n\tPRE_OFFER\020\006\022\t\n\005OFFER\020\001\022\n" - "\n\006ANSWER\020\002\022\026\n\022PROVISIONAL_ANSWER\020\003\022\022\n\016IC" - "E_CANDIDATES\020\004\022\014\n\010END_CALL\020\005\"0\n\007KeyPair\022" - "\021\n\tpublicKey\030\001 \002(\014\022\022\n\nprivateKey\030\002 \002(\014\"\226" - "\001\n\032DataExtractionNotification\022<\n\004type\030\001 " - "\002(\0162..SessionProtos.DataExtractionNotifi" - "cation.Type\022\021\n\ttimestamp\030\002 \001(\004\"\'\n\004Type\022\016" - "\n\nSCREENSHOT\020\001\022\017\n\013MEDIA_SAVED\020\002\":\n\013LokiP" - "rofile\022\023\n\013displayName\030\001 \001(\t\022\026\n\016profilePi" - "cture\030\002 \001(\t\"\367\010\n\013DataMessage\022\014\n\004body\030\001 \001(" - "\t\0225\n\013attachments\030\002 \003(\0132 .SessionProtos.A" - "ttachmentPointer\022\r\n\005flags\030\004 \001(\r\022\022\n\nprofi" - "leKey\030\006 \001(\014\022\021\n\ttimestamp\030\007 \001(\004\022/\n\005quote\030" - "\010 \001(\0132 .SessionProtos.DataMessage.Quote\022" - "3\n\007preview\030\n \003(\0132\".SessionProtos.DataMes" - "sage.Preview\0225\n\010reaction\030\013 \001(\0132#.Session" - "Protos.DataMessage.Reaction\022+\n\007profile\030e" - " \001(\0132\032.SessionProtos.LokiProfile\022K\n\023open" - "GroupInvitation\030f \001(\0132..SessionProtos.Da" - "taMessage.OpenGroupInvitation\022\022\n\nsyncTar" - "get\030i \001(\t\022&\n\036blocksCommunityMessageReque" - "sts\030j \001(\010\022=\n\022groupUpdateMessage\030x \001(\0132!." - "SessionProtos.GroupUpdateMessage\032\225\002\n\005Quo" - "te\022\n\n\002id\030\001 \002(\004\022\016\n\006author\030\002 \002(\t\022\014\n\004text\030\003" - " \001(\t\022F\n\013attachments\030\004 \003(\01321.SessionProto" - "s.DataMessage.Quote.QuotedAttachment\032\231\001\n" - "\020QuotedAttachment\022\023\n\013contentType\030\001 \001(\t\022\020" - "\n\010fileName\030\002 \001(\t\0223\n\tthumbnail\030\003 \001(\0132 .Se" - "ssionProtos.AttachmentPointer\022\r\n\005flags\030\004" - " \001(\r\"\032\n\005Flags\022\021\n\rVOICE_MESSAGE\020\001\032V\n\007Prev" - "iew\022\013\n\003url\030\001 \002(\t\022\r\n\005title\030\002 \001(\t\022/\n\005image" - "\030\003 \001(\0132 .SessionProtos.AttachmentPointer" - "\032\222\001\n\010Reaction\022\n\n\002id\030\001 \002(\004\022\016\n\006author\030\002 \002(" - "\t\022\r\n\005emoji\030\003 \001(\t\022:\n\006action\030\004 \002(\0162*.Sessi" - "onProtos.DataMessage.Reaction.Action\"\037\n\006" - "Action\022\t\n\005REACT\020\000\022\n\n\006REMOVE\020\001\0320\n\023OpenGro" - "upInvitation\022\013\n\003url\030\001 \002(\t\022\014\n\004name\030\003 \002(\t\"" - "$\n\005Flags\022\033\n\027EXPIRATION_TIMER_UPDATE\020\002\"u\n" - "\016ReceiptMessage\0220\n\004type\030\001 \002(\0162\".SessionP" - "rotos.ReceiptMessage.Type\022\021\n\ttimestamp\030\002" - " \003(\004\"\036\n\004Type\022\014\n\010DELIVERY\020\000\022\010\n\004READ\020\001\"\354\001\n" - "\021AttachmentPointer\022\n\n\002id\030\001 \002(\006\022\023\n\013conten" - "tType\030\002 \001(\t\022\013\n\003key\030\003 \001(\014\022\014\n\004size\030\004 \001(\r\022\021" - "\n\tthumbnail\030\005 \001(\014\022\016\n\006digest\030\006 \001(\014\022\020\n\010fil" - "eName\030\007 \001(\t\022\r\n\005flags\030\010 \001(\r\022\r\n\005width\030\t \001(" - "\r\022\016\n\006height\030\n \001(\r\022\017\n\007caption\030\013 \001(\t\022\013\n\003ur" - "l\030e \001(\t\"\032\n\005Flags\022\021\n\rVOICE_MESSAGE\020\001\"\273\001\n\023" - "SharedConfigMessage\0225\n\004kind\030\001 \002(\0162\'.Sess" - "ionProtos.SharedConfigMessage.Kind\022\r\n\005se" - "qno\030\002 \002(\003\022\014\n\004data\030\003 \002(\014\"P\n\004Kind\022\020\n\014USER_" - "PROFILE\020\001\022\014\n\010CONTACTS\020\002\022\027\n\023CONVO_INFO_VO" - "LATILE\020\003\022\017\n\013USER_GROUPS\020\004\"\356\004\n\022GroupUpdat" - "eMessage\022>\n\rinviteMessage\030\001 \001(\0132\'.Sessio" - "nProtos.GroupUpdateInviteMessage\022F\n\021info" - "ChangeMessage\030\002 \001(\0132+.SessionProtos.Grou" - "pUpdateInfoChangeMessage\022J\n\023memberChange" - "Message\030\003 \001(\0132-.SessionProtos.GroupUpdat" - "eMemberChangeMessage\022@\n\016promoteMessage\030\004" - " \001(\0132(.SessionProtos.GroupUpdatePromoteM" - "essage\022F\n\021memberLeftMessage\030\005 \001(\0132+.Sess" - "ionProtos.GroupUpdateMemberLeftMessage\022G" - "\n\016inviteResponse\030\006 \001(\0132/.SessionProtos.G" - "roupUpdateInviteResponseMessage\022Q\n\023delet" - "eMemberContent\030\007 \001(\01324.SessionProtos.Gro" - "upUpdateDeleteMemberContentMessage\022^\n\035me" - "mberLeftNotificationMessage\030\010 \001(\01327.Sess" - "ionProtos.GroupUpdateMemberLeftNotificat" - "ionMessage\"p\n\030GroupUpdateInviteMessage\022\026" - "\n\016groupSessionId\030\001 \002(\t\022\014\n\004name\030\002 \002(\t\022\026\n\016" - "memberAuthData\030\003 \002(\014\022\026\n\016adminSignature\030\004" - " \002(\014\"D\n\031GroupUpdatePromoteMessage\022\031\n\021gro" - "upIdentitySeed\030\001 \002(\014\022\014\n\004name\030\002 \002(\t\"\337\001\n\034G" - "roupUpdateInfoChangeMessage\022>\n\004type\030\001 \002(" - "\01620.SessionProtos.GroupUpdateInfoChangeM" - "essage.Type\022\023\n\013updatedName\030\002 \001(\t\022\031\n\021upda" - "tedExpiration\030\003 \001(\r\022\026\n\016adminSignature\030\004 " - "\002(\014\"7\n\004Type\022\010\n\004NAME\020\001\022\n\n\006AVATAR\020\002\022\031\n\025DIS" - "APPEARING_MESSAGES\020\003\"\331\001\n\036GroupUpdateMemb" - "erChangeMessage\022@\n\004type\030\001 \002(\01622.SessionP" - "rotos.GroupUpdateMemberChangeMessage.Typ" - "e\022\030\n\020memberSessionIds\030\002 \003(\t\022\025\n\rhistorySh" - "ared\030\003 \001(\010\022\026\n\016adminSignature\030\004 \002(\014\",\n\004Ty" - "pe\022\t\n\005ADDED\020\001\022\013\n\007REMOVED\020\002\022\014\n\010PROMOTED\020\003" - "\"\036\n\034GroupUpdateMemberLeftMessage\"*\n(Grou" - "pUpdateMemberLeftNotificationMessage\"6\n " - "GroupUpdateInviteResponseMessage\022\022\n\nisAp" - "proved\030\001 \002(\010\"p\n%GroupUpdateDeleteMemberC" - "ontentMessage\022\030\n\020memberSessionIds\030\001 \003(\t\022" - "\025\n\rmessageHashes\030\002 \003(\t\022\026\n\016adminSignature" - "\030\003 \001(\014\"o\n\010ProProof\022\017\n\007version\030\001 \002(\r\022\024\n\014g" - "enIndexHash\030\002 \002(\014\022\031\n\021rotatingPublicKey\030\003" - " \002(\014\022\024\n\014expiryUnixTs\030\004 \002(\004\022\013\n\003sig\030\005 \002(\014\"" - "L\n\tProConfig\022\027\n\017rotatingPrivKey\030\001 \002(\014\022&\n" - "\005proof\030\002 \002(\0132\027.SessionProtos.ProProof\"C\n" - "\nProMessage\022&\n\005proof\030\001 \002(\0132\027.SessionProt" - "os.ProProof\022\r\n\005flags\030\002 \002(\r" - ; -static ::_pbi::once_flag descriptor_table_SessionProtos_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_SessionProtos_2eproto = { - false, false, 5226, descriptor_table_protodef_SessionProtos_2eproto, - "SessionProtos.proto", - &descriptor_table_SessionProtos_2eproto_once, nullptr, 0, 30, - schemas, file_default_instances, TableStruct_SessionProtos_2eproto::offsets, - file_level_metadata_SessionProtos_2eproto, file_level_enum_descriptors_SessionProtos_2eproto, - file_level_service_descriptors_SessionProtos_2eproto, -}; -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_SessionProtos_2eproto_getter() { - return &descriptor_table_SessionProtos_2eproto; -} - -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_SessionProtos_2eproto(&descriptor_table_SessionProtos_2eproto); namespace SessionProtos { -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Envelope_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[0]; -} bool Envelope_Type_IsValid(int value) { switch (value) { case 6: @@ -1180,6 +522,47 @@ bool Envelope_Type_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed Envelope_Type_strings[2] = {}; + +static const char Envelope_Type_names[] = + "CLOSED_GROUP_MESSAGE" + "SESSION_MESSAGE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry Envelope_Type_entries[] = { + { {Envelope_Type_names + 0, 20}, 7 }, + { {Envelope_Type_names + 20, 15}, 6 }, +}; + +static const int Envelope_Type_entries_by_number[] = { + 1, // 6 -> SESSION_MESSAGE + 0, // 7 -> CLOSED_GROUP_MESSAGE +}; + +const std::string& Envelope_Type_Name( + Envelope_Type value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + Envelope_Type_entries, + Envelope_Type_entries_by_number, + 2, Envelope_Type_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + Envelope_Type_entries, + Envelope_Type_entries_by_number, + 2, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + Envelope_Type_strings[idx].get(); +} +bool Envelope_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Envelope_Type* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + Envelope_Type_entries, 2, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr Envelope_Type Envelope::SESSION_MESSAGE; constexpr Envelope_Type Envelope::CLOSED_GROUP_MESSAGE; @@ -1187,10 +570,6 @@ constexpr Envelope_Type Envelope::Type_MIN; constexpr Envelope_Type Envelope::Type_MAX; constexpr int Envelope::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* TypingMessage_Action_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[1]; -} bool TypingMessage_Action_IsValid(int value) { switch (value) { case 0: @@ -1201,6 +580,47 @@ bool TypingMessage_Action_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed TypingMessage_Action_strings[2] = {}; + +static const char TypingMessage_Action_names[] = + "STARTED" + "STOPPED"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry TypingMessage_Action_entries[] = { + { {TypingMessage_Action_names + 0, 7}, 0 }, + { {TypingMessage_Action_names + 7, 7}, 1 }, +}; + +static const int TypingMessage_Action_entries_by_number[] = { + 0, // 0 -> STARTED + 1, // 1 -> STOPPED +}; + +const std::string& TypingMessage_Action_Name( + TypingMessage_Action value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + TypingMessage_Action_entries, + TypingMessage_Action_entries_by_number, + 2, TypingMessage_Action_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + TypingMessage_Action_entries, + TypingMessage_Action_entries_by_number, + 2, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + TypingMessage_Action_strings[idx].get(); +} +bool TypingMessage_Action_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, TypingMessage_Action* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + TypingMessage_Action_entries, 2, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr TypingMessage_Action TypingMessage::STARTED; constexpr TypingMessage_Action TypingMessage::STOPPED; @@ -1208,10 +628,6 @@ constexpr TypingMessage_Action TypingMessage::Action_MIN; constexpr TypingMessage_Action TypingMessage::Action_MAX; constexpr int TypingMessage::Action_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Content_ExpirationType_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[2]; -} bool Content_ExpirationType_IsValid(int value) { switch (value) { case 0: @@ -1223,6 +639,50 @@ bool Content_ExpirationType_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed Content_ExpirationType_strings[3] = {}; + +static const char Content_ExpirationType_names[] = + "DELETE_AFTER_READ" + "DELETE_AFTER_SEND" + "UNKNOWN"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry Content_ExpirationType_entries[] = { + { {Content_ExpirationType_names + 0, 17}, 1 }, + { {Content_ExpirationType_names + 17, 17}, 2 }, + { {Content_ExpirationType_names + 34, 7}, 0 }, +}; + +static const int Content_ExpirationType_entries_by_number[] = { + 2, // 0 -> UNKNOWN + 0, // 1 -> DELETE_AFTER_READ + 1, // 2 -> DELETE_AFTER_SEND +}; + +const std::string& Content_ExpirationType_Name( + Content_ExpirationType value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + Content_ExpirationType_entries, + Content_ExpirationType_entries_by_number, + 3, Content_ExpirationType_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + Content_ExpirationType_entries, + Content_ExpirationType_entries_by_number, + 3, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + Content_ExpirationType_strings[idx].get(); +} +bool Content_ExpirationType_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Content_ExpirationType* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + Content_ExpirationType_entries, 3, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr Content_ExpirationType Content::UNKNOWN; constexpr Content_ExpirationType Content::DELETE_AFTER_READ; @@ -1231,10 +691,6 @@ constexpr Content_ExpirationType Content::ExpirationType_MIN; constexpr Content_ExpirationType Content::ExpirationType_MAX; constexpr int Content::ExpirationType_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CallMessage_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[3]; -} bool CallMessage_Type_IsValid(int value) { switch (value) { case 1: @@ -1249,6 +705,59 @@ bool CallMessage_Type_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed CallMessage_Type_strings[6] = {}; + +static const char CallMessage_Type_names[] = + "ANSWER" + "END_CALL" + "ICE_CANDIDATES" + "OFFER" + "PRE_OFFER" + "PROVISIONAL_ANSWER"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry CallMessage_Type_entries[] = { + { {CallMessage_Type_names + 0, 6}, 2 }, + { {CallMessage_Type_names + 6, 8}, 5 }, + { {CallMessage_Type_names + 14, 14}, 4 }, + { {CallMessage_Type_names + 28, 5}, 1 }, + { {CallMessage_Type_names + 33, 9}, 6 }, + { {CallMessage_Type_names + 42, 18}, 3 }, +}; + +static const int CallMessage_Type_entries_by_number[] = { + 3, // 1 -> OFFER + 0, // 2 -> ANSWER + 5, // 3 -> PROVISIONAL_ANSWER + 2, // 4 -> ICE_CANDIDATES + 1, // 5 -> END_CALL + 4, // 6 -> PRE_OFFER +}; + +const std::string& CallMessage_Type_Name( + CallMessage_Type value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + CallMessage_Type_entries, + CallMessage_Type_entries_by_number, + 6, CallMessage_Type_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + CallMessage_Type_entries, + CallMessage_Type_entries_by_number, + 6, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + CallMessage_Type_strings[idx].get(); +} +bool CallMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CallMessage_Type* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + CallMessage_Type_entries, 6, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr CallMessage_Type CallMessage::PRE_OFFER; constexpr CallMessage_Type CallMessage::OFFER; @@ -1260,10 +769,6 @@ constexpr CallMessage_Type CallMessage::Type_MIN; constexpr CallMessage_Type CallMessage::Type_MAX; constexpr int CallMessage::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataExtractionNotification_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[4]; -} bool DataExtractionNotification_Type_IsValid(int value) { switch (value) { case 1: @@ -1274,6 +779,47 @@ bool DataExtractionNotification_Type_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataExtractionNotification_Type_strings[2] = {}; + +static const char DataExtractionNotification_Type_names[] = + "MEDIA_SAVED" + "SCREENSHOT"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataExtractionNotification_Type_entries[] = { + { {DataExtractionNotification_Type_names + 0, 11}, 2 }, + { {DataExtractionNotification_Type_names + 11, 10}, 1 }, +}; + +static const int DataExtractionNotification_Type_entries_by_number[] = { + 1, // 1 -> SCREENSHOT + 0, // 2 -> MEDIA_SAVED +}; + +const std::string& DataExtractionNotification_Type_Name( + DataExtractionNotification_Type value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + DataExtractionNotification_Type_entries, + DataExtractionNotification_Type_entries_by_number, + 2, DataExtractionNotification_Type_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + DataExtractionNotification_Type_entries, + DataExtractionNotification_Type_entries_by_number, + 2, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + DataExtractionNotification_Type_strings[idx].get(); +} +bool DataExtractionNotification_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataExtractionNotification_Type* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + DataExtractionNotification_Type_entries, 2, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataExtractionNotification_Type DataExtractionNotification::SCREENSHOT; constexpr DataExtractionNotification_Type DataExtractionNotification::MEDIA_SAVED; @@ -1281,10 +827,6 @@ constexpr DataExtractionNotification_Type DataExtractionNotification::Type_MIN; constexpr DataExtractionNotification_Type DataExtractionNotification::Type_MAX; constexpr int DataExtractionNotification::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Quote_QuotedAttachment_Flags_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[5]; -} bool DataMessage_Quote_QuotedAttachment_Flags_IsValid(int value) { switch (value) { case 1: @@ -1294,16 +836,50 @@ bool DataMessage_Quote_QuotedAttachment_Flags_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_Quote_QuotedAttachment_Flags_strings[1] = {}; + +static const char DataMessage_Quote_QuotedAttachment_Flags_names[] = + "VOICE_MESSAGE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_Quote_QuotedAttachment_Flags_entries[] = { + { {DataMessage_Quote_QuotedAttachment_Flags_names + 0, 13}, 1 }, +}; + +static const int DataMessage_Quote_QuotedAttachment_Flags_entries_by_number[] = { + 0, // 1 -> VOICE_MESSAGE +}; + +const std::string& DataMessage_Quote_QuotedAttachment_Flags_Name( + DataMessage_Quote_QuotedAttachment_Flags value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + DataMessage_Quote_QuotedAttachment_Flags_entries, + DataMessage_Quote_QuotedAttachment_Flags_entries_by_number, + 1, DataMessage_Quote_QuotedAttachment_Flags_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + DataMessage_Quote_QuotedAttachment_Flags_entries, + DataMessage_Quote_QuotedAttachment_Flags_entries_by_number, + 1, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + DataMessage_Quote_QuotedAttachment_Flags_strings[idx].get(); +} +bool DataMessage_Quote_QuotedAttachment_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Quote_QuotedAttachment_Flags* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + DataMessage_Quote_QuotedAttachment_Flags_entries, 1, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment::VOICE_MESSAGE; constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment::Flags_MIN; constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment::Flags_MAX; constexpr int DataMessage_Quote_QuotedAttachment::Flags_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Reaction_Action_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[6]; -} bool DataMessage_Reaction_Action_IsValid(int value) { switch (value) { case 0: @@ -1314,6 +890,47 @@ bool DataMessage_Reaction_Action_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_Reaction_Action_strings[2] = {}; + +static const char DataMessage_Reaction_Action_names[] = + "REACT" + "REMOVE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_Reaction_Action_entries[] = { + { {DataMessage_Reaction_Action_names + 0, 5}, 0 }, + { {DataMessage_Reaction_Action_names + 5, 6}, 1 }, +}; + +static const int DataMessage_Reaction_Action_entries_by_number[] = { + 0, // 0 -> REACT + 1, // 1 -> REMOVE +}; + +const std::string& DataMessage_Reaction_Action_Name( + DataMessage_Reaction_Action value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + DataMessage_Reaction_Action_entries, + DataMessage_Reaction_Action_entries_by_number, + 2, DataMessage_Reaction_Action_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + DataMessage_Reaction_Action_entries, + DataMessage_Reaction_Action_entries_by_number, + 2, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + DataMessage_Reaction_Action_strings[idx].get(); +} +bool DataMessage_Reaction_Action_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Reaction_Action* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + DataMessage_Reaction_Action_entries, 2, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataMessage_Reaction_Action DataMessage_Reaction::REACT; constexpr DataMessage_Reaction_Action DataMessage_Reaction::REMOVE; @@ -1321,10 +938,6 @@ constexpr DataMessage_Reaction_Action DataMessage_Reaction::Action_MIN; constexpr DataMessage_Reaction_Action DataMessage_Reaction::Action_MAX; constexpr int DataMessage_Reaction::Action_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Flags_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[7]; -} bool DataMessage_Flags_IsValid(int value) { switch (value) { case 2: @@ -1334,16 +947,50 @@ bool DataMessage_Flags_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed DataMessage_Flags_strings[1] = {}; + +static const char DataMessage_Flags_names[] = + "EXPIRATION_TIMER_UPDATE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DataMessage_Flags_entries[] = { + { {DataMessage_Flags_names + 0, 23}, 2 }, +}; + +static const int DataMessage_Flags_entries_by_number[] = { + 0, // 2 -> EXPIRATION_TIMER_UPDATE +}; + +const std::string& DataMessage_Flags_Name( + DataMessage_Flags value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + DataMessage_Flags_entries, + DataMessage_Flags_entries_by_number, + 1, DataMessage_Flags_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + DataMessage_Flags_entries, + DataMessage_Flags_entries_by_number, + 1, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + DataMessage_Flags_strings[idx].get(); +} +bool DataMessage_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Flags* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + DataMessage_Flags_entries, 1, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr DataMessage_Flags DataMessage::EXPIRATION_TIMER_UPDATE; constexpr DataMessage_Flags DataMessage::Flags_MIN; constexpr DataMessage_Flags DataMessage::Flags_MAX; constexpr int DataMessage::Flags_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ReceiptMessage_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[8]; -} bool ReceiptMessage_Type_IsValid(int value) { switch (value) { case 0: @@ -1354,6 +1001,47 @@ bool ReceiptMessage_Type_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed ReceiptMessage_Type_strings[2] = {}; + +static const char ReceiptMessage_Type_names[] = + "DELIVERY" + "READ"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry ReceiptMessage_Type_entries[] = { + { {ReceiptMessage_Type_names + 0, 8}, 0 }, + { {ReceiptMessage_Type_names + 8, 4}, 1 }, +}; + +static const int ReceiptMessage_Type_entries_by_number[] = { + 0, // 0 -> DELIVERY + 1, // 1 -> READ +}; + +const std::string& ReceiptMessage_Type_Name( + ReceiptMessage_Type value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + ReceiptMessage_Type_entries, + ReceiptMessage_Type_entries_by_number, + 2, ReceiptMessage_Type_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + ReceiptMessage_Type_entries, + ReceiptMessage_Type_entries_by_number, + 2, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + ReceiptMessage_Type_strings[idx].get(); +} +bool ReceiptMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceiptMessage_Type* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + ReceiptMessage_Type_entries, 2, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr ReceiptMessage_Type ReceiptMessage::DELIVERY; constexpr ReceiptMessage_Type ReceiptMessage::READ; @@ -1361,10 +1049,6 @@ constexpr ReceiptMessage_Type ReceiptMessage::Type_MIN; constexpr ReceiptMessage_Type ReceiptMessage::Type_MAX; constexpr int ReceiptMessage::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttachmentPointer_Flags_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[9]; -} bool AttachmentPointer_Flags_IsValid(int value) { switch (value) { case 1: @@ -1374,16 +1058,50 @@ bool AttachmentPointer_Flags_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed AttachmentPointer_Flags_strings[1] = {}; + +static const char AttachmentPointer_Flags_names[] = + "VOICE_MESSAGE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry AttachmentPointer_Flags_entries[] = { + { {AttachmentPointer_Flags_names + 0, 13}, 1 }, +}; + +static const int AttachmentPointer_Flags_entries_by_number[] = { + 0, // 1 -> VOICE_MESSAGE +}; + +const std::string& AttachmentPointer_Flags_Name( + AttachmentPointer_Flags value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + AttachmentPointer_Flags_entries, + AttachmentPointer_Flags_entries_by_number, + 1, AttachmentPointer_Flags_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + AttachmentPointer_Flags_entries, + AttachmentPointer_Flags_entries_by_number, + 1, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + AttachmentPointer_Flags_strings[idx].get(); +} +bool AttachmentPointer_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttachmentPointer_Flags* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + AttachmentPointer_Flags_entries, 1, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr AttachmentPointer_Flags AttachmentPointer::VOICE_MESSAGE; constexpr AttachmentPointer_Flags AttachmentPointer::Flags_MIN; constexpr AttachmentPointer_Flags AttachmentPointer::Flags_MAX; constexpr int AttachmentPointer::Flags_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* SharedConfigMessage_Kind_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[10]; -} bool SharedConfigMessage_Kind_IsValid(int value) { switch (value) { case 1: @@ -1396,6 +1114,53 @@ bool SharedConfigMessage_Kind_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed SharedConfigMessage_Kind_strings[4] = {}; + +static const char SharedConfigMessage_Kind_names[] = + "CONTACTS" + "CONVO_INFO_VOLATILE" + "USER_GROUPS" + "USER_PROFILE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry SharedConfigMessage_Kind_entries[] = { + { {SharedConfigMessage_Kind_names + 0, 8}, 2 }, + { {SharedConfigMessage_Kind_names + 8, 19}, 3 }, + { {SharedConfigMessage_Kind_names + 27, 11}, 4 }, + { {SharedConfigMessage_Kind_names + 38, 12}, 1 }, +}; + +static const int SharedConfigMessage_Kind_entries_by_number[] = { + 3, // 1 -> USER_PROFILE + 0, // 2 -> CONTACTS + 1, // 3 -> CONVO_INFO_VOLATILE + 2, // 4 -> USER_GROUPS +}; + +const std::string& SharedConfigMessage_Kind_Name( + SharedConfigMessage_Kind value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + SharedConfigMessage_Kind_entries, + SharedConfigMessage_Kind_entries_by_number, + 4, SharedConfigMessage_Kind_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + SharedConfigMessage_Kind_entries, + SharedConfigMessage_Kind_entries_by_number, + 4, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + SharedConfigMessage_Kind_strings[idx].get(); +} +bool SharedConfigMessage_Kind_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SharedConfigMessage_Kind* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + SharedConfigMessage_Kind_entries, 4, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr SharedConfigMessage_Kind SharedConfigMessage::USER_PROFILE; constexpr SharedConfigMessage_Kind SharedConfigMessage::CONTACTS; @@ -1405,10 +1170,6 @@ constexpr SharedConfigMessage_Kind SharedConfigMessage::Kind_MIN; constexpr SharedConfigMessage_Kind SharedConfigMessage::Kind_MAX; constexpr int SharedConfigMessage::Kind_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateInfoChangeMessage_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[11]; -} bool GroupUpdateInfoChangeMessage_Type_IsValid(int value) { switch (value) { case 1: @@ -1420,6 +1181,50 @@ bool GroupUpdateInfoChangeMessage_Type_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed GroupUpdateInfoChangeMessage_Type_strings[3] = {}; + +static const char GroupUpdateInfoChangeMessage_Type_names[] = + "AVATAR" + "DISAPPEARING_MESSAGES" + "NAME"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry GroupUpdateInfoChangeMessage_Type_entries[] = { + { {GroupUpdateInfoChangeMessage_Type_names + 0, 6}, 2 }, + { {GroupUpdateInfoChangeMessage_Type_names + 6, 21}, 3 }, + { {GroupUpdateInfoChangeMessage_Type_names + 27, 4}, 1 }, +}; + +static const int GroupUpdateInfoChangeMessage_Type_entries_by_number[] = { + 2, // 1 -> NAME + 0, // 2 -> AVATAR + 1, // 3 -> DISAPPEARING_MESSAGES +}; + +const std::string& GroupUpdateInfoChangeMessage_Type_Name( + GroupUpdateInfoChangeMessage_Type value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + GroupUpdateInfoChangeMessage_Type_entries, + GroupUpdateInfoChangeMessage_Type_entries_by_number, + 3, GroupUpdateInfoChangeMessage_Type_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + GroupUpdateInfoChangeMessage_Type_entries, + GroupUpdateInfoChangeMessage_Type_entries_by_number, + 3, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + GroupUpdateInfoChangeMessage_Type_strings[idx].get(); +} +bool GroupUpdateInfoChangeMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateInfoChangeMessage_Type* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + GroupUpdateInfoChangeMessage_Type_entries, 3, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::NAME; constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::AVATAR; @@ -1428,10 +1233,6 @@ constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::Type_M constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage::Type_MAX; constexpr int GroupUpdateInfoChangeMessage::Type_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateMemberChangeMessage_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_SessionProtos_2eproto); - return file_level_enum_descriptors_SessionProtos_2eproto[12]; -} bool GroupUpdateMemberChangeMessage_Type_IsValid(int value) { switch (value) { case 1: @@ -1443,6 +1244,50 @@ bool GroupUpdateMemberChangeMessage_Type_IsValid(int value) { } } +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed GroupUpdateMemberChangeMessage_Type_strings[3] = {}; + +static const char GroupUpdateMemberChangeMessage_Type_names[] = + "ADDED" + "PROMOTED" + "REMOVED"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry GroupUpdateMemberChangeMessage_Type_entries[] = { + { {GroupUpdateMemberChangeMessage_Type_names + 0, 5}, 1 }, + { {GroupUpdateMemberChangeMessage_Type_names + 5, 8}, 3 }, + { {GroupUpdateMemberChangeMessage_Type_names + 13, 7}, 2 }, +}; + +static const int GroupUpdateMemberChangeMessage_Type_entries_by_number[] = { + 0, // 1 -> ADDED + 2, // 2 -> REMOVED + 1, // 3 -> PROMOTED +}; + +const std::string& GroupUpdateMemberChangeMessage_Type_Name( + GroupUpdateMemberChangeMessage_Type value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + GroupUpdateMemberChangeMessage_Type_entries, + GroupUpdateMemberChangeMessage_Type_entries_by_number, + 3, GroupUpdateMemberChangeMessage_Type_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + GroupUpdateMemberChangeMessage_Type_entries, + GroupUpdateMemberChangeMessage_Type_entries_by_number, + 3, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + GroupUpdateMemberChangeMessage_Type_strings[idx].get(); +} +bool GroupUpdateMemberChangeMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateMemberChangeMessage_Type* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + GroupUpdateMemberChangeMessage_Type_entries, 3, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::ADDED; constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage::REMOVED; @@ -1485,12 +1330,12 @@ class Envelope::_Internal { Envelope::Envelope(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.Envelope) } Envelope::Envelope(const Envelope& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { Envelope* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -1503,7 +1348,7 @@ Envelope::Envelope(const Envelope& from) , decltype(_impl_.sourcedevice_){} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.source_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.source_.Set("", GetArenaForAllocation()); @@ -1565,7 +1410,7 @@ inline void Envelope::SharedCtor( Envelope::~Envelope() { // @@protoc_insertion_point(destructor:SessionProtos.Envelope) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -1608,7 +1453,7 @@ void Envelope::Clear() { _impl_.type_ = 6; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -1637,9 +1482,6 @@ const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) auto str = _internal_mutable_source(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.Envelope.source"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1699,7 +1541,7 @@ const char* Envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -1728,10 +1570,6 @@ uint8_t* Envelope::_InternalSerialize( // optional string source = 2; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_source().data(), static_cast(this->_internal_source().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.Envelope.source"); target = stream->WriteStringMaybeAliased( 2, this->_internal_source(), target); } @@ -1767,8 +1605,8 @@ uint8_t* Envelope::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Envelope) return target; @@ -1846,19 +1684,22 @@ size_t Envelope::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Envelope::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Envelope::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Envelope::GetClassData() const { return &_class_data_; } - +void Envelope::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void Envelope::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void Envelope::MergeFrom(const Envelope& from) { + Envelope* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Envelope) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -1889,7 +1730,7 @@ void Envelope::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTO } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void Envelope::CopyFrom(const Envelope& from) { @@ -1931,12 +1772,11 @@ void Envelope::InternalSwap(Envelope* other) { swap(_impl_.type_, other->_impl_.type_); } -::PROTOBUF_NAMESPACE_ID::Metadata Envelope::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[0]); +std::string Envelope::GetTypeName() const { + return "SessionProtos.Envelope"; } + // =================================================================== class TypingMessage::_Internal { @@ -1955,12 +1795,12 @@ class TypingMessage::_Internal { TypingMessage::TypingMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.TypingMessage) } TypingMessage::TypingMessage(const TypingMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { TypingMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -1968,7 +1808,7 @@ TypingMessage::TypingMessage(const TypingMessage& from) , decltype(_impl_.timestamp_){} , decltype(_impl_.action_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, static_cast(reinterpret_cast(&_impl_.action_) - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.action_)); @@ -1989,7 +1829,7 @@ inline void TypingMessage::SharedCtor( TypingMessage::~TypingMessage() { // @@protoc_insertion_point(destructor:SessionProtos.TypingMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -2017,7 +1857,7 @@ void TypingMessage::Clear() { reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.action_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* TypingMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -2060,7 +1900,7 @@ const char* TypingMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -2094,8 +1934,8 @@ uint8_t* TypingMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.TypingMessage) return target; @@ -2137,19 +1977,22 @@ size_t TypingMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData TypingMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - TypingMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*TypingMessage::GetClassData() const { return &_class_data_; } - +void TypingMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void TypingMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void TypingMessage::MergeFrom(const TypingMessage& from) { + TypingMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.TypingMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -2165,7 +2008,7 @@ void TypingMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :: } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void TypingMessage::CopyFrom(const TypingMessage& from) { @@ -2192,12 +2035,11 @@ void TypingMessage::InternalSwap(TypingMessage* other) { reinterpret_cast(&other->_impl_.timestamp_)); } -::PROTOBUF_NAMESPACE_ID::Metadata TypingMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[1]); +std::string TypingMessage::GetTypeName() const { + return "SessionProtos.TypingMessage"; } + // =================================================================== class UnsendRequest::_Internal { @@ -2216,12 +2058,12 @@ class UnsendRequest::_Internal { UnsendRequest::UnsendRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.UnsendRequest) } UnsendRequest::UnsendRequest(const UnsendRequest& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { UnsendRequest* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -2229,7 +2071,7 @@ UnsendRequest::UnsendRequest(const UnsendRequest& from) , decltype(_impl_.author_){} , decltype(_impl_.timestamp_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.author_.Set("", GetArenaForAllocation()); @@ -2260,7 +2102,7 @@ inline void UnsendRequest::SharedCtor( UnsendRequest::~UnsendRequest() { // @@protoc_insertion_point(destructor:SessionProtos.UnsendRequest) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -2288,7 +2130,7 @@ void UnsendRequest::Clear() { } _impl_.timestamp_ = uint64_t{0u}; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* UnsendRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -2313,9 +2155,6 @@ const char* UnsendRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.UnsendRequest.author"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -2330,7 +2169,7 @@ const char* UnsendRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -2358,17 +2197,13 @@ uint8_t* UnsendRequest::_InternalSerialize( // required string author = 2; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_author().data(), static_cast(this->_internal_author().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.UnsendRequest.author"); target = stream->WriteStringMaybeAliased( 2, this->_internal_author(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.UnsendRequest) return target; @@ -2412,19 +2247,22 @@ size_t UnsendRequest::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData UnsendRequest::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - UnsendRequest::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UnsendRequest::GetClassData() const { return &_class_data_; } - +void UnsendRequest::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void UnsendRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void UnsendRequest::MergeFrom(const UnsendRequest& from) { + UnsendRequest* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.UnsendRequest) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -2440,7 +2278,7 @@ void UnsendRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :: } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void UnsendRequest::CopyFrom(const UnsendRequest& from) { @@ -2468,12 +2306,11 @@ void UnsendRequest::InternalSwap(UnsendRequest* other) { swap(_impl_.timestamp_, other->_impl_.timestamp_); } -::PROTOBUF_NAMESPACE_ID::Metadata UnsendRequest::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[2]); +std::string UnsendRequest::GetTypeName() const { + return "SessionProtos.UnsendRequest"; } + // =================================================================== class MessageRequestResponse::_Internal { @@ -2500,12 +2337,12 @@ MessageRequestResponse::_Internal::profile(const MessageRequestResponse* msg) { } MessageRequestResponse::MessageRequestResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.MessageRequestResponse) } MessageRequestResponse::MessageRequestResponse(const MessageRequestResponse& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { MessageRequestResponse* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -2514,7 +2351,7 @@ MessageRequestResponse::MessageRequestResponse(const MessageRequestResponse& fro , decltype(_impl_.profile_){nullptr} , decltype(_impl_.isapproved_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.profilekey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.profilekey_.Set("", GetArenaForAllocation()); @@ -2549,7 +2386,7 @@ inline void MessageRequestResponse::SharedCtor( MessageRequestResponse::~MessageRequestResponse() { // @@protoc_insertion_point(destructor:SessionProtos.MessageRequestResponse) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -2584,7 +2421,7 @@ void MessageRequestResponse::Clear() { } _impl_.isapproved_ = false; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* MessageRequestResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -2631,7 +2468,7 @@ const char* MessageRequestResponse::_InternalParse(const char* ptr, ::_pbi::Pars } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -2671,8 +2508,8 @@ uint8_t* MessageRequestResponse::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.MessageRequestResponse) return target; @@ -2707,19 +2544,22 @@ size_t MessageRequestResponse::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData MessageRequestResponse::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - MessageRequestResponse::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MessageRequestResponse::GetClassData() const { return &_class_data_; } - +void MessageRequestResponse::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void MessageRequestResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void MessageRequestResponse::MergeFrom(const MessageRequestResponse& from) { + MessageRequestResponse* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.MessageRequestResponse) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -2739,7 +2579,7 @@ void MessageRequestResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void MessageRequestResponse::CopyFrom(const MessageRequestResponse& from) { @@ -2772,12 +2612,11 @@ void MessageRequestResponse::InternalSwap(MessageRequestResponse* other) { reinterpret_cast(&other->_impl_.profile_)); } -::PROTOBUF_NAMESPACE_ID::Metadata MessageRequestResponse::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[3]); +std::string MessageRequestResponse::GetTypeName() const { + return "SessionProtos.MessageRequestResponse"; } + // =================================================================== class Content::_Internal { @@ -2868,12 +2707,12 @@ Content::_Internal::promessage(const Content* msg) { } Content::Content(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.Content) } Content::Content(const Content& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { Content* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -2891,7 +2730,7 @@ Content::Content(const Content& from) , decltype(_impl_.expirationtimer_){} , decltype(_impl_.sigtimestamp_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from._internal_has_datamessage()) { _this->_impl_.datamessage_ = new ::SessionProtos::DataMessage(*from._impl_.datamessage_); } @@ -2949,7 +2788,7 @@ inline void Content::SharedCtor( Content::~Content() { // @@protoc_insertion_point(destructor:SessionProtos.Content) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -3024,7 +2863,7 @@ void Content::Clear() { reinterpret_cast(&_impl_.expirationtype_)) + sizeof(_impl_.sigtimestamp_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -3148,7 +2987,7 @@ const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -3251,8 +3090,8 @@ uint8_t* Content::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.Content) return target; @@ -3350,19 +3189,22 @@ size_t Content::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Content::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Content::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Content::GetClassData() const { return &_class_data_; } - +void Content::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void Content::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void Content::MergeFrom(const Content& from) { + Content* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.Content) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -3419,7 +3261,7 @@ void Content::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void Content::CopyFrom(const Content& from) { @@ -3472,12 +3314,11 @@ void Content::InternalSwap(Content* other) { reinterpret_cast(&other->_impl_.datamessage_)); } -::PROTOBUF_NAMESPACE_ID::Metadata Content::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[4]); +std::string Content::GetTypeName() const { + return "SessionProtos.Content"; } + // =================================================================== class CallMessage::_Internal { @@ -3496,12 +3337,12 @@ class CallMessage::_Internal { CallMessage::CallMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.CallMessage) } CallMessage::CallMessage(const CallMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { CallMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -3512,7 +3353,7 @@ CallMessage::CallMessage(const CallMessage& from) , decltype(_impl_.uuid_){} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.uuid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.uuid_.Set("", GetArenaForAllocation()); @@ -3546,7 +3387,7 @@ inline void CallMessage::SharedCtor( CallMessage::~CallMessage() { // @@protoc_insertion_point(destructor:SessionProtos.CallMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -3582,7 +3423,7 @@ void CallMessage::Clear() { _impl_.type_ = 6; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -3614,9 +3455,6 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_add_sdps(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.CallMessage.sdps"); - #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else @@ -3647,9 +3485,6 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_add_sdpmids(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.CallMessage.sdpMids"); - #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else @@ -3661,9 +3496,6 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_mutable_uuid(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.CallMessage.uuid"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -3678,7 +3510,7 @@ const char* CallMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -3708,10 +3540,6 @@ uint8_t* CallMessage::_InternalSerialize( // repeated string sdps = 2; for (int i = 0, n = this->_internal_sdps_size(); i < n; i++) { const auto& s = this->_internal_sdps(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.CallMessage.sdps"); target = stream->WriteString(2, s, target); } @@ -3724,26 +3552,18 @@ uint8_t* CallMessage::_InternalSerialize( // repeated string sdpMids = 4; for (int i = 0, n = this->_internal_sdpmids_size(); i < n; i++) { const auto& s = this->_internal_sdpmids(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.CallMessage.sdpMids"); target = stream->WriteString(4, s, target); } // required string uuid = 5; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_uuid().data(), static_cast(this->_internal_uuid().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.CallMessage.uuid"); target = stream->WriteStringMaybeAliased( 5, this->_internal_uuid(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.CallMessage) return target; @@ -3814,19 +3634,22 @@ size_t CallMessage::ByteSizeLong() const { _impl_.sdpmids_.Get(i)); } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CallMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - CallMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CallMessage::GetClassData() const { return &_class_data_; } - +void CallMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void CallMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void CallMessage::MergeFrom(const CallMessage& from) { + CallMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.CallMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -3845,7 +3668,7 @@ void CallMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void CallMessage::CopyFrom(const CallMessage& from) { @@ -3876,12 +3699,11 @@ void CallMessage::InternalSwap(CallMessage* other) { swap(_impl_.type_, other->_impl_.type_); } -::PROTOBUF_NAMESPACE_ID::Metadata CallMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[5]); +std::string CallMessage::GetTypeName() const { + return "SessionProtos.CallMessage"; } + // =================================================================== class KeyPair::_Internal { @@ -3900,12 +3722,12 @@ class KeyPair::_Internal { KeyPair::KeyPair(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.KeyPair) } KeyPair::KeyPair(const KeyPair& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { KeyPair* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -3913,7 +3735,7 @@ KeyPair::KeyPair(const KeyPair& from) , decltype(_impl_.publickey_){} , decltype(_impl_.privatekey_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.publickey_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.publickey_.Set("", GetArenaForAllocation()); @@ -3955,7 +3777,7 @@ inline void KeyPair::SharedCtor( KeyPair::~KeyPair() { // @@protoc_insertion_point(destructor:SessionProtos.KeyPair) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -3988,7 +3810,7 @@ void KeyPair::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -4027,7 +3849,7 @@ const char* KeyPair::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4060,8 +3882,8 @@ uint8_t* KeyPair::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.KeyPair) return target; @@ -4109,19 +3931,22 @@ size_t KeyPair::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData KeyPair::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - KeyPair::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*KeyPair::GetClassData() const { return &_class_data_; } - +void KeyPair::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void KeyPair::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void KeyPair::MergeFrom(const KeyPair& from) { + KeyPair* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.KeyPair) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -4136,7 +3961,7 @@ void KeyPair::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB _this->_internal_set_privatekey(from._internal_privatekey()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void KeyPair::CopyFrom(const KeyPair& from) { @@ -4167,12 +3992,11 @@ void KeyPair::InternalSwap(KeyPair* other) { ); } -::PROTOBUF_NAMESPACE_ID::Metadata KeyPair::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[6]); +std::string KeyPair::GetTypeName() const { + return "SessionProtos.KeyPair"; } + // =================================================================== class DataExtractionNotification::_Internal { @@ -4191,12 +4015,12 @@ class DataExtractionNotification::_Internal { DataExtractionNotification::DataExtractionNotification(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataExtractionNotification) } DataExtractionNotification::DataExtractionNotification(const DataExtractionNotification& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataExtractionNotification* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -4204,7 +4028,7 @@ DataExtractionNotification::DataExtractionNotification(const DataExtractionNotif , decltype(_impl_.timestamp_){} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); ::memcpy(&_impl_.timestamp_, &from._impl_.timestamp_, static_cast(reinterpret_cast(&_impl_.type_) - reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.type_)); @@ -4225,7 +4049,7 @@ inline void DataExtractionNotification::SharedCtor( DataExtractionNotification::~DataExtractionNotification() { // @@protoc_insertion_point(destructor:SessionProtos.DataExtractionNotification) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -4252,7 +4076,7 @@ void DataExtractionNotification::Clear() { _impl_.type_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -4295,7 +4119,7 @@ const char* DataExtractionNotification::_InternalParse(const char* ptr, ::_pbi:: } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4329,8 +4153,8 @@ uint8_t* DataExtractionNotification::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataExtractionNotification) return target; @@ -4355,19 +4179,22 @@ size_t DataExtractionNotification::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_timestamp()); } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataExtractionNotification::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataExtractionNotification::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataExtractionNotification::GetClassData() const { return &_class_data_; } - +void DataExtractionNotification::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataExtractionNotification::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataExtractionNotification::MergeFrom(const DataExtractionNotification& from) { + DataExtractionNotification* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataExtractionNotification) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -4383,7 +4210,7 @@ void DataExtractionNotification::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_ } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataExtractionNotification::CopyFrom(const DataExtractionNotification& from) { @@ -4406,12 +4233,11 @@ void DataExtractionNotification::InternalSwap(DataExtractionNotification* other) swap(_impl_.type_, other->_impl_.type_); } -::PROTOBUF_NAMESPACE_ID::Metadata DataExtractionNotification::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[7]); +std::string DataExtractionNotification::GetTypeName() const { + return "SessionProtos.DataExtractionNotification"; } + // =================================================================== class LokiProfile::_Internal { @@ -4427,12 +4253,12 @@ class LokiProfile::_Internal { LokiProfile::LokiProfile(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.LokiProfile) } LokiProfile::LokiProfile(const LokiProfile& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { LokiProfile* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -4440,7 +4266,7 @@ LokiProfile::LokiProfile(const LokiProfile& from) , decltype(_impl_.displayname_){} , decltype(_impl_.profilepicture_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.displayname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.displayname_.Set("", GetArenaForAllocation()); @@ -4482,7 +4308,7 @@ inline void LokiProfile::SharedCtor( LokiProfile::~LokiProfile() { // @@protoc_insertion_point(destructor:SessionProtos.LokiProfile) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -4515,7 +4341,7 @@ void LokiProfile::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -4531,9 +4357,6 @@ const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_mutable_displayname(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.LokiProfile.displayName"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4543,9 +4366,6 @@ const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_mutable_profilepicture(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.LokiProfile.profilePicture"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4560,7 +4380,7 @@ const char* LokiProfile::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4582,27 +4402,19 @@ uint8_t* LokiProfile::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // optional string displayName = 1; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_displayname().data(), static_cast(this->_internal_displayname().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.LokiProfile.displayName"); target = stream->WriteStringMaybeAliased( 1, this->_internal_displayname(), target); } // optional string profilePicture = 2; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_profilepicture().data(), static_cast(this->_internal_profilepicture().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.LokiProfile.profilePicture"); target = stream->WriteStringMaybeAliased( 2, this->_internal_profilepicture(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.LokiProfile) return target; @@ -4633,19 +4445,22 @@ size_t LokiProfile::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData LokiProfile::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - LokiProfile::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*LokiProfile::GetClassData() const { return &_class_data_; } - +void LokiProfile::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void LokiProfile::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void LokiProfile::MergeFrom(const LokiProfile& from) { + LokiProfile* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.LokiProfile) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -4660,7 +4475,7 @@ void LokiProfile::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR _this->_internal_set_profilepicture(from._internal_profilepicture()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void LokiProfile::CopyFrom(const LokiProfile& from) { @@ -4690,12 +4505,11 @@ void LokiProfile::InternalSwap(LokiProfile* other) { ); } -::PROTOBUF_NAMESPACE_ID::Metadata LokiProfile::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[8]); +std::string LokiProfile::GetTypeName() const { + return "SessionProtos.LokiProfile"; } + // =================================================================== class DataMessage_Quote_QuotedAttachment::_Internal { @@ -4722,12 +4536,12 @@ DataMessage_Quote_QuotedAttachment::_Internal::thumbnail(const DataMessage_Quote } DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote.QuotedAttachment) } DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(const DataMessage_Quote_QuotedAttachment& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataMessage_Quote_QuotedAttachment* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -4737,7 +4551,7 @@ DataMessage_Quote_QuotedAttachment::DataMessage_Quote_QuotedAttachment(const Dat , decltype(_impl_.thumbnail_){nullptr} , decltype(_impl_.flags_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.contenttype_.Set("", GetArenaForAllocation()); @@ -4785,7 +4599,7 @@ inline void DataMessage_Quote_QuotedAttachment::SharedCtor( DataMessage_Quote_QuotedAttachment::~DataMessage_Quote_QuotedAttachment() { // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote.QuotedAttachment) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -4824,7 +4638,7 @@ void DataMessage_Quote_QuotedAttachment::Clear() { } _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -4840,9 +4654,6 @@ const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, auto str = _internal_mutable_contenttype(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.QuotedAttachment.contentType"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4852,9 +4663,6 @@ const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, auto str = _internal_mutable_filename(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.QuotedAttachment.fileName"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4886,7 +4694,7 @@ const char* DataMessage_Quote_QuotedAttachment::_InternalParse(const char* ptr, } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -4908,20 +4716,12 @@ uint8_t* DataMessage_Quote_QuotedAttachment::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // optional string contentType = 1; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_contenttype().data(), static_cast(this->_internal_contenttype().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Quote.QuotedAttachment.contentType"); target = stream->WriteStringMaybeAliased( 1, this->_internal_contenttype(), target); } // optional string fileName = 2; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_filename().data(), static_cast(this->_internal_filename().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Quote.QuotedAttachment.fileName"); target = stream->WriteStringMaybeAliased( 2, this->_internal_filename(), target); } @@ -4940,8 +4740,8 @@ uint8_t* DataMessage_Quote_QuotedAttachment::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote.QuotedAttachment) return target; @@ -4984,19 +4784,22 @@ size_t DataMessage_Quote_QuotedAttachment::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Quote_QuotedAttachment::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataMessage_Quote_QuotedAttachment::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Quote_QuotedAttachment::GetClassData() const { return &_class_data_; } - +void DataMessage_Quote_QuotedAttachment::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataMessage_Quote_QuotedAttachment::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataMessage_Quote_QuotedAttachment::MergeFrom(const DataMessage_Quote_QuotedAttachment& from) { + DataMessage_Quote_QuotedAttachment* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote.QuotedAttachment) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -5019,7 +4822,7 @@ void DataMessage_Quote_QuotedAttachment::MergeImpl(::PROTOBUF_NAMESPACE_ID::Mess } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataMessage_Quote_QuotedAttachment::CopyFrom(const DataMessage_Quote_QuotedAttachment& from) { @@ -5058,12 +4861,11 @@ void DataMessage_Quote_QuotedAttachment::InternalSwap(DataMessage_Quote_QuotedAt reinterpret_cast(&other->_impl_.thumbnail_)); } -::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Quote_QuotedAttachment::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[9]); +std::string DataMessage_Quote_QuotedAttachment::GetTypeName() const { + return "SessionProtos.DataMessage.Quote.QuotedAttachment"; } + // =================================================================== class DataMessage_Quote::_Internal { @@ -5085,12 +4887,12 @@ class DataMessage_Quote::_Internal { DataMessage_Quote::DataMessage_Quote(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Quote) } DataMessage_Quote::DataMessage_Quote(const DataMessage_Quote& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataMessage_Quote* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -5100,7 +4902,7 @@ DataMessage_Quote::DataMessage_Quote(const DataMessage_Quote& from) , decltype(_impl_.text_){} , decltype(_impl_.id_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.author_.Set("", GetArenaForAllocation()); @@ -5145,7 +4947,7 @@ inline void DataMessage_Quote::SharedCtor( DataMessage_Quote::~DataMessage_Quote() { // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Quote) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -5181,7 +4983,7 @@ void DataMessage_Quote::Clear() { } _impl_.id_ = uint64_t{0u}; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -5206,9 +5008,6 @@ const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseCont auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.author"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5218,9 +5017,6 @@ const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseCont auto str = _internal_mutable_text(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Quote.text"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5248,7 +5044,7 @@ const char* DataMessage_Quote::_InternalParse(const char* ptr, ::_pbi::ParseCont } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -5276,20 +5072,12 @@ uint8_t* DataMessage_Quote::_InternalSerialize( // required string author = 2; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_author().data(), static_cast(this->_internal_author().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Quote.author"); target = stream->WriteStringMaybeAliased( 2, this->_internal_author(), target); } // optional string text = 3; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_text().data(), static_cast(this->_internal_text().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Quote.text"); target = stream->WriteStringMaybeAliased( 3, this->_internal_text(), target); } @@ -5303,8 +5091,8 @@ uint8_t* DataMessage_Quote::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Quote) return target; @@ -5363,19 +5151,22 @@ size_t DataMessage_Quote::ByteSizeLong() const { this->_internal_text()); } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Quote::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataMessage_Quote::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Quote::GetClassData() const { return &_class_data_; } - +void DataMessage_Quote::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataMessage_Quote::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataMessage_Quote::MergeFrom(const DataMessage_Quote& from) { + DataMessage_Quote* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Quote) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -5395,7 +5186,7 @@ void DataMessage_Quote::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, cons } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataMessage_Quote::CopyFrom(const DataMessage_Quote& from) { @@ -5430,12 +5221,11 @@ void DataMessage_Quote::InternalSwap(DataMessage_Quote* other) { swap(_impl_.id_, other->_impl_.id_); } -::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Quote::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[10]); +std::string DataMessage_Quote::GetTypeName() const { + return "SessionProtos.DataMessage.Quote"; } + // =================================================================== class DataMessage_Preview::_Internal { @@ -5462,12 +5252,12 @@ DataMessage_Preview::_Internal::image(const DataMessage_Preview* msg) { } DataMessage_Preview::DataMessage_Preview(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Preview) } DataMessage_Preview::DataMessage_Preview(const DataMessage_Preview& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataMessage_Preview* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -5476,7 +5266,7 @@ DataMessage_Preview::DataMessage_Preview(const DataMessage_Preview& from) , decltype(_impl_.title_){} , decltype(_impl_.image_){nullptr}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.url_.Set("", GetArenaForAllocation()); @@ -5522,7 +5312,7 @@ inline void DataMessage_Preview::SharedCtor( DataMessage_Preview::~DataMessage_Preview() { // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Preview) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -5560,7 +5350,7 @@ void DataMessage_Preview::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -5576,9 +5366,6 @@ const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseCo auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Preview.url"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5588,9 +5375,6 @@ const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseCo auto str = _internal_mutable_title(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Preview.title"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5613,7 +5397,7 @@ const char* DataMessage_Preview::_InternalParse(const char* ptr, ::_pbi::ParseCo } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -5635,20 +5419,12 @@ uint8_t* DataMessage_Preview::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // required string url = 1; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_url().data(), static_cast(this->_internal_url().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Preview.url"); target = stream->WriteStringMaybeAliased( 1, this->_internal_url(), target); } // optional string title = 2; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_title().data(), static_cast(this->_internal_title().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Preview.title"); target = stream->WriteStringMaybeAliased( 2, this->_internal_title(), target); } @@ -5661,8 +5437,8 @@ uint8_t* DataMessage_Preview::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Preview) return target; @@ -5699,19 +5475,22 @@ size_t DataMessage_Preview::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Preview::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataMessage_Preview::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Preview::GetClassData() const { return &_class_data_; } - +void DataMessage_Preview::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataMessage_Preview::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataMessage_Preview::MergeFrom(const DataMessage_Preview& from) { + DataMessage_Preview* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Preview) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -5730,7 +5509,7 @@ void DataMessage_Preview::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co from._internal_image()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataMessage_Preview::CopyFrom(const DataMessage_Preview& from) { @@ -5765,12 +5544,11 @@ void DataMessage_Preview::InternalSwap(DataMessage_Preview* other) { swap(_impl_.image_, other->_impl_.image_); } -::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Preview::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[11]); +std::string DataMessage_Preview::GetTypeName() const { + return "SessionProtos.DataMessage.Preview"; } + // =================================================================== class DataMessage_Reaction::_Internal { @@ -5795,12 +5573,12 @@ class DataMessage_Reaction::_Internal { DataMessage_Reaction::DataMessage_Reaction(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.Reaction) } DataMessage_Reaction::DataMessage_Reaction(const DataMessage_Reaction& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataMessage_Reaction* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -5810,7 +5588,7 @@ DataMessage_Reaction::DataMessage_Reaction(const DataMessage_Reaction& from) , decltype(_impl_.id_){} , decltype(_impl_.action_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.author_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.author_.Set("", GetArenaForAllocation()); @@ -5857,7 +5635,7 @@ inline void DataMessage_Reaction::SharedCtor( DataMessage_Reaction::~DataMessage_Reaction() { // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.Reaction) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -5895,7 +5673,7 @@ void DataMessage_Reaction::Clear() { reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.action_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -5920,9 +5698,6 @@ const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseC auto str = _internal_mutable_author(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Reaction.author"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5932,9 +5707,6 @@ const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseC auto str = _internal_mutable_emoji(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.Reaction.emoji"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5962,7 +5734,7 @@ const char* DataMessage_Reaction::_InternalParse(const char* ptr, ::_pbi::ParseC } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -5990,20 +5762,12 @@ uint8_t* DataMessage_Reaction::_InternalSerialize( // required string author = 2; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_author().data(), static_cast(this->_internal_author().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Reaction.author"); target = stream->WriteStringMaybeAliased( 2, this->_internal_author(), target); } // optional string emoji = 3; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_emoji().data(), static_cast(this->_internal_emoji().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.Reaction.emoji"); target = stream->WriteStringMaybeAliased( 3, this->_internal_emoji(), target); } @@ -6016,8 +5780,8 @@ uint8_t* DataMessage_Reaction::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.Reaction) return target; @@ -6079,19 +5843,22 @@ size_t DataMessage_Reaction::ByteSizeLong() const { this->_internal_emoji()); } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_Reaction::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataMessage_Reaction::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_Reaction::GetClassData() const { return &_class_data_; } - +void DataMessage_Reaction::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataMessage_Reaction::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataMessage_Reaction::MergeFrom(const DataMessage_Reaction& from) { + DataMessage_Reaction* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.Reaction) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -6113,7 +5880,7 @@ void DataMessage_Reaction::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataMessage_Reaction::CopyFrom(const DataMessage_Reaction& from) { @@ -6150,12 +5917,11 @@ void DataMessage_Reaction::InternalSwap(DataMessage_Reaction* other) { reinterpret_cast(&other->_impl_.id_)); } -::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_Reaction::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[12]); +std::string DataMessage_Reaction::GetTypeName() const { + return "SessionProtos.DataMessage.Reaction"; } + // =================================================================== class DataMessage_OpenGroupInvitation::_Internal { @@ -6174,12 +5940,12 @@ class DataMessage_OpenGroupInvitation::_Internal { DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage.OpenGroupInvitation) } DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(const DataMessage_OpenGroupInvitation& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataMessage_OpenGroupInvitation* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -6187,7 +5953,7 @@ DataMessage_OpenGroupInvitation::DataMessage_OpenGroupInvitation(const DataMessa , decltype(_impl_.url_){} , decltype(_impl_.name_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.url_.Set("", GetArenaForAllocation()); @@ -6229,7 +5995,7 @@ inline void DataMessage_OpenGroupInvitation::SharedCtor( DataMessage_OpenGroupInvitation::~DataMessage_OpenGroupInvitation() { // @@protoc_insertion_point(destructor:SessionProtos.DataMessage.OpenGroupInvitation) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -6262,7 +6028,7 @@ void DataMessage_OpenGroupInvitation::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -6278,9 +6044,6 @@ const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_ auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.OpenGroupInvitation.url"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6290,9 +6053,6 @@ const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_ auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.OpenGroupInvitation.name"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6307,7 +6067,7 @@ const char* DataMessage_OpenGroupInvitation::_InternalParse(const char* ptr, ::_ } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -6329,27 +6089,19 @@ uint8_t* DataMessage_OpenGroupInvitation::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // required string url = 1; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_url().data(), static_cast(this->_internal_url().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.OpenGroupInvitation.url"); target = stream->WriteStringMaybeAliased( 1, this->_internal_url(), target); } // required string name = 3; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.OpenGroupInvitation.name"); target = stream->WriteStringMaybeAliased( 3, this->_internal_name(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage.OpenGroupInvitation) return target; @@ -6397,19 +6149,22 @@ size_t DataMessage_OpenGroupInvitation::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage_OpenGroupInvitation::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataMessage_OpenGroupInvitation::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage_OpenGroupInvitation::GetClassData() const { return &_class_data_; } - +void DataMessage_OpenGroupInvitation::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataMessage_OpenGroupInvitation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataMessage_OpenGroupInvitation::MergeFrom(const DataMessage_OpenGroupInvitation& from) { + DataMessage_OpenGroupInvitation* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage.OpenGroupInvitation) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -6424,7 +6179,7 @@ void DataMessage_OpenGroupInvitation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message _this->_internal_set_name(from._internal_name()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataMessage_OpenGroupInvitation::CopyFrom(const DataMessage_OpenGroupInvitation& from) { @@ -6455,12 +6210,11 @@ void DataMessage_OpenGroupInvitation::InternalSwap(DataMessage_OpenGroupInvitati ); } -::PROTOBUF_NAMESPACE_ID::Metadata DataMessage_OpenGroupInvitation::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[13]); +std::string DataMessage_OpenGroupInvitation::GetTypeName() const { + return "SessionProtos.DataMessage.OpenGroupInvitation"; } + // =================================================================== class DataMessage::_Internal { @@ -6528,12 +6282,12 @@ DataMessage::_Internal::groupupdatemessage(const DataMessage* msg) { } DataMessage::DataMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.DataMessage) } DataMessage::DataMessage(const DataMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { DataMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -6552,7 +6306,7 @@ DataMessage::DataMessage(const DataMessage& from) , decltype(_impl_.flags_){} , decltype(_impl_.blockscommunitymessagerequests_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.body_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.body_.Set("", GetArenaForAllocation()); @@ -6635,7 +6389,7 @@ inline void DataMessage::SharedCtor( DataMessage::~DataMessage() { // @@protoc_insertion_point(destructor:SessionProtos.DataMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -6706,7 +6460,7 @@ void DataMessage::Clear() { reinterpret_cast(&_impl_.timestamp_)) + sizeof(_impl_.blockscommunitymessagerequests_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -6722,9 +6476,6 @@ const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_mutable_body(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.body"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6819,9 +6570,6 @@ const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c auto str = _internal_mutable_synctarget(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.DataMessage.syncTarget"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6853,7 +6601,7 @@ const char* DataMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -6875,10 +6623,6 @@ uint8_t* DataMessage::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // optional string body = 1; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_body().data(), static_cast(this->_internal_body().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.body"); target = stream->WriteStringMaybeAliased( 1, this->_internal_body(), target); } @@ -6947,10 +6691,6 @@ uint8_t* DataMessage::_InternalSerialize( // optional string syncTarget = 105; if (cached_has_bits & 0x00000004u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_synctarget().data(), static_cast(this->_internal_synctarget().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.DataMessage.syncTarget"); target = stream->WriteStringMaybeAliased( 105, this->_internal_synctarget(), target); } @@ -6969,8 +6709,8 @@ uint8_t* DataMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.DataMessage) return target; @@ -7074,19 +6814,22 @@ size_t DataMessage::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DataMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - DataMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DataMessage::GetClassData() const { return &_class_data_; } - +void DataMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void DataMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void DataMessage::MergeFrom(const DataMessage& from) { + DataMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.DataMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -7138,7 +6881,7 @@ void DataMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void DataMessage::CopyFrom(const DataMessage& from) { @@ -7196,12 +6939,11 @@ void DataMessage::InternalSwap(DataMessage* other) { reinterpret_cast(&other->_impl_.quote_)); } -::PROTOBUF_NAMESPACE_ID::Metadata DataMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[14]); +std::string DataMessage::GetTypeName() const { + return "SessionProtos.DataMessage"; } + // =================================================================== class ReceiptMessage::_Internal { @@ -7217,12 +6959,12 @@ class ReceiptMessage::_Internal { ReceiptMessage::ReceiptMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.ReceiptMessage) } ReceiptMessage::ReceiptMessage(const ReceiptMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { ReceiptMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -7230,7 +6972,7 @@ ReceiptMessage::ReceiptMessage(const ReceiptMessage& from) , decltype(_impl_.timestamp_){from._impl_.timestamp_} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _this->_impl_.type_ = from._impl_.type_; // @@protoc_insertion_point(copy_constructor:SessionProtos.ReceiptMessage) } @@ -7249,7 +6991,7 @@ inline void ReceiptMessage::SharedCtor( ReceiptMessage::~ReceiptMessage() { // @@protoc_insertion_point(destructor:SessionProtos.ReceiptMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -7274,7 +7016,7 @@ void ReceiptMessage::Clear() { _impl_.timestamp_.Clear(); _impl_.type_ = 0; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* ReceiptMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -7324,7 +7066,7 @@ const char* ReceiptMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -7358,8 +7100,8 @@ uint8_t* ReceiptMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ReceiptMessage) return target; @@ -7387,19 +7129,22 @@ size_t ReceiptMessage::ByteSizeLong() const { total_size += data_size; } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ReceiptMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - ReceiptMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ReceiptMessage::GetClassData() const { return &_class_data_; } - +void ReceiptMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void ReceiptMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void ReceiptMessage::MergeFrom(const ReceiptMessage& from) { + ReceiptMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ReceiptMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -7409,7 +7154,7 @@ void ReceiptMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const : if (from._internal_has_type()) { _this->_internal_set_type(from._internal_type()); } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void ReceiptMessage::CopyFrom(const ReceiptMessage& from) { @@ -7432,12 +7177,11 @@ void ReceiptMessage::InternalSwap(ReceiptMessage* other) { swap(_impl_.type_, other->_impl_.type_); } -::PROTOBUF_NAMESPACE_ID::Metadata ReceiptMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[15]); +std::string ReceiptMessage::GetTypeName() const { + return "SessionProtos.ReceiptMessage"; } + // =================================================================== class AttachmentPointer::_Internal { @@ -7486,12 +7230,12 @@ class AttachmentPointer::_Internal { AttachmentPointer::AttachmentPointer(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.AttachmentPointer) } AttachmentPointer::AttachmentPointer(const AttachmentPointer& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { AttachmentPointer* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -7509,7 +7253,7 @@ AttachmentPointer::AttachmentPointer(const AttachmentPointer& from) , decltype(_impl_.width_){} , decltype(_impl_.height_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.contenttype_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.contenttype_.Set("", GetArenaForAllocation()); @@ -7624,7 +7368,7 @@ inline void AttachmentPointer::SharedCtor( AttachmentPointer::~AttachmentPointer() { // @@protoc_insertion_point(destructor:SessionProtos.AttachmentPointer) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -7683,7 +7427,7 @@ void AttachmentPointer::Clear() { reinterpret_cast(&_impl_.size_)) + sizeof(_impl_.height_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -7708,9 +7452,6 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont auto str = _internal_mutable_contenttype(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.contentType"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -7756,9 +7497,6 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont auto str = _internal_mutable_filename(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.fileName"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -7795,9 +7533,6 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont auto str = _internal_mutable_caption(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.caption"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -7807,9 +7542,6 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont auto str = _internal_mutable_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.AttachmentPointer.url"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -7824,7 +7556,7 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -7852,10 +7584,6 @@ uint8_t* AttachmentPointer::_InternalSerialize( // optional string contentType = 2; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_contenttype().data(), static_cast(this->_internal_contenttype().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.AttachmentPointer.contentType"); target = stream->WriteStringMaybeAliased( 2, this->_internal_contenttype(), target); } @@ -7886,10 +7614,6 @@ uint8_t* AttachmentPointer::_InternalSerialize( // optional string fileName = 7; if (cached_has_bits & 0x00000010u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_filename().data(), static_cast(this->_internal_filename().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.AttachmentPointer.fileName"); target = stream->WriteStringMaybeAliased( 7, this->_internal_filename(), target); } @@ -7914,27 +7638,19 @@ uint8_t* AttachmentPointer::_InternalSerialize( // optional string caption = 11; if (cached_has_bits & 0x00000020u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_caption().data(), static_cast(this->_internal_caption().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.AttachmentPointer.caption"); target = stream->WriteStringMaybeAliased( 11, this->_internal_caption(), target); } // optional string url = 101; if (cached_has_bits & 0x00000040u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_url().data(), static_cast(this->_internal_url().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.AttachmentPointer.url"); target = stream->WriteStringMaybeAliased( 101, this->_internal_url(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.AttachmentPointer) return target; @@ -8026,19 +7742,22 @@ size_t AttachmentPointer::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData AttachmentPointer::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - AttachmentPointer::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*AttachmentPointer::GetClassData() const { return &_class_data_; } - +void AttachmentPointer::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void AttachmentPointer::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void AttachmentPointer::MergeFrom(const AttachmentPointer& from) { + AttachmentPointer* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.AttachmentPointer) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -8087,7 +7806,7 @@ void AttachmentPointer::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, cons } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void AttachmentPointer::CopyFrom(const AttachmentPointer& from) { @@ -8144,12 +7863,11 @@ void AttachmentPointer::InternalSwap(AttachmentPointer* other) { reinterpret_cast(&other->_impl_.id_)); } -::PROTOBUF_NAMESPACE_ID::Metadata AttachmentPointer::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[16]); +std::string AttachmentPointer::GetTypeName() const { + return "SessionProtos.AttachmentPointer"; } + // =================================================================== class SharedConfigMessage::_Internal { @@ -8171,12 +7889,12 @@ class SharedConfigMessage::_Internal { SharedConfigMessage::SharedConfigMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.SharedConfigMessage) } SharedConfigMessage::SharedConfigMessage(const SharedConfigMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { SharedConfigMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -8185,7 +7903,7 @@ SharedConfigMessage::SharedConfigMessage(const SharedConfigMessage& from) , decltype(_impl_.seqno_){} , decltype(_impl_.kind_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.data_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.data_.Set("", GetArenaForAllocation()); @@ -8219,7 +7937,7 @@ inline void SharedConfigMessage::SharedCtor( SharedConfigMessage::~SharedConfigMessage() { // @@protoc_insertion_point(destructor:SessionProtos.SharedConfigMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -8250,7 +7968,7 @@ void SharedConfigMessage::Clear() { _impl_.kind_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* SharedConfigMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -8302,7 +8020,7 @@ const char* SharedConfigMessage::_InternalParse(const char* ptr, ::_pbi::ParseCo } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -8342,8 +8060,8 @@ uint8_t* SharedConfigMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.SharedConfigMessage) return target; @@ -8397,19 +8115,22 @@ size_t SharedConfigMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SharedConfigMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - SharedConfigMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SharedConfigMessage::GetClassData() const { return &_class_data_; } - +void SharedConfigMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void SharedConfigMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void SharedConfigMessage::MergeFrom(const SharedConfigMessage& from) { + SharedConfigMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.SharedConfigMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -8428,7 +8149,7 @@ void SharedConfigMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void SharedConfigMessage::CopyFrom(const SharedConfigMessage& from) { @@ -8457,12 +8178,11 @@ void SharedConfigMessage::InternalSwap(SharedConfigMessage* other) { swap(_impl_.kind_, other->_impl_.kind_); } -::PROTOBUF_NAMESPACE_ID::Metadata SharedConfigMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[17]); +std::string SharedConfigMessage::GetTypeName() const { + return "SessionProtos.SharedConfigMessage"; } + // =================================================================== class GroupUpdateMessage::_Internal { @@ -8536,12 +8256,12 @@ GroupUpdateMessage::_Internal::memberleftnotificationmessage(const GroupUpdateMe } GroupUpdateMessage::GroupUpdateMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMessage) } GroupUpdateMessage::GroupUpdateMessage(const GroupUpdateMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -8555,7 +8275,7 @@ GroupUpdateMessage::GroupUpdateMessage(const GroupUpdateMessage& from) , decltype(_impl_.deletemembercontent_){nullptr} , decltype(_impl_.memberleftnotificationmessage_){nullptr}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from._internal_has_invitemessage()) { _this->_impl_.invitemessage_ = new ::SessionProtos::GroupUpdateInviteMessage(*from._impl_.invitemessage_); } @@ -8603,7 +8323,7 @@ inline void GroupUpdateMessage::SharedCtor( GroupUpdateMessage::~GroupUpdateMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -8668,7 +8388,7 @@ void GroupUpdateMessage::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdateMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -8753,7 +8473,7 @@ const char* GroupUpdateMessage::_InternalParse(const char* ptr, ::_pbi::ParseCon } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -8830,8 +8550,8 @@ uint8_t* GroupUpdateMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateMessage) return target; @@ -8904,19 +8624,22 @@ size_t GroupUpdateMessage::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdateMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMessage::GetClassData() const { return &_class_data_; } - +void GroupUpdateMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdateMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdateMessage::MergeFrom(const GroupUpdateMessage& from) { + GroupUpdateMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -8957,7 +8680,7 @@ void GroupUpdateMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, con from._internal_memberleftnotificationmessage()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdateMessage::CopyFrom(const GroupUpdateMessage& from) { @@ -8998,12 +8721,11 @@ void GroupUpdateMessage::InternalSwap(GroupUpdateMessage* other) { reinterpret_cast(&other->_impl_.invitemessage_)); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[18]); +std::string GroupUpdateMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateMessage"; } + // =================================================================== class GroupUpdateInviteMessage::_Internal { @@ -9028,12 +8750,12 @@ class GroupUpdateInviteMessage::_Internal { GroupUpdateInviteMessage::GroupUpdateInviteMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateInviteMessage) } GroupUpdateInviteMessage::GroupUpdateInviteMessage(const GroupUpdateInviteMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateInviteMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -9043,7 +8765,7 @@ GroupUpdateInviteMessage::GroupUpdateInviteMessage(const GroupUpdateInviteMessag , decltype(_impl_.memberauthdata_){} , decltype(_impl_.adminsignature_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.groupsessionid_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.groupsessionid_.Set("", GetArenaForAllocation()); @@ -9111,7 +8833,7 @@ inline void GroupUpdateInviteMessage::SharedCtor( GroupUpdateInviteMessage::~GroupUpdateInviteMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateInviteMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -9152,7 +8874,7 @@ void GroupUpdateInviteMessage::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdateInviteMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -9168,9 +8890,6 @@ const char* GroupUpdateInviteMessage::_InternalParse(const char* ptr, ::_pbi::Pa auto str = _internal_mutable_groupsessionid(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateInviteMessage.groupSessionId"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9180,9 +8899,6 @@ const char* GroupUpdateInviteMessage::_InternalParse(const char* ptr, ::_pbi::Pa auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateInviteMessage.name"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9215,7 +8931,7 @@ const char* GroupUpdateInviteMessage::_InternalParse(const char* ptr, ::_pbi::Pa } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -9237,20 +8953,12 @@ uint8_t* GroupUpdateInviteMessage::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // required string groupSessionId = 1; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_groupsessionid().data(), static_cast(this->_internal_groupsessionid().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdateInviteMessage.groupSessionId"); target = stream->WriteStringMaybeAliased( 1, this->_internal_groupsessionid(), target); } // required string name = 2; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdateInviteMessage.name"); target = stream->WriteStringMaybeAliased( 2, this->_internal_name(), target); } @@ -9268,8 +8976,8 @@ uint8_t* GroupUpdateInviteMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateInviteMessage) return target; @@ -9341,19 +9049,22 @@ size_t GroupUpdateInviteMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateInviteMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdateInviteMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateInviteMessage::GetClassData() const { return &_class_data_; } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} +void GroupUpdateInviteMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdateInviteMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdateInviteMessage::MergeFrom(const GroupUpdateInviteMessage& from) { + GroupUpdateInviteMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateInviteMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -9374,7 +9085,7 @@ void GroupUpdateInviteMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_ms _this->_internal_set_adminsignature(from._internal_adminsignature()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdateInviteMessage::CopyFrom(const GroupUpdateInviteMessage& from) { @@ -9413,12 +9124,11 @@ void GroupUpdateInviteMessage::InternalSwap(GroupUpdateInviteMessage* other) { ); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateInviteMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[19]); +std::string GroupUpdateInviteMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateInviteMessage"; } + // =================================================================== class GroupUpdatePromoteMessage::_Internal { @@ -9437,12 +9147,12 @@ class GroupUpdatePromoteMessage::_Internal { GroupUpdatePromoteMessage::GroupUpdatePromoteMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdatePromoteMessage) } GroupUpdatePromoteMessage::GroupUpdatePromoteMessage(const GroupUpdatePromoteMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdatePromoteMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -9450,7 +9160,7 @@ GroupUpdatePromoteMessage::GroupUpdatePromoteMessage(const GroupUpdatePromoteMes , decltype(_impl_.groupidentityseed_){} , decltype(_impl_.name_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.groupidentityseed_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.groupidentityseed_.Set("", GetArenaForAllocation()); @@ -9492,7 +9202,7 @@ inline void GroupUpdatePromoteMessage::SharedCtor( GroupUpdatePromoteMessage::~GroupUpdatePromoteMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdatePromoteMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -9525,7 +9235,7 @@ void GroupUpdatePromoteMessage::Clear() { } } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdatePromoteMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -9550,9 +9260,6 @@ const char* GroupUpdatePromoteMessage::_InternalParse(const char* ptr, ::_pbi::P auto str = _internal_mutable_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdatePromoteMessage.name"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9567,7 +9274,7 @@ const char* GroupUpdatePromoteMessage::_InternalParse(const char* ptr, ::_pbi::P } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -9595,17 +9302,13 @@ uint8_t* GroupUpdatePromoteMessage::_InternalSerialize( // required string name = 2; if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdatePromoteMessage.name"); target = stream->WriteStringMaybeAliased( 2, this->_internal_name(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdatePromoteMessage) return target; @@ -9653,19 +9356,22 @@ size_t GroupUpdatePromoteMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdatePromoteMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdatePromoteMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdatePromoteMessage::GetClassData() const { return &_class_data_; } - +void GroupUpdatePromoteMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdatePromoteMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdatePromoteMessage::MergeFrom(const GroupUpdatePromoteMessage& from) { + GroupUpdatePromoteMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdatePromoteMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -9680,7 +9386,7 @@ void GroupUpdatePromoteMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_m _this->_internal_set_name(from._internal_name()); } } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdatePromoteMessage::CopyFrom(const GroupUpdatePromoteMessage& from) { @@ -9711,12 +9417,11 @@ void GroupUpdatePromoteMessage::InternalSwap(GroupUpdatePromoteMessage* other) { ); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdatePromoteMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[20]); +std::string GroupUpdatePromoteMessage::GetTypeName() const { + return "SessionProtos.GroupUpdatePromoteMessage"; } + // =================================================================== class GroupUpdateInfoChangeMessage::_Internal { @@ -9741,12 +9446,12 @@ class GroupUpdateInfoChangeMessage::_Internal { GroupUpdateInfoChangeMessage::GroupUpdateInfoChangeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateInfoChangeMessage) } GroupUpdateInfoChangeMessage::GroupUpdateInfoChangeMessage(const GroupUpdateInfoChangeMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateInfoChangeMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -9756,7 +9461,7 @@ GroupUpdateInfoChangeMessage::GroupUpdateInfoChangeMessage(const GroupUpdateInfo , decltype(_impl_.updatedexpiration_){} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.updatedname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.updatedname_.Set("", GetArenaForAllocation()); @@ -9803,7 +9508,7 @@ inline void GroupUpdateInfoChangeMessage::SharedCtor( GroupUpdateInfoChangeMessage::~GroupUpdateInfoChangeMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateInfoChangeMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -9840,7 +9545,7 @@ void GroupUpdateInfoChangeMessage::Clear() { _impl_.type_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdateInfoChangeMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -9869,9 +9574,6 @@ const char* GroupUpdateInfoChangeMessage::_InternalParse(const char* ptr, ::_pbi auto str = _internal_mutable_updatedname(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateInfoChangeMessage.updatedName"); - #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9904,7 +9606,7 @@ const char* GroupUpdateInfoChangeMessage::_InternalParse(const char* ptr, ::_pbi } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -9933,10 +9635,6 @@ uint8_t* GroupUpdateInfoChangeMessage::_InternalSerialize( // optional string updatedName = 2; if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_updatedname().data(), static_cast(this->_internal_updatedname().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdateInfoChangeMessage.updatedName"); target = stream->WriteStringMaybeAliased( 2, this->_internal_updatedname(), target); } @@ -9954,8 +9652,8 @@ uint8_t* GroupUpdateInfoChangeMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateInfoChangeMessage) return target; @@ -10014,19 +9712,22 @@ size_t GroupUpdateInfoChangeMessage::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_updatedexpiration()); } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateInfoChangeMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdateInfoChangeMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateInfoChangeMessage::GetClassData() const { return &_class_data_; } - +void GroupUpdateInfoChangeMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdateInfoChangeMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdateInfoChangeMessage::MergeFrom(const GroupUpdateInfoChangeMessage& from) { + GroupUpdateInfoChangeMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateInfoChangeMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -10048,7 +9749,7 @@ void GroupUpdateInfoChangeMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& t } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdateInfoChangeMessage::CopyFrom(const GroupUpdateInfoChangeMessage& from) { @@ -10081,12 +9782,11 @@ void GroupUpdateInfoChangeMessage::InternalSwap(GroupUpdateInfoChangeMessage* ot swap(_impl_.type_, other->_impl_.type_); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateInfoChangeMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[21]); +std::string GroupUpdateInfoChangeMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateInfoChangeMessage"; } + // =================================================================== class GroupUpdateMemberChangeMessage::_Internal { @@ -10108,12 +9808,12 @@ class GroupUpdateMemberChangeMessage::_Internal { GroupUpdateMemberChangeMessage::GroupUpdateMemberChangeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMemberChangeMessage) } GroupUpdateMemberChangeMessage::GroupUpdateMemberChangeMessage(const GroupUpdateMemberChangeMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateMemberChangeMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -10123,7 +9823,7 @@ GroupUpdateMemberChangeMessage::GroupUpdateMemberChangeMessage(const GroupUpdate , decltype(_impl_.historyshared_){} , decltype(_impl_.type_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.adminsignature_.Set("", GetArenaForAllocation()); @@ -10158,7 +9858,7 @@ inline void GroupUpdateMemberChangeMessage::SharedCtor( GroupUpdateMemberChangeMessage::~GroupUpdateMemberChangeMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateMemberChangeMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -10191,7 +9891,7 @@ void GroupUpdateMemberChangeMessage::Clear() { _impl_.type_ = 1; } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdateMemberChangeMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -10223,9 +9923,6 @@ const char* GroupUpdateMemberChangeMessage::_InternalParse(const char* ptr, ::_p auto str = _internal_add_membersessionids(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds"); - #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else @@ -10260,7 +9957,7 @@ const char* GroupUpdateMemberChangeMessage::_InternalParse(const char* ptr, ::_p } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -10290,10 +9987,6 @@ uint8_t* GroupUpdateMemberChangeMessage::_InternalSerialize( // repeated string memberSessionIds = 2; for (int i = 0, n = this->_internal_membersessionids_size(); i < n; i++) { const auto& s = this->_internal_membersessionids(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdateMemberChangeMessage.memberSessionIds"); target = stream->WriteString(2, s, target); } @@ -10310,8 +10003,8 @@ uint8_t* GroupUpdateMemberChangeMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateMemberChangeMessage) return target; @@ -10371,19 +10064,22 @@ size_t GroupUpdateMemberChangeMessage::ByteSizeLong() const { total_size += 1 + 1; } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMemberChangeMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdateMemberChangeMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMemberChangeMessage::GetClassData() const { return &_class_data_; } - +void GroupUpdateMemberChangeMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdateMemberChangeMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdateMemberChangeMessage::MergeFrom(const GroupUpdateMemberChangeMessage& from) { + GroupUpdateMemberChangeMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateMemberChangeMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -10403,7 +10099,7 @@ void GroupUpdateMemberChangeMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdateMemberChangeMessage::CopyFrom(const GroupUpdateMemberChangeMessage& from) { @@ -10433,12 +10129,11 @@ void GroupUpdateMemberChangeMessage::InternalSwap(GroupUpdateMemberChangeMessage swap(_impl_.type_, other->_impl_.type_); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMemberChangeMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[22]); +std::string GroupUpdateMemberChangeMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateMemberChangeMessage"; } + // =================================================================== class GroupUpdateMemberLeftMessage::_Internal { @@ -10447,38 +10142,146 @@ class GroupUpdateMemberLeftMessage::_Internal { GroupUpdateMemberLeftMessage::GroupUpdateMemberLeftMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMemberLeftMessage) } GroupUpdateMemberLeftMessage::GroupUpdateMemberLeftMessage(const GroupUpdateMemberLeftMessage& from) - : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateMemberLeftMessage* const _this = this; (void)_this; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + new (&_impl_) Impl_{ + /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateMemberLeftMessage) } +inline void GroupUpdateMemberLeftMessage::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._cached_size_)*/{} + }; +} + +GroupUpdateMemberLeftMessage::~GroupUpdateMemberLeftMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateMemberLeftMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void GroupUpdateMemberLeftMessage::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} +void GroupUpdateMemberLeftMessage::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} +void GroupUpdateMemberLeftMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateMemberLeftMessage) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _internal_metadata_.Clear(); +} -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMemberLeftMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMemberLeftMessage::GetClassData() const { return &_class_data_; } +const char* GroupUpdateMemberLeftMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} +uint8_t* GroupUpdateMemberLeftMessage::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateMemberLeftMessage) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateMemberLeftMessage) + return target; +} + +size_t GroupUpdateMemberLeftMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateMemberLeftMessage) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void GroupUpdateMemberLeftMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} +void GroupUpdateMemberLeftMessage::MergeFrom(const GroupUpdateMemberLeftMessage& from) { + GroupUpdateMemberLeftMessage* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateMemberLeftMessage) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} +void GroupUpdateMemberLeftMessage::CopyFrom(const GroupUpdateMemberLeftMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateMemberLeftMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool GroupUpdateMemberLeftMessage::IsInitialized() const { + return true; +} +void GroupUpdateMemberLeftMessage::InternalSwap(GroupUpdateMemberLeftMessage* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); +} -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMemberLeftMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[23]); +std::string GroupUpdateMemberLeftMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateMemberLeftMessage"; } + // =================================================================== class GroupUpdateMemberLeftNotificationMessage::_Internal { @@ -10487,38 +10290,146 @@ class GroupUpdateMemberLeftNotificationMessage::_Internal { GroupUpdateMemberLeftNotificationMessage::GroupUpdateMemberLeftNotificationMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateMemberLeftNotificationMessage) } GroupUpdateMemberLeftNotificationMessage::GroupUpdateMemberLeftNotificationMessage(const GroupUpdateMemberLeftNotificationMessage& from) - : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateMemberLeftNotificationMessage* const _this = this; (void)_this; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + new (&_impl_) Impl_{ + /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateMemberLeftNotificationMessage) } +inline void GroupUpdateMemberLeftNotificationMessage::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._cached_size_)*/{} + }; +} +GroupUpdateMemberLeftNotificationMessage::~GroupUpdateMemberLeftNotificationMessage() { + // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (void)arena; + return; + } + SharedDtor(); +} +inline void GroupUpdateMemberLeftNotificationMessage::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} +void GroupUpdateMemberLeftNotificationMessage::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateMemberLeftNotificationMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateMemberLeftNotificationMessage::GetClassData() const { return &_class_data_; } +void GroupUpdateMemberLeftNotificationMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _internal_metadata_.Clear(); +} + +const char* GroupUpdateMemberLeftNotificationMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* GroupUpdateMemberLeftNotificationMessage::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + return target; +} +size_t GroupUpdateMemberLeftNotificationMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + size_t total_size = 0; + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} +void GroupUpdateMemberLeftNotificationMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} +void GroupUpdateMemberLeftNotificationMessage::MergeFrom(const GroupUpdateMemberLeftNotificationMessage& from) { + GroupUpdateMemberLeftNotificationMessage* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateMemberLeftNotificationMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[24]); +void GroupUpdateMemberLeftNotificationMessage::CopyFrom(const GroupUpdateMemberLeftNotificationMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.GroupUpdateMemberLeftNotificationMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); } +bool GroupUpdateMemberLeftNotificationMessage::IsInitialized() const { + return true; +} + +void GroupUpdateMemberLeftNotificationMessage::InternalSwap(GroupUpdateMemberLeftNotificationMessage* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); +} + +std::string GroupUpdateMemberLeftNotificationMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateMemberLeftNotificationMessage"; +} + + // =================================================================== class GroupUpdateInviteResponseMessage::_Internal { @@ -10534,19 +10445,19 @@ class GroupUpdateInviteResponseMessage::_Internal { GroupUpdateInviteResponseMessage::GroupUpdateInviteResponseMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateInviteResponseMessage) } GroupUpdateInviteResponseMessage::GroupUpdateInviteResponseMessage(const GroupUpdateInviteResponseMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateInviteResponseMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.isapproved_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _this->_impl_.isapproved_ = from._impl_.isapproved_; // @@protoc_insertion_point(copy_constructor:SessionProtos.GroupUpdateInviteResponseMessage) } @@ -10564,7 +10475,7 @@ inline void GroupUpdateInviteResponseMessage::SharedCtor( GroupUpdateInviteResponseMessage::~GroupUpdateInviteResponseMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateInviteResponseMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -10587,7 +10498,7 @@ void GroupUpdateInviteResponseMessage::Clear() { _impl_.isapproved_ = false; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdateInviteResponseMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -10617,7 +10528,7 @@ const char* GroupUpdateInviteResponseMessage::_InternalParse(const char* ptr, :: } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -10644,8 +10555,8 @@ uint8_t* GroupUpdateInviteResponseMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateInviteResponseMessage) return target; @@ -10663,19 +10574,22 @@ size_t GroupUpdateInviteResponseMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateInviteResponseMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdateInviteResponseMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateInviteResponseMessage::GetClassData() const { return &_class_data_; } - +void GroupUpdateInviteResponseMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdateInviteResponseMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdateInviteResponseMessage::MergeFrom(const GroupUpdateInviteResponseMessage& from) { + GroupUpdateInviteResponseMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateInviteResponseMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -10684,7 +10598,7 @@ void GroupUpdateInviteResponseMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Messag if (from._internal_has_isapproved()) { _this->_internal_set_isapproved(from._internal_isapproved()); } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdateInviteResponseMessage::CopyFrom(const GroupUpdateInviteResponseMessage& from) { @@ -10706,12 +10620,11 @@ void GroupUpdateInviteResponseMessage::InternalSwap(GroupUpdateInviteResponseMes swap(_impl_.isapproved_, other->_impl_.isapproved_); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateInviteResponseMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[25]); +std::string GroupUpdateInviteResponseMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateInviteResponseMessage"; } + // =================================================================== class GroupUpdateDeleteMemberContentMessage::_Internal { @@ -10724,12 +10637,12 @@ class GroupUpdateDeleteMemberContentMessage::_Internal { GroupUpdateDeleteMemberContentMessage::GroupUpdateDeleteMemberContentMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.GroupUpdateDeleteMemberContentMessage) } GroupUpdateDeleteMemberContentMessage::GroupUpdateDeleteMemberContentMessage(const GroupUpdateDeleteMemberContentMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { GroupUpdateDeleteMemberContentMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -10738,7 +10651,7 @@ GroupUpdateDeleteMemberContentMessage::GroupUpdateDeleteMemberContentMessage(con , decltype(_impl_.messagehashes_){from._impl_.messagehashes_} , decltype(_impl_.adminsignature_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.adminsignature_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.adminsignature_.Set("", GetArenaForAllocation()); @@ -10769,7 +10682,7 @@ inline void GroupUpdateDeleteMemberContentMessage::SharedCtor( GroupUpdateDeleteMemberContentMessage::~GroupUpdateDeleteMemberContentMessage() { // @@protoc_insertion_point(destructor:SessionProtos.GroupUpdateDeleteMemberContentMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -10800,7 +10713,7 @@ void GroupUpdateDeleteMemberContentMessage::Clear() { _impl_.adminsignature_.ClearNonDefaultToEmpty(); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* GroupUpdateDeleteMemberContentMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -10819,9 +10732,6 @@ const char* GroupUpdateDeleteMemberContentMessage::_InternalParse(const char* pt auto str = _internal_add_membersessionids(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds"); - #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else @@ -10836,9 +10746,6 @@ const char* GroupUpdateDeleteMemberContentMessage::_InternalParse(const char* pt auto str = _internal_add_messagehashes(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); - #ifndef NDEBUG - ::_pbi::VerifyUTF8(str, "SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes"); - #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else @@ -10864,7 +10771,7 @@ const char* GroupUpdateDeleteMemberContentMessage::_InternalParse(const char* pt } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -10886,20 +10793,12 @@ uint8_t* GroupUpdateDeleteMemberContentMessage::_InternalSerialize( // repeated string memberSessionIds = 1; for (int i = 0, n = this->_internal_membersessionids_size(); i < n; i++) { const auto& s = this->_internal_membersessionids(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdateDeleteMemberContentMessage.memberSessionIds"); target = stream->WriteString(1, s, target); } // repeated string messageHashes = 2; for (int i = 0, n = this->_internal_messagehashes_size(); i < n; i++) { const auto& s = this->_internal_messagehashes(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "SessionProtos.GroupUpdateDeleteMemberContentMessage.messageHashes"); target = stream->WriteString(2, s, target); } @@ -10911,8 +10810,8 @@ uint8_t* GroupUpdateDeleteMemberContentMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.GroupUpdateDeleteMemberContentMessage) return target; @@ -10950,19 +10849,22 @@ size_t GroupUpdateDeleteMemberContentMessage::ByteSizeLong() const { this->_internal_adminsignature()); } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GroupUpdateDeleteMemberContentMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - GroupUpdateDeleteMemberContentMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GroupUpdateDeleteMemberContentMessage::GetClassData() const { return &_class_data_; } - +void GroupUpdateDeleteMemberContentMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void GroupUpdateDeleteMemberContentMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void GroupUpdateDeleteMemberContentMessage::MergeFrom(const GroupUpdateDeleteMemberContentMessage& from) { + GroupUpdateDeleteMemberContentMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.GroupUpdateDeleteMemberContentMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -10973,7 +10875,7 @@ void GroupUpdateDeleteMemberContentMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::M if (from._internal_has_adminsignature()) { _this->_internal_set_adminsignature(from._internal_adminsignature()); } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void GroupUpdateDeleteMemberContentMessage::CopyFrom(const GroupUpdateDeleteMemberContentMessage& from) { @@ -11001,12 +10903,11 @@ void GroupUpdateDeleteMemberContentMessage::InternalSwap(GroupUpdateDeleteMember ); } -::PROTOBUF_NAMESPACE_ID::Metadata GroupUpdateDeleteMemberContentMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[26]); +std::string GroupUpdateDeleteMemberContentMessage::GetTypeName() const { + return "SessionProtos.GroupUpdateDeleteMemberContentMessage"; } + // =================================================================== class ProProof::_Internal { @@ -11034,12 +10935,12 @@ class ProProof::_Internal { ProProof::ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.ProProof) } ProProof::ProProof(const ProProof& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { ProProof* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -11050,7 +10951,7 @@ ProProof::ProProof(const ProProof& from) , decltype(_impl_.expiryunixts_){} , decltype(_impl_.version_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); _impl_.genindexhash_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.genindexhash_.Set("", GetArenaForAllocation()); @@ -11110,7 +11011,7 @@ inline void ProProof::SharedCtor( ProProof::~ProProof() { // @@protoc_insertion_point(destructor:SessionProtos.ProProof) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -11152,7 +11053,7 @@ void ProProof::Clear() { reinterpret_cast(&_impl_.expiryunixts_)) + sizeof(_impl_.version_)); } _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -11218,7 +11119,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -11269,8 +11170,8 @@ uint8_t* ProProof::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProProof) return target; @@ -11346,19 +11247,22 @@ size_t ProProof::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ProProof::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - ProProof::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ProProof::GetClassData() const { return &_class_data_; } - +void ProProof::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void ProProof::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void ProProof::MergeFrom(const ProProof& from) { + ProProof* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProProof) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -11383,7 +11287,7 @@ void ProProof::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTO } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void ProProof::CopyFrom(const ProProof& from) { @@ -11424,300 +11328,10 @@ void ProProof::InternalSwap(ProProof* other) { reinterpret_cast(&other->_impl_.expiryunixts_)); } -::PROTOBUF_NAMESPACE_ID::Metadata ProProof::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[27]); -} - -// =================================================================== - -class ProConfig::_Internal { - public: - using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_rotatingprivkey(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::SessionProtos::ProProof& proof(const ProConfig* msg); - static void set_has_proof(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } -}; - -const ::SessionProtos::ProProof& -ProConfig::_Internal::proof(const ProConfig* msg) { - return *msg->_impl_.proof_; -} -ProConfig::ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(arena, is_message_owned); - // @@protoc_insertion_point(arena_constructor:SessionProtos.ProConfig) -} -ProConfig::ProConfig(const ProConfig& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - ProConfig* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_._has_bits_){from._impl_._has_bits_} - , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.rotatingprivkey_){} - , decltype(_impl_.proof_){nullptr}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.rotatingprivkey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_rotatingprivkey()) { - _this->_impl_.rotatingprivkey_.Set(from._internal_rotatingprivkey(), - _this->GetArenaForAllocation()); - } - if (from._internal_has_proof()) { - _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); - } - // @@protoc_insertion_point(copy_constructor:SessionProtos.ProConfig) -} - -inline void ProConfig::SharedCtor( - ::_pb::Arena* arena, bool is_message_owned) { - (void)arena; - (void)is_message_owned; - new (&_impl_) Impl_{ - decltype(_impl_._has_bits_){} - , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.rotatingprivkey_){} - , decltype(_impl_.proof_){nullptr} - }; - _impl_.rotatingprivkey_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -ProConfig::~ProConfig() { - // @@protoc_insertion_point(destructor:SessionProtos.ProConfig) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void ProConfig::SharedDtor() { - GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.rotatingprivkey_.Destroy(); - if (this != internal_default_instance()) delete _impl_.proof_; -} - -void ProConfig::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void ProConfig::Clear() { -// @@protoc_insertion_point(message_clear_start:SessionProtos.ProConfig) - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _impl_.rotatingprivkey_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(_impl_.proof_ != nullptr); - _impl_.proof_->Clear(); - } - } - _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* ProConfig::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // required bytes rotatingPrivKey = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { - auto str = _internal_mutable_rotatingprivkey(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // required .SessionProtos.ProProof proof = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - _impl_._has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -uint8_t* ProConfig::_InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:SessionProtos.ProConfig) - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _impl_._has_bits_[0]; - // required bytes rotatingPrivKey = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->WriteBytesMaybeAliased( - 1, this->_internal_rotatingprivkey(), target); - } - - // required .SessionProtos.ProProof proof = 2; - if (cached_has_bits & 0x00000002u) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, _Internal::proof(this), - _Internal::proof(this).GetCachedSize(), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProConfig) - return target; -} - -size_t ProConfig::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProConfig) - size_t total_size = 0; - - if (_internal_has_rotatingprivkey()) { - // required bytes rotatingPrivKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingprivkey()); - } - - if (_internal_has_proof()) { - // required .SessionProtos.ProProof proof = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); - } - - return total_size; -} -size_t ProConfig::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProConfig) - size_t total_size = 0; - - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required bytes rotatingPrivKey = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingprivkey()); - - // required .SessionProtos.ProProof proof = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +std::string ProProof::GetTypeName() const { + return "SessionProtos.ProProof"; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ProConfig::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - ProConfig::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ProConfig::GetClassData() const { return &_class_data_; } - - -void ProConfig::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProConfig) - GOOGLE_DCHECK_NE(&from, _this); - uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _this->_internal_set_rotatingprivkey(from._internal_rotatingprivkey()); - } - if (cached_has_bits & 0x00000002u) { - _this->_internal_mutable_proof()->::SessionProtos::ProProof::MergeFrom( - from._internal_proof()); - } - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void ProConfig::CopyFrom(const ProConfig& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:SessionProtos.ProConfig) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool ProConfig::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (_internal_has_proof()) { - if (!_impl_.proof_->IsInitialized()) return false; - } - return true; -} - -void ProConfig::InternalSwap(ProConfig* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.rotatingprivkey_, lhs_arena, - &other->_impl_.rotatingprivkey_, rhs_arena - ); - swap(_impl_.proof_, other->_impl_.proof_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata ProConfig::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[28]); -} // =================================================================== @@ -11742,12 +11356,12 @@ ProMessage::_Internal::proof(const ProMessage* msg) { } ProMessage::ProMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SessionProtos.ProMessage) } ProMessage::ProMessage(const ProMessage& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { ProMessage* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} @@ -11755,7 +11369,7 @@ ProMessage::ProMessage(const ProMessage& from) , decltype(_impl_.proof_){nullptr} , decltype(_impl_.flags_){}}; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from._internal_has_proof()) { _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); } @@ -11777,7 +11391,7 @@ inline void ProMessage::SharedCtor( ProMessage::~ProMessage() { // @@protoc_insertion_point(destructor:SessionProtos.ProMessage) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { (void)arena; return; } @@ -11806,7 +11420,7 @@ void ProMessage::Clear() { } _impl_.flags_ = 0u; _impl_._has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + _internal_metadata_.Clear(); } const char* ProMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { @@ -11844,7 +11458,7 @@ const char* ProMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ct } ptr = UnknownFieldParse( tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + _internal_metadata_.mutable_unknown_fields(), ptr, ctx); CHK_(ptr != nullptr); } // while @@ -11878,8 +11492,8 @@ uint8_t* ProMessage::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); } // @@protoc_insertion_point(serialize_to_array_end:SessionProtos.ProMessage) return target; @@ -11923,19 +11537,22 @@ size_t ProMessage::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; } -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ProMessage::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - ProMessage::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ProMessage::GetClassData() const { return &_class_data_; } - +void ProMessage::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} -void ProMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); +void ProMessage::MergeFrom(const ProMessage& from) { + ProMessage* const _this = this; // @@protoc_insertion_point(class_specific_merge_from_start:SessionProtos.ProMessage) GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; @@ -11952,7 +11569,7 @@ void ProMessage::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PRO } _this->_impl_._has_bits_[0] |= cached_has_bits; } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); } void ProMessage::CopyFrom(const ProMessage& from) { @@ -11982,12 +11599,11 @@ void ProMessage::InternalSwap(ProMessage* other) { reinterpret_cast(&other->_impl_.proof_)); } -::PROTOBUF_NAMESPACE_ID::Metadata ProMessage::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_SessionProtos_2eproto_getter, &descriptor_table_SessionProtos_2eproto_once, - file_level_metadata_SessionProtos_2eproto[29]); +std::string ProMessage::GetTypeName() const { + return "SessionProtos.ProMessage"; } + // @@protoc_insertion_point(namespace_scope) } // namespace SessionProtos PROTOBUF_NAMESPACE_OPEN @@ -12103,10 +11719,6 @@ template<> PROTOBUF_NOINLINE ::SessionProtos::ProProof* Arena::CreateMaybeMessage< ::SessionProtos::ProProof >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ProProof >(arena); } -template<> PROTOBUF_NOINLINE ::SessionProtos::ProConfig* -Arena::CreateMaybeMessage< ::SessionProtos::ProConfig >(Arena* arena) { - return Arena::CreateMessageInternal< ::SessionProtos::ProConfig >(arena); -} template<> PROTOBUF_NOINLINE ::SessionProtos::ProMessage* Arena::CreateMaybeMessage< ::SessionProtos::ProMessage >(Arena* arena) { return Arena::CreateMessageInternal< ::SessionProtos::ProMessage >(arena); diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index c73bb3d0..10c96518 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -23,15 +23,12 @@ #include #include #include -#include #include #include -#include -#include +#include #include // IWYU pragma: export #include // IWYU pragma: export -#include -#include +#include // @@protoc_insertion_point(includes) #include #define PROTOBUF_INTERNAL_EXPORT_SessionProtos_2eproto @@ -45,7 +42,6 @@ PROTOBUF_NAMESPACE_CLOSE struct TableStruct_SessionProtos_2eproto { static const uint32_t offsets[]; }; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_SessionProtos_2eproto; namespace SessionProtos { class AttachmentPointer; struct AttachmentPointerDefaultTypeInternal; @@ -116,9 +112,6 @@ extern LokiProfileDefaultTypeInternal _LokiProfile_default_instance_; class MessageRequestResponse; struct MessageRequestResponseDefaultTypeInternal; extern MessageRequestResponseDefaultTypeInternal _MessageRequestResponse_default_instance_; -class ProConfig; -struct ProConfigDefaultTypeInternal; -extern ProConfigDefaultTypeInternal _ProConfig_default_instance_; class ProMessage; struct ProMessageDefaultTypeInternal; extern ProMessageDefaultTypeInternal _ProMessage_default_instance_; @@ -162,7 +155,6 @@ template<> ::SessionProtos::GroupUpdatePromoteMessage* Arena::CreateMaybeMessage template<> ::SessionProtos::KeyPair* Arena::CreateMaybeMessage<::SessionProtos::KeyPair>(Arena*); template<> ::SessionProtos::LokiProfile* Arena::CreateMaybeMessage<::SessionProtos::LokiProfile>(Arena*); template<> ::SessionProtos::MessageRequestResponse* Arena::CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(Arena*); -template<> ::SessionProtos::ProConfig* Arena::CreateMaybeMessage<::SessionProtos::ProConfig>(Arena*); template<> ::SessionProtos::ProMessage* Arena::CreateMaybeMessage<::SessionProtos::ProMessage>(Arena*); template<> ::SessionProtos::ProProof* Arena::CreateMaybeMessage<::SessionProtos::ProProof>(Arena*); template<> ::SessionProtos::ReceiptMessage* Arena::CreateMaybeMessage<::SessionProtos::ReceiptMessage>(Arena*); @@ -181,20 +173,16 @@ constexpr Envelope_Type Envelope_Type_Type_MIN = Envelope_Type_SESSION_MESSAGE; constexpr Envelope_Type Envelope_Type_Type_MAX = Envelope_Type_CLOSED_GROUP_MESSAGE; constexpr int Envelope_Type_Type_ARRAYSIZE = Envelope_Type_Type_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Envelope_Type_descriptor(); +const std::string& Envelope_Type_Name(Envelope_Type value); template inline const std::string& Envelope_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function Envelope_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - Envelope_Type_descriptor(), enum_t_value); -} -inline bool Envelope_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Envelope_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - Envelope_Type_descriptor(), name, value); + return Envelope_Type_Name(static_cast(enum_t_value)); } +bool Envelope_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Envelope_Type* value); enum TypingMessage_Action : int { TypingMessage_Action_STARTED = 0, TypingMessage_Action_STOPPED = 1 @@ -204,20 +192,16 @@ constexpr TypingMessage_Action TypingMessage_Action_Action_MIN = TypingMessage_A constexpr TypingMessage_Action TypingMessage_Action_Action_MAX = TypingMessage_Action_STOPPED; constexpr int TypingMessage_Action_Action_ARRAYSIZE = TypingMessage_Action_Action_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* TypingMessage_Action_descriptor(); +const std::string& TypingMessage_Action_Name(TypingMessage_Action value); template inline const std::string& TypingMessage_Action_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function TypingMessage_Action_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - TypingMessage_Action_descriptor(), enum_t_value); -} -inline bool TypingMessage_Action_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, TypingMessage_Action* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - TypingMessage_Action_descriptor(), name, value); + return TypingMessage_Action_Name(static_cast(enum_t_value)); } +bool TypingMessage_Action_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, TypingMessage_Action* value); enum Content_ExpirationType : int { Content_ExpirationType_UNKNOWN = 0, Content_ExpirationType_DELETE_AFTER_READ = 1, @@ -228,20 +212,16 @@ constexpr Content_ExpirationType Content_ExpirationType_ExpirationType_MIN = Con constexpr Content_ExpirationType Content_ExpirationType_ExpirationType_MAX = Content_ExpirationType_DELETE_AFTER_SEND; constexpr int Content_ExpirationType_ExpirationType_ARRAYSIZE = Content_ExpirationType_ExpirationType_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Content_ExpirationType_descriptor(); +const std::string& Content_ExpirationType_Name(Content_ExpirationType value); template inline const std::string& Content_ExpirationType_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function Content_ExpirationType_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - Content_ExpirationType_descriptor(), enum_t_value); -} -inline bool Content_ExpirationType_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Content_ExpirationType* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - Content_ExpirationType_descriptor(), name, value); + return Content_ExpirationType_Name(static_cast(enum_t_value)); } +bool Content_ExpirationType_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Content_ExpirationType* value); enum CallMessage_Type : int { CallMessage_Type_PRE_OFFER = 6, CallMessage_Type_OFFER = 1, @@ -255,20 +235,16 @@ constexpr CallMessage_Type CallMessage_Type_Type_MIN = CallMessage_Type_OFFER; constexpr CallMessage_Type CallMessage_Type_Type_MAX = CallMessage_Type_PRE_OFFER; constexpr int CallMessage_Type_Type_ARRAYSIZE = CallMessage_Type_Type_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CallMessage_Type_descriptor(); +const std::string& CallMessage_Type_Name(CallMessage_Type value); template inline const std::string& CallMessage_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function CallMessage_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - CallMessage_Type_descriptor(), enum_t_value); -} -inline bool CallMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CallMessage_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - CallMessage_Type_descriptor(), name, value); + return CallMessage_Type_Name(static_cast(enum_t_value)); } +bool CallMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CallMessage_Type* value); enum DataExtractionNotification_Type : int { DataExtractionNotification_Type_SCREENSHOT = 1, DataExtractionNotification_Type_MEDIA_SAVED = 2 @@ -278,20 +254,16 @@ constexpr DataExtractionNotification_Type DataExtractionNotification_Type_Type_M constexpr DataExtractionNotification_Type DataExtractionNotification_Type_Type_MAX = DataExtractionNotification_Type_MEDIA_SAVED; constexpr int DataExtractionNotification_Type_Type_ARRAYSIZE = DataExtractionNotification_Type_Type_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataExtractionNotification_Type_descriptor(); +const std::string& DataExtractionNotification_Type_Name(DataExtractionNotification_Type value); template inline const std::string& DataExtractionNotification_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataExtractionNotification_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - DataExtractionNotification_Type_descriptor(), enum_t_value); -} -inline bool DataExtractionNotification_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataExtractionNotification_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - DataExtractionNotification_Type_descriptor(), name, value); + return DataExtractionNotification_Type_Name(static_cast(enum_t_value)); } +bool DataExtractionNotification_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataExtractionNotification_Type* value); enum DataMessage_Quote_QuotedAttachment_Flags : int { DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE = 1 }; @@ -300,20 +272,16 @@ constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttac constexpr DataMessage_Quote_QuotedAttachment_Flags DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX = DataMessage_Quote_QuotedAttachment_Flags_VOICE_MESSAGE; constexpr int DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE = DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Quote_QuotedAttachment_Flags_descriptor(); +const std::string& DataMessage_Quote_QuotedAttachment_Flags_Name(DataMessage_Quote_QuotedAttachment_Flags value); template inline const std::string& DataMessage_Quote_QuotedAttachment_Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataMessage_Quote_QuotedAttachment_Flags_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - DataMessage_Quote_QuotedAttachment_Flags_descriptor(), enum_t_value); -} -inline bool DataMessage_Quote_QuotedAttachment_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Quote_QuotedAttachment_Flags* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - DataMessage_Quote_QuotedAttachment_Flags_descriptor(), name, value); + return DataMessage_Quote_QuotedAttachment_Flags_Name(static_cast(enum_t_value)); } +bool DataMessage_Quote_QuotedAttachment_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Quote_QuotedAttachment_Flags* value); enum DataMessage_Reaction_Action : int { DataMessage_Reaction_Action_REACT = 0, DataMessage_Reaction_Action_REMOVE = 1 @@ -323,20 +291,16 @@ constexpr DataMessage_Reaction_Action DataMessage_Reaction_Action_Action_MIN = D constexpr DataMessage_Reaction_Action DataMessage_Reaction_Action_Action_MAX = DataMessage_Reaction_Action_REMOVE; constexpr int DataMessage_Reaction_Action_Action_ARRAYSIZE = DataMessage_Reaction_Action_Action_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Reaction_Action_descriptor(); +const std::string& DataMessage_Reaction_Action_Name(DataMessage_Reaction_Action value); template inline const std::string& DataMessage_Reaction_Action_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataMessage_Reaction_Action_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - DataMessage_Reaction_Action_descriptor(), enum_t_value); -} -inline bool DataMessage_Reaction_Action_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Reaction_Action* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - DataMessage_Reaction_Action_descriptor(), name, value); + return DataMessage_Reaction_Action_Name(static_cast(enum_t_value)); } +bool DataMessage_Reaction_Action_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Reaction_Action* value); enum DataMessage_Flags : int { DataMessage_Flags_EXPIRATION_TIMER_UPDATE = 2 }; @@ -345,20 +309,16 @@ constexpr DataMessage_Flags DataMessage_Flags_Flags_MIN = DataMessage_Flags_EXPI constexpr DataMessage_Flags DataMessage_Flags_Flags_MAX = DataMessage_Flags_EXPIRATION_TIMER_UPDATE; constexpr int DataMessage_Flags_Flags_ARRAYSIZE = DataMessage_Flags_Flags_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DataMessage_Flags_descriptor(); +const std::string& DataMessage_Flags_Name(DataMessage_Flags value); template inline const std::string& DataMessage_Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function DataMessage_Flags_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - DataMessage_Flags_descriptor(), enum_t_value); -} -inline bool DataMessage_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Flags* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - DataMessage_Flags_descriptor(), name, value); + return DataMessage_Flags_Name(static_cast(enum_t_value)); } +bool DataMessage_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DataMessage_Flags* value); enum ReceiptMessage_Type : int { ReceiptMessage_Type_DELIVERY = 0, ReceiptMessage_Type_READ = 1 @@ -368,20 +328,16 @@ constexpr ReceiptMessage_Type ReceiptMessage_Type_Type_MIN = ReceiptMessage_Type constexpr ReceiptMessage_Type ReceiptMessage_Type_Type_MAX = ReceiptMessage_Type_READ; constexpr int ReceiptMessage_Type_Type_ARRAYSIZE = ReceiptMessage_Type_Type_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ReceiptMessage_Type_descriptor(); +const std::string& ReceiptMessage_Type_Name(ReceiptMessage_Type value); template inline const std::string& ReceiptMessage_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function ReceiptMessage_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - ReceiptMessage_Type_descriptor(), enum_t_value); -} -inline bool ReceiptMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceiptMessage_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - ReceiptMessage_Type_descriptor(), name, value); + return ReceiptMessage_Type_Name(static_cast(enum_t_value)); } +bool ReceiptMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceiptMessage_Type* value); enum AttachmentPointer_Flags : int { AttachmentPointer_Flags_VOICE_MESSAGE = 1 }; @@ -390,20 +346,16 @@ constexpr AttachmentPointer_Flags AttachmentPointer_Flags_Flags_MIN = Attachment constexpr AttachmentPointer_Flags AttachmentPointer_Flags_Flags_MAX = AttachmentPointer_Flags_VOICE_MESSAGE; constexpr int AttachmentPointer_Flags_Flags_ARRAYSIZE = AttachmentPointer_Flags_Flags_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttachmentPointer_Flags_descriptor(); +const std::string& AttachmentPointer_Flags_Name(AttachmentPointer_Flags value); template inline const std::string& AttachmentPointer_Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function AttachmentPointer_Flags_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - AttachmentPointer_Flags_descriptor(), enum_t_value); -} -inline bool AttachmentPointer_Flags_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttachmentPointer_Flags* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - AttachmentPointer_Flags_descriptor(), name, value); + return AttachmentPointer_Flags_Name(static_cast(enum_t_value)); } +bool AttachmentPointer_Flags_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttachmentPointer_Flags* value); enum SharedConfigMessage_Kind : int { SharedConfigMessage_Kind_USER_PROFILE = 1, SharedConfigMessage_Kind_CONTACTS = 2, @@ -415,20 +367,16 @@ constexpr SharedConfigMessage_Kind SharedConfigMessage_Kind_Kind_MIN = SharedCon constexpr SharedConfigMessage_Kind SharedConfigMessage_Kind_Kind_MAX = SharedConfigMessage_Kind_USER_GROUPS; constexpr int SharedConfigMessage_Kind_Kind_ARRAYSIZE = SharedConfigMessage_Kind_Kind_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* SharedConfigMessage_Kind_descriptor(); +const std::string& SharedConfigMessage_Kind_Name(SharedConfigMessage_Kind value); template inline const std::string& SharedConfigMessage_Kind_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function SharedConfigMessage_Kind_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - SharedConfigMessage_Kind_descriptor(), enum_t_value); -} -inline bool SharedConfigMessage_Kind_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SharedConfigMessage_Kind* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - SharedConfigMessage_Kind_descriptor(), name, value); + return SharedConfigMessage_Kind_Name(static_cast(enum_t_value)); } +bool SharedConfigMessage_Kind_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SharedConfigMessage_Kind* value); enum GroupUpdateInfoChangeMessage_Type : int { GroupUpdateInfoChangeMessage_Type_NAME = 1, GroupUpdateInfoChangeMessage_Type_AVATAR = 2, @@ -439,20 +387,16 @@ constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage_Type_Ty constexpr GroupUpdateInfoChangeMessage_Type GroupUpdateInfoChangeMessage_Type_Type_MAX = GroupUpdateInfoChangeMessage_Type_DISAPPEARING_MESSAGES; constexpr int GroupUpdateInfoChangeMessage_Type_Type_ARRAYSIZE = GroupUpdateInfoChangeMessage_Type_Type_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateInfoChangeMessage_Type_descriptor(); +const std::string& GroupUpdateInfoChangeMessage_Type_Name(GroupUpdateInfoChangeMessage_Type value); template inline const std::string& GroupUpdateInfoChangeMessage_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function GroupUpdateInfoChangeMessage_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - GroupUpdateInfoChangeMessage_Type_descriptor(), enum_t_value); -} -inline bool GroupUpdateInfoChangeMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateInfoChangeMessage_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - GroupUpdateInfoChangeMessage_Type_descriptor(), name, value); + return GroupUpdateInfoChangeMessage_Type_Name(static_cast(enum_t_value)); } +bool GroupUpdateInfoChangeMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateInfoChangeMessage_Type* value); enum GroupUpdateMemberChangeMessage_Type : int { GroupUpdateMemberChangeMessage_Type_ADDED = 1, GroupUpdateMemberChangeMessage_Type_REMOVED = 2, @@ -463,24 +407,20 @@ constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage_Typ constexpr GroupUpdateMemberChangeMessage_Type GroupUpdateMemberChangeMessage_Type_Type_MAX = GroupUpdateMemberChangeMessage_Type_PROMOTED; constexpr int GroupUpdateMemberChangeMessage_Type_Type_ARRAYSIZE = GroupUpdateMemberChangeMessage_Type_Type_MAX + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GroupUpdateMemberChangeMessage_Type_descriptor(); +const std::string& GroupUpdateMemberChangeMessage_Type_Name(GroupUpdateMemberChangeMessage_Type value); template inline const std::string& GroupUpdateMemberChangeMessage_Type_Name(T enum_t_value) { static_assert(::std::is_same::value || ::std::is_integral::value, "Incorrect type passed to function GroupUpdateMemberChangeMessage_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - GroupUpdateMemberChangeMessage_Type_descriptor(), enum_t_value); -} -inline bool GroupUpdateMemberChangeMessage_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateMemberChangeMessage_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - GroupUpdateMemberChangeMessage_Type_descriptor(), name, value); + return GroupUpdateMemberChangeMessage_Type_Name(static_cast(enum_t_value)); } +bool GroupUpdateMemberChangeMessage_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, GroupUpdateMemberChangeMessage_Type* value); // =================================================================== class Envelope final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.Envelope) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.Envelope) */ { public: inline Envelope() : Envelope(nullptr) {} ~Envelope() override; @@ -510,22 +450,13 @@ class Envelope final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const Envelope& default_instance() { return *internal_default_instance(); } @@ -563,15 +494,9 @@ class Envelope final : Envelope* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const Envelope& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Envelope& from) { - Envelope::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const Envelope& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -584,7 +509,7 @@ class Envelope final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(Envelope* other); private: @@ -597,10 +522,7 @@ class Envelope final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -618,10 +540,6 @@ class Envelope final : Envelope_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = Envelope_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return Envelope_Type_descriptor(); - } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -778,7 +696,7 @@ class Envelope final : // ------------------------------------------------------------------- class TypingMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.TypingMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.TypingMessage) */ { public: inline TypingMessage() : TypingMessage(nullptr) {} ~TypingMessage() override; @@ -808,22 +726,13 @@ class TypingMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const TypingMessage& default_instance() { return *internal_default_instance(); } @@ -861,15 +770,9 @@ class TypingMessage final : TypingMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const TypingMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const TypingMessage& from) { - TypingMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const TypingMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -882,7 +785,7 @@ class TypingMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(TypingMessage* other); private: @@ -895,10 +798,7 @@ class TypingMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -916,10 +816,6 @@ class TypingMessage final : TypingMessage_Action_Action_MAX; static constexpr int Action_ARRAYSIZE = TypingMessage_Action_Action_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Action_descriptor() { - return TypingMessage_Action_descriptor(); - } template static inline const std::string& Action_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -986,7 +882,7 @@ class TypingMessage final : // ------------------------------------------------------------------- class UnsendRequest final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.UnsendRequest) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.UnsendRequest) */ { public: inline UnsendRequest() : UnsendRequest(nullptr) {} ~UnsendRequest() override; @@ -1016,22 +912,13 @@ class UnsendRequest final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const UnsendRequest& default_instance() { return *internal_default_instance(); } @@ -1069,15 +956,9 @@ class UnsendRequest final : UnsendRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const UnsendRequest& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const UnsendRequest& from) { - UnsendRequest::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const UnsendRequest& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1090,7 +971,7 @@ class UnsendRequest final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(UnsendRequest* other); private: @@ -1103,10 +984,7 @@ class UnsendRequest final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -1169,7 +1047,7 @@ class UnsendRequest final : // ------------------------------------------------------------------- class MessageRequestResponse final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.MessageRequestResponse) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.MessageRequestResponse) */ { public: inline MessageRequestResponse() : MessageRequestResponse(nullptr) {} ~MessageRequestResponse() override; @@ -1199,22 +1077,13 @@ class MessageRequestResponse final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const MessageRequestResponse& default_instance() { return *internal_default_instance(); } @@ -1252,15 +1121,9 @@ class MessageRequestResponse final : MessageRequestResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const MessageRequestResponse& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const MessageRequestResponse& from) { - MessageRequestResponse::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const MessageRequestResponse& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1273,7 +1136,7 @@ class MessageRequestResponse final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(MessageRequestResponse* other); private: @@ -1286,10 +1149,7 @@ class MessageRequestResponse final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -1369,7 +1229,7 @@ class MessageRequestResponse final : // ------------------------------------------------------------------- class Content final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.Content) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.Content) */ { public: inline Content() : Content(nullptr) {} ~Content() override; @@ -1399,22 +1259,13 @@ class Content final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const Content& default_instance() { return *internal_default_instance(); } @@ -1452,15 +1303,9 @@ class Content final : Content* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const Content& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Content& from) { - Content::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const Content& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1473,7 +1318,7 @@ class Content final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(Content* other); private: @@ -1486,10 +1331,7 @@ class Content final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -1509,10 +1351,6 @@ class Content final : Content_ExpirationType_ExpirationType_MAX; static constexpr int ExpirationType_ARRAYSIZE = Content_ExpirationType_ExpirationType_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - ExpirationType_descriptor() { - return Content_ExpirationType_descriptor(); - } template static inline const std::string& ExpirationType_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -1771,7 +1609,7 @@ class Content final : // ------------------------------------------------------------------- class CallMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.CallMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.CallMessage) */ { public: inline CallMessage() : CallMessage(nullptr) {} ~CallMessage() override; @@ -1801,22 +1639,13 @@ class CallMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const CallMessage& default_instance() { return *internal_default_instance(); } @@ -1854,15 +1683,9 @@ class CallMessage final : CallMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const CallMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const CallMessage& from) { - CallMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const CallMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1875,7 +1698,7 @@ class CallMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(CallMessage* other); private: @@ -1888,10 +1711,7 @@ class CallMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -1917,10 +1737,6 @@ class CallMessage final : CallMessage_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = CallMessage_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return CallMessage_Type_descriptor(); - } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -2068,7 +1884,7 @@ class CallMessage final : // ------------------------------------------------------------------- class KeyPair final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.KeyPair) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.KeyPair) */ { public: inline KeyPair() : KeyPair(nullptr) {} ~KeyPair() override; @@ -2098,22 +1914,13 @@ class KeyPair final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const KeyPair& default_instance() { return *internal_default_instance(); } @@ -2151,15 +1958,9 @@ class KeyPair final : KeyPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const KeyPair& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const KeyPair& from) { - KeyPair::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const KeyPair& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2172,7 +1973,7 @@ class KeyPair final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(KeyPair* other); private: @@ -2185,10 +1986,7 @@ class KeyPair final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -2256,7 +2054,7 @@ class KeyPair final : // ------------------------------------------------------------------- class DataExtractionNotification final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataExtractionNotification) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataExtractionNotification) */ { public: inline DataExtractionNotification() : DataExtractionNotification(nullptr) {} ~DataExtractionNotification() override; @@ -2286,22 +2084,13 @@ class DataExtractionNotification final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataExtractionNotification& default_instance() { return *internal_default_instance(); } @@ -2339,15 +2128,9 @@ class DataExtractionNotification final : DataExtractionNotification* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataExtractionNotification& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataExtractionNotification& from) { - DataExtractionNotification::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataExtractionNotification& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2360,7 +2143,7 @@ class DataExtractionNotification final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataExtractionNotification* other); private: @@ -2373,10 +2156,7 @@ class DataExtractionNotification final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -2394,10 +2174,6 @@ class DataExtractionNotification final : DataExtractionNotification_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = DataExtractionNotification_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return DataExtractionNotification_Type_descriptor(); - } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -2461,7 +2237,7 @@ class DataExtractionNotification final : // ------------------------------------------------------------------- class LokiProfile final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.LokiProfile) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.LokiProfile) */ { public: inline LokiProfile() : LokiProfile(nullptr) {} ~LokiProfile() override; @@ -2491,22 +2267,13 @@ class LokiProfile final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const LokiProfile& default_instance() { return *internal_default_instance(); } @@ -2544,15 +2311,9 @@ class LokiProfile final : LokiProfile* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const LokiProfile& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const LokiProfile& from) { - LokiProfile::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const LokiProfile& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2565,7 +2326,7 @@ class LokiProfile final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(LokiProfile* other); private: @@ -2578,10 +2339,7 @@ class LokiProfile final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -2646,7 +2404,7 @@ class LokiProfile final : // ------------------------------------------------------------------- class DataMessage_Quote_QuotedAttachment final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote.QuotedAttachment) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote.QuotedAttachment) */ { public: inline DataMessage_Quote_QuotedAttachment() : DataMessage_Quote_QuotedAttachment(nullptr) {} ~DataMessage_Quote_QuotedAttachment() override; @@ -2676,22 +2434,13 @@ class DataMessage_Quote_QuotedAttachment final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataMessage_Quote_QuotedAttachment& default_instance() { return *internal_default_instance(); } @@ -2729,15 +2478,9 @@ class DataMessage_Quote_QuotedAttachment final : DataMessage_Quote_QuotedAttachment* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataMessage_Quote_QuotedAttachment& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataMessage_Quote_QuotedAttachment& from) { - DataMessage_Quote_QuotedAttachment::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataMessage_Quote_QuotedAttachment& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2750,7 +2493,7 @@ class DataMessage_Quote_QuotedAttachment final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataMessage_Quote_QuotedAttachment* other); private: @@ -2763,10 +2506,7 @@ class DataMessage_Quote_QuotedAttachment final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -2782,10 +2522,6 @@ class DataMessage_Quote_QuotedAttachment final : DataMessage_Quote_QuotedAttachment_Flags_Flags_MAX; static constexpr int Flags_ARRAYSIZE = DataMessage_Quote_QuotedAttachment_Flags_Flags_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Flags_descriptor() { - return DataMessage_Quote_QuotedAttachment_Flags_descriptor(); - } template static inline const std::string& Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -2894,7 +2630,7 @@ class DataMessage_Quote_QuotedAttachment final : // ------------------------------------------------------------------- class DataMessage_Quote final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Quote) */ { public: inline DataMessage_Quote() : DataMessage_Quote(nullptr) {} ~DataMessage_Quote() override; @@ -2924,22 +2660,13 @@ class DataMessage_Quote final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataMessage_Quote& default_instance() { return *internal_default_instance(); } @@ -2977,15 +2704,9 @@ class DataMessage_Quote final : DataMessage_Quote* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataMessage_Quote& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataMessage_Quote& from) { - DataMessage_Quote::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataMessage_Quote& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2998,7 +2719,7 @@ class DataMessage_Quote final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataMessage_Quote* other); private: @@ -3011,10 +2732,7 @@ class DataMessage_Quote final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -3119,7 +2837,7 @@ class DataMessage_Quote final : // ------------------------------------------------------------------- class DataMessage_Preview final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Preview) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Preview) */ { public: inline DataMessage_Preview() : DataMessage_Preview(nullptr) {} ~DataMessage_Preview() override; @@ -3149,22 +2867,13 @@ class DataMessage_Preview final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataMessage_Preview& default_instance() { return *internal_default_instance(); } @@ -3202,15 +2911,9 @@ class DataMessage_Preview final : DataMessage_Preview* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataMessage_Preview& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataMessage_Preview& from) { - DataMessage_Preview::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataMessage_Preview& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3223,7 +2926,7 @@ class DataMessage_Preview final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataMessage_Preview* other); private: @@ -3236,10 +2939,7 @@ class DataMessage_Preview final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -3324,7 +3024,7 @@ class DataMessage_Preview final : // ------------------------------------------------------------------- class DataMessage_Reaction final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Reaction) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.Reaction) */ { public: inline DataMessage_Reaction() : DataMessage_Reaction(nullptr) {} ~DataMessage_Reaction() override; @@ -3354,22 +3054,13 @@ class DataMessage_Reaction final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataMessage_Reaction& default_instance() { return *internal_default_instance(); } @@ -3407,15 +3098,9 @@ class DataMessage_Reaction final : DataMessage_Reaction* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataMessage_Reaction& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataMessage_Reaction& from) { - DataMessage_Reaction::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataMessage_Reaction& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3428,7 +3113,7 @@ class DataMessage_Reaction final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataMessage_Reaction* other); private: @@ -3441,10 +3126,7 @@ class DataMessage_Reaction final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -3462,10 +3144,6 @@ class DataMessage_Reaction final : DataMessage_Reaction_Action_Action_MAX; static constexpr int Action_ARRAYSIZE = DataMessage_Reaction_Action_Action_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Action_descriptor() { - return DataMessage_Reaction_Action_descriptor(); - } template static inline const std::string& Action_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -3572,7 +3250,7 @@ class DataMessage_Reaction final : // ------------------------------------------------------------------- class DataMessage_OpenGroupInvitation final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.OpenGroupInvitation) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage.OpenGroupInvitation) */ { public: inline DataMessage_OpenGroupInvitation() : DataMessage_OpenGroupInvitation(nullptr) {} ~DataMessage_OpenGroupInvitation() override; @@ -3602,22 +3280,13 @@ class DataMessage_OpenGroupInvitation final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataMessage_OpenGroupInvitation& default_instance() { return *internal_default_instance(); } @@ -3655,15 +3324,9 @@ class DataMessage_OpenGroupInvitation final : DataMessage_OpenGroupInvitation* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataMessage_OpenGroupInvitation& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataMessage_OpenGroupInvitation& from) { - DataMessage_OpenGroupInvitation::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataMessage_OpenGroupInvitation& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3676,7 +3339,7 @@ class DataMessage_OpenGroupInvitation final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataMessage_OpenGroupInvitation* other); private: @@ -3689,10 +3352,7 @@ class DataMessage_OpenGroupInvitation final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -3760,7 +3420,7 @@ class DataMessage_OpenGroupInvitation final : // ------------------------------------------------------------------- class DataMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.DataMessage) */ { public: inline DataMessage() : DataMessage(nullptr) {} ~DataMessage() override; @@ -3790,22 +3450,13 @@ class DataMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const DataMessage& default_instance() { return *internal_default_instance(); } @@ -3843,15 +3494,9 @@ class DataMessage final : DataMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const DataMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const DataMessage& from) { - DataMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const DataMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3864,7 +3509,7 @@ class DataMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(DataMessage* other); private: @@ -3877,10 +3522,7 @@ class DataMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -3901,10 +3543,6 @@ class DataMessage final : DataMessage_Flags_Flags_MAX; static constexpr int Flags_ARRAYSIZE = DataMessage_Flags_Flags_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Flags_descriptor() { - return DataMessage_Flags_descriptor(); - } template static inline const std::string& Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -4183,7 +3821,7 @@ class DataMessage final : // ------------------------------------------------------------------- class ReceiptMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ReceiptMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ReceiptMessage) */ { public: inline ReceiptMessage() : ReceiptMessage(nullptr) {} ~ReceiptMessage() override; @@ -4213,22 +3851,13 @@ class ReceiptMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const ReceiptMessage& default_instance() { return *internal_default_instance(); } @@ -4266,15 +3895,9 @@ class ReceiptMessage final : ReceiptMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const ReceiptMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const ReceiptMessage& from) { - ReceiptMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const ReceiptMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4287,7 +3910,7 @@ class ReceiptMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(ReceiptMessage* other); private: @@ -4300,10 +3923,7 @@ class ReceiptMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -4321,10 +3941,6 @@ class ReceiptMessage final : ReceiptMessage_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = ReceiptMessage_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return ReceiptMessage_Type_descriptor(); - } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -4397,7 +4013,7 @@ class ReceiptMessage final : // ------------------------------------------------------------------- class AttachmentPointer final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.AttachmentPointer) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.AttachmentPointer) */ { public: inline AttachmentPointer() : AttachmentPointer(nullptr) {} ~AttachmentPointer() override; @@ -4427,22 +4043,13 @@ class AttachmentPointer final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const AttachmentPointer& default_instance() { return *internal_default_instance(); } @@ -4480,15 +4087,9 @@ class AttachmentPointer final : AttachmentPointer* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const AttachmentPointer& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const AttachmentPointer& from) { - AttachmentPointer::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const AttachmentPointer& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4501,7 +4102,7 @@ class AttachmentPointer final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(AttachmentPointer* other); private: @@ -4514,10 +4115,7 @@ class AttachmentPointer final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -4533,10 +4131,6 @@ class AttachmentPointer final : AttachmentPointer_Flags_Flags_MAX; static constexpr int Flags_ARRAYSIZE = AttachmentPointer_Flags_Flags_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Flags_descriptor() { - return AttachmentPointer_Flags_descriptor(); - } template static inline const std::string& Flags_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -4785,7 +4379,7 @@ class AttachmentPointer final : // ------------------------------------------------------------------- class SharedConfigMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.SharedConfigMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.SharedConfigMessage) */ { public: inline SharedConfigMessage() : SharedConfigMessage(nullptr) {} ~SharedConfigMessage() override; @@ -4815,22 +4409,13 @@ class SharedConfigMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const SharedConfigMessage& default_instance() { return *internal_default_instance(); } @@ -4868,15 +4453,9 @@ class SharedConfigMessage final : SharedConfigMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const SharedConfigMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const SharedConfigMessage& from) { - SharedConfigMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const SharedConfigMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4889,7 +4468,7 @@ class SharedConfigMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(SharedConfigMessage* other); private: @@ -4902,10 +4481,7 @@ class SharedConfigMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -4927,10 +4503,6 @@ class SharedConfigMessage final : SharedConfigMessage_Kind_Kind_MAX; static constexpr int Kind_ARRAYSIZE = SharedConfigMessage_Kind_Kind_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Kind_descriptor() { - return SharedConfigMessage_Kind_descriptor(); - } template static inline const std::string& Kind_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -5017,7 +4589,7 @@ class SharedConfigMessage final : // ------------------------------------------------------------------- class GroupUpdateMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMessage) */ { public: inline GroupUpdateMessage() : GroupUpdateMessage(nullptr) {} ~GroupUpdateMessage() override; @@ -5047,22 +4619,13 @@ class GroupUpdateMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateMessage& default_instance() { return *internal_default_instance(); } @@ -5100,15 +4663,9 @@ class GroupUpdateMessage final : GroupUpdateMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdateMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdateMessage& from) { - GroupUpdateMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdateMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5121,7 +4678,7 @@ class GroupUpdateMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdateMessage* other); private: @@ -5134,10 +4691,7 @@ class GroupUpdateMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -5322,7 +4876,7 @@ class GroupUpdateMessage final : // ------------------------------------------------------------------- class GroupUpdateInviteMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInviteMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInviteMessage) */ { public: inline GroupUpdateInviteMessage() : GroupUpdateInviteMessage(nullptr) {} ~GroupUpdateInviteMessage() override; @@ -5352,22 +4906,13 @@ class GroupUpdateInviteMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateInviteMessage& default_instance() { return *internal_default_instance(); } @@ -5405,15 +4950,9 @@ class GroupUpdateInviteMessage final : GroupUpdateInviteMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdateInviteMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdateInviteMessage& from) { - GroupUpdateInviteMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdateInviteMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5426,7 +4965,7 @@ class GroupUpdateInviteMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdateInviteMessage* other); private: @@ -5439,10 +4978,7 @@ class GroupUpdateInviteMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -5550,7 +5086,7 @@ class GroupUpdateInviteMessage final : // ------------------------------------------------------------------- class GroupUpdatePromoteMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdatePromoteMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdatePromoteMessage) */ { public: inline GroupUpdatePromoteMessage() : GroupUpdatePromoteMessage(nullptr) {} ~GroupUpdatePromoteMessage() override; @@ -5580,22 +5116,13 @@ class GroupUpdatePromoteMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdatePromoteMessage& default_instance() { return *internal_default_instance(); } @@ -5633,15 +5160,9 @@ class GroupUpdatePromoteMessage final : GroupUpdatePromoteMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdatePromoteMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdatePromoteMessage& from) { - GroupUpdatePromoteMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdatePromoteMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5654,7 +5175,7 @@ class GroupUpdatePromoteMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdatePromoteMessage* other); private: @@ -5667,10 +5188,7 @@ class GroupUpdatePromoteMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -5738,7 +5256,7 @@ class GroupUpdatePromoteMessage final : // ------------------------------------------------------------------- class GroupUpdateInfoChangeMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInfoChangeMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInfoChangeMessage) */ { public: inline GroupUpdateInfoChangeMessage() : GroupUpdateInfoChangeMessage(nullptr) {} ~GroupUpdateInfoChangeMessage() override; @@ -5768,22 +5286,13 @@ class GroupUpdateInfoChangeMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateInfoChangeMessage& default_instance() { return *internal_default_instance(); } @@ -5821,15 +5330,9 @@ class GroupUpdateInfoChangeMessage final : GroupUpdateInfoChangeMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdateInfoChangeMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdateInfoChangeMessage& from) { - GroupUpdateInfoChangeMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdateInfoChangeMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5842,7 +5345,7 @@ class GroupUpdateInfoChangeMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdateInfoChangeMessage* other); private: @@ -5855,10 +5358,7 @@ class GroupUpdateInfoChangeMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -5878,10 +5378,6 @@ class GroupUpdateInfoChangeMessage final : GroupUpdateInfoChangeMessage_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = GroupUpdateInfoChangeMessage_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return GroupUpdateInfoChangeMessage_Type_descriptor(); - } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -5988,7 +5484,7 @@ class GroupUpdateInfoChangeMessage final : // ------------------------------------------------------------------- class GroupUpdateMemberChangeMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberChangeMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberChangeMessage) */ { public: inline GroupUpdateMemberChangeMessage() : GroupUpdateMemberChangeMessage(nullptr) {} ~GroupUpdateMemberChangeMessage() override; @@ -6018,22 +5514,13 @@ class GroupUpdateMemberChangeMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateMemberChangeMessage& default_instance() { return *internal_default_instance(); } @@ -6071,15 +5558,9 @@ class GroupUpdateMemberChangeMessage final : GroupUpdateMemberChangeMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdateMemberChangeMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdateMemberChangeMessage& from) { - GroupUpdateMemberChangeMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdateMemberChangeMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6092,7 +5573,7 @@ class GroupUpdateMemberChangeMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdateMemberChangeMessage* other); private: @@ -6105,10 +5586,7 @@ class GroupUpdateMemberChangeMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -6128,10 +5606,6 @@ class GroupUpdateMemberChangeMessage final : GroupUpdateMemberChangeMessage_Type_Type_MAX; static constexpr int Type_ARRAYSIZE = GroupUpdateMemberChangeMessage_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return GroupUpdateMemberChangeMessage_Type_descriptor(); - } template static inline const std::string& Type_Name(T enum_t_value) { static_assert(::std::is_same::value || @@ -6244,9 +5718,10 @@ class GroupUpdateMemberChangeMessage final : // ------------------------------------------------------------------- class GroupUpdateMemberLeftMessage final : - public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberLeftMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberLeftMessage) */ { public: inline GroupUpdateMemberLeftMessage() : GroupUpdateMemberLeftMessage(nullptr) {} + ~GroupUpdateMemberLeftMessage() override; explicit PROTOBUF_CONSTEXPR GroupUpdateMemberLeftMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GroupUpdateMemberLeftMessage(const GroupUpdateMemberLeftMessage& from); @@ -6273,22 +5748,13 @@ class GroupUpdateMemberLeftMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateMemberLeftMessage& default_instance() { return *internal_default_instance(); } @@ -6326,15 +5792,23 @@ class GroupUpdateMemberLeftMessage final : GroupUpdateMemberLeftMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; - inline void CopyFrom(const GroupUpdateMemberLeftMessage& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); - } - using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; - void MergeFrom(const GroupUpdateMemberLeftMessage& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); - } - public: + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const GroupUpdateMemberLeftMessage& from); + void MergeFrom(const GroupUpdateMemberLeftMessage& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(GroupUpdateMemberLeftMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; @@ -6346,10 +5820,7 @@ class GroupUpdateMemberLeftMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -6363,15 +5834,18 @@ class GroupUpdateMemberLeftMessage final : typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; + union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- class GroupUpdateMemberLeftNotificationMessage final : - public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberLeftNotificationMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateMemberLeftNotificationMessage) */ { public: inline GroupUpdateMemberLeftNotificationMessage() : GroupUpdateMemberLeftNotificationMessage(nullptr) {} + ~GroupUpdateMemberLeftNotificationMessage() override; explicit PROTOBUF_CONSTEXPR GroupUpdateMemberLeftNotificationMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GroupUpdateMemberLeftNotificationMessage(const GroupUpdateMemberLeftNotificationMessage& from); @@ -6398,22 +5872,13 @@ class GroupUpdateMemberLeftNotificationMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateMemberLeftNotificationMessage& default_instance() { return *internal_default_instance(); } @@ -6451,15 +5916,23 @@ class GroupUpdateMemberLeftNotificationMessage final : GroupUpdateMemberLeftNotificationMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; - inline void CopyFrom(const GroupUpdateMemberLeftNotificationMessage& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); - } - using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; - void MergeFrom(const GroupUpdateMemberLeftNotificationMessage& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); - } - public: + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const GroupUpdateMemberLeftNotificationMessage& from); + void MergeFrom(const GroupUpdateMemberLeftNotificationMessage& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(GroupUpdateMemberLeftNotificationMessage* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; @@ -6471,10 +5944,7 @@ class GroupUpdateMemberLeftNotificationMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -6488,13 +5958,15 @@ class GroupUpdateMemberLeftNotificationMessage final : typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; + union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; }; // ------------------------------------------------------------------- class GroupUpdateInviteResponseMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInviteResponseMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateInviteResponseMessage) */ { public: inline GroupUpdateInviteResponseMessage() : GroupUpdateInviteResponseMessage(nullptr) {} ~GroupUpdateInviteResponseMessage() override; @@ -6524,22 +5996,13 @@ class GroupUpdateInviteResponseMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateInviteResponseMessage& default_instance() { return *internal_default_instance(); } @@ -6577,15 +6040,9 @@ class GroupUpdateInviteResponseMessage final : GroupUpdateInviteResponseMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdateInviteResponseMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdateInviteResponseMessage& from) { - GroupUpdateInviteResponseMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdateInviteResponseMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6598,7 +6055,7 @@ class GroupUpdateInviteResponseMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdateInviteResponseMessage* other); private: @@ -6611,10 +6068,7 @@ class GroupUpdateInviteResponseMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -6654,7 +6108,7 @@ class GroupUpdateInviteResponseMessage final : // ------------------------------------------------------------------- class GroupUpdateDeleteMemberContentMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateDeleteMemberContentMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.GroupUpdateDeleteMemberContentMessage) */ { public: inline GroupUpdateDeleteMemberContentMessage() : GroupUpdateDeleteMemberContentMessage(nullptr) {} ~GroupUpdateDeleteMemberContentMessage() override; @@ -6684,22 +6138,13 @@ class GroupUpdateDeleteMemberContentMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const GroupUpdateDeleteMemberContentMessage& default_instance() { return *internal_default_instance(); } @@ -6737,15 +6182,9 @@ class GroupUpdateDeleteMemberContentMessage final : GroupUpdateDeleteMemberContentMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const GroupUpdateDeleteMemberContentMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const GroupUpdateDeleteMemberContentMessage& from) { - GroupUpdateDeleteMemberContentMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const GroupUpdateDeleteMemberContentMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6758,7 +6197,7 @@ class GroupUpdateDeleteMemberContentMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(GroupUpdateDeleteMemberContentMessage* other); private: @@ -6771,10 +6210,7 @@ class GroupUpdateDeleteMemberContentMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -6871,261 +6307,23 @@ class GroupUpdateDeleteMemberContentMessage final : // ------------------------------------------------------------------- class ProProof final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ProProof) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProProof) */ { public: inline ProProof() : ProProof(nullptr) {} - ~ProProof() override; - explicit PROTOBUF_CONSTEXPR ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - ProProof(const ProProof& from); - ProProof(ProProof&& from) noexcept - : ProProof() { - *this = ::std::move(from); - } - - inline ProProof& operator=(const ProProof& from) { - CopyFrom(from); - return *this; - } - inline ProProof& operator=(ProProof&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const ProProof& default_instance() { - return *internal_default_instance(); - } - static inline const ProProof* internal_default_instance() { - return reinterpret_cast( - &_ProProof_default_instance_); - } - static constexpr int kIndexInFileMessages = - 27; - - friend void swap(ProProof& a, ProProof& b) { - a.Swap(&b); - } - inline void Swap(ProProof* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(ProProof* other) { - if (other == this) return; - GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const ProProof& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const ProProof& from) { - ProProof::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - uint8_t* _InternalSerialize( - uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(ProProof* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ProProof"; - } - protected: - explicit ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned = false); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kGenIndexHashFieldNumber = 2, - kRotatingPublicKeyFieldNumber = 3, - kSigFieldNumber = 5, - kExpiryUnixTsFieldNumber = 4, - kVersionFieldNumber = 1, - }; - // required bytes genIndexHash = 2; - bool has_genindexhash() const; - private: - bool _internal_has_genindexhash() const; - public: - void clear_genindexhash(); - const std::string& genindexhash() const; - template - void set_genindexhash(ArgT0&& arg0, ArgT... args); - std::string* mutable_genindexhash(); - PROTOBUF_NODISCARD std::string* release_genindexhash(); - void set_allocated_genindexhash(std::string* genindexhash); - private: - const std::string& _internal_genindexhash() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); - std::string* _internal_mutable_genindexhash(); - public: - - // required bytes rotatingPublicKey = 3; - bool has_rotatingpublickey() const; - private: - bool _internal_has_rotatingpublickey() const; - public: - void clear_rotatingpublickey(); - const std::string& rotatingpublickey() const; - template - void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); - std::string* mutable_rotatingpublickey(); - PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); - void set_allocated_rotatingpublickey(std::string* rotatingpublickey); - private: - const std::string& _internal_rotatingpublickey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); - std::string* _internal_mutable_rotatingpublickey(); - public: - - // required bytes sig = 5; - bool has_sig() const; - private: - bool _internal_has_sig() const; - public: - void clear_sig(); - const std::string& sig() const; - template - void set_sig(ArgT0&& arg0, ArgT... args); - std::string* mutable_sig(); - PROTOBUF_NODISCARD std::string* release_sig(); - void set_allocated_sig(std::string* sig); - private: - const std::string& _internal_sig() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); - std::string* _internal_mutable_sig(); - public: - - // required uint64 expiryUnixTs = 4; - bool has_expiryunixts() const; - private: - bool _internal_has_expiryunixts() const; - public: - void clear_expiryunixts(); - uint64_t expiryunixts() const; - void set_expiryunixts(uint64_t value); - private: - uint64_t _internal_expiryunixts() const; - void _internal_set_expiryunixts(uint64_t value); - public: - - // required uint32 version = 1; - bool has_version() const; - private: - bool _internal_has_version() const; - public: - void clear_version(); - uint32_t version() const; - void set_version(uint32_t value); - private: - uint32_t _internal_version() const; - void _internal_set_version(uint32_t value); - public: - - // @@protoc_insertion_point(class_scope:SessionProtos.ProProof) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; - uint64_t expiryunixts_; - uint32_t version_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_SessionProtos_2eproto; -}; -// ------------------------------------------------------------------- - -class ProConfig final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ProConfig) */ { - public: - inline ProConfig() : ProConfig(nullptr) {} - ~ProConfig() override; - explicit PROTOBUF_CONSTEXPR ProConfig(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + ~ProProof() override; + explicit PROTOBUF_CONSTEXPR ProProof(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - ProConfig(const ProConfig& from); - ProConfig(ProConfig&& from) noexcept - : ProConfig() { + ProProof(const ProProof& from); + ProProof(ProProof&& from) noexcept + : ProProof() { *this = ::std::move(from); } - inline ProConfig& operator=(const ProConfig& from) { + inline ProProof& operator=(const ProProof& from) { CopyFrom(from); return *this; } - inline ProConfig& operator=(ProConfig&& from) noexcept { + inline ProProof& operator=(ProProof&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE @@ -7139,36 +6337,27 @@ class ProConfig final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const ProConfig& default_instance() { + static const ProProof& default_instance() { return *internal_default_instance(); } - static inline const ProConfig* internal_default_instance() { - return reinterpret_cast( - &_ProConfig_default_instance_); + static inline const ProProof* internal_default_instance() { + return reinterpret_cast( + &_ProProof_default_instance_); } static constexpr int kIndexInFileMessages = - 28; + 27; - friend void swap(ProConfig& a, ProConfig& b) { + friend void swap(ProProof& a, ProProof& b) { a.Swap(&b); } - inline void Swap(ProConfig* other) { + inline void Swap(ProProof* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() != nullptr && @@ -7181,7 +6370,7 @@ class ProConfig final : ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); } } - void UnsafeArenaSwap(ProConfig* other) { + void UnsafeArenaSwap(ProProof* other) { if (other == this) return; GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); @@ -7189,18 +6378,12 @@ class ProConfig final : // implements Message ---------------------------------------------- - ProConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const ProConfig& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const ProConfig& from) { - ProConfig::MergeImpl(*this, from); + ProProof* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const ProProof& from); + void MergeFrom(const ProProof& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -7213,69 +6396,113 @@ class ProConfig final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(ProConfig* other); + void SetCachedSize(int size) const; + void InternalSwap(ProProof* other); private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "SessionProtos.ProConfig"; + return "SessionProtos.ProProof"; } protected: - explicit ProConfig(::PROTOBUF_NAMESPACE_ID::Arena* arena, + explicit ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { - kRotatingPrivKeyFieldNumber = 1, - kProofFieldNumber = 2, + kGenIndexHashFieldNumber = 2, + kRotatingPublicKeyFieldNumber = 3, + kSigFieldNumber = 5, + kExpiryUnixTsFieldNumber = 4, + kVersionFieldNumber = 1, }; - // required bytes rotatingPrivKey = 1; - bool has_rotatingprivkey() const; + // required bytes genIndexHash = 2; + bool has_genindexhash() const; private: - bool _internal_has_rotatingprivkey() const; + bool _internal_has_genindexhash() const; public: - void clear_rotatingprivkey(); - const std::string& rotatingprivkey() const; + void clear_genindexhash(); + const std::string& genindexhash() const; template - void set_rotatingprivkey(ArgT0&& arg0, ArgT... args); - std::string* mutable_rotatingprivkey(); - PROTOBUF_NODISCARD std::string* release_rotatingprivkey(); - void set_allocated_rotatingprivkey(std::string* rotatingprivkey); + void set_genindexhash(ArgT0&& arg0, ArgT... args); + std::string* mutable_genindexhash(); + PROTOBUF_NODISCARD std::string* release_genindexhash(); + void set_allocated_genindexhash(std::string* genindexhash); private: - const std::string& _internal_rotatingprivkey() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingprivkey(const std::string& value); - std::string* _internal_mutable_rotatingprivkey(); + const std::string& _internal_genindexhash() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_genindexhash(const std::string& value); + std::string* _internal_mutable_genindexhash(); public: - // required .SessionProtos.ProProof proof = 2; - bool has_proof() const; + // required bytes rotatingPublicKey = 3; + bool has_rotatingpublickey() const; private: - bool _internal_has_proof() const; + bool _internal_has_rotatingpublickey() const; public: - void clear_proof(); - const ::SessionProtos::ProProof& proof() const; - PROTOBUF_NODISCARD ::SessionProtos::ProProof* release_proof(); - ::SessionProtos::ProProof* mutable_proof(); - void set_allocated_proof(::SessionProtos::ProProof* proof); + void clear_rotatingpublickey(); + const std::string& rotatingpublickey() const; + template + void set_rotatingpublickey(ArgT0&& arg0, ArgT... args); + std::string* mutable_rotatingpublickey(); + PROTOBUF_NODISCARD std::string* release_rotatingpublickey(); + void set_allocated_rotatingpublickey(std::string* rotatingpublickey); private: - const ::SessionProtos::ProProof& _internal_proof() const; - ::SessionProtos::ProProof* _internal_mutable_proof(); + const std::string& _internal_rotatingpublickey() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_rotatingpublickey(const std::string& value); + std::string* _internal_mutable_rotatingpublickey(); + public: + + // required bytes sig = 5; + bool has_sig() const; + private: + bool _internal_has_sig() const; + public: + void clear_sig(); + const std::string& sig() const; + template + void set_sig(ArgT0&& arg0, ArgT... args); + std::string* mutable_sig(); + PROTOBUF_NODISCARD std::string* release_sig(); + void set_allocated_sig(std::string* sig); + private: + const std::string& _internal_sig() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_sig(const std::string& value); + std::string* _internal_mutable_sig(); + public: + + // required uint64 expiryUnixTs = 4; + bool has_expiryunixts() const; + private: + bool _internal_has_expiryunixts() const; + public: + void clear_expiryunixts(); + uint64_t expiryunixts() const; + void set_expiryunixts(uint64_t value); + private: + uint64_t _internal_expiryunixts() const; + void _internal_set_expiryunixts(uint64_t value); + public: + + // required uint32 version = 1; + bool has_version() const; + private: + bool _internal_has_version() const; + public: + void clear_version(); + uint32_t version() const; + void set_version(uint32_t value); + private: + uint32_t _internal_version() const; + void _internal_set_version(uint32_t value); public: - void unsafe_arena_set_allocated_proof( - ::SessionProtos::ProProof* proof); - ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // @@protoc_insertion_point(class_scope:SessionProtos.ProConfig) + // @@protoc_insertion_point(class_scope:SessionProtos.ProProof) private: class _Internal; @@ -7288,8 +6515,11 @@ class ProConfig final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingprivkey_; - ::SessionProtos::ProProof* proof_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr genindexhash_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rotatingpublickey_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr sig_; + uint64_t expiryunixts_; + uint32_t version_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; @@ -7297,7 +6527,7 @@ class ProConfig final : // ------------------------------------------------------------------- class ProMessage final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:SessionProtos.ProMessage) */ { + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SessionProtos.ProMessage) */ { public: inline ProMessage() : ProMessage(nullptr) {} ~ProMessage() override; @@ -7327,22 +6557,13 @@ class ProMessage final : return *this; } - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } static const ProMessage& default_instance() { return *internal_default_instance(); } @@ -7351,7 +6572,7 @@ class ProMessage final : &_ProMessage_default_instance_); } static constexpr int kIndexInFileMessages = - 29; + 28; friend void swap(ProMessage& a, ProMessage& b) { a.Swap(&b); @@ -7380,15 +6601,9 @@ class ProMessage final : ProMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage(arena); } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; void CopyFrom(const ProMessage& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const ProMessage& from) { - ProMessage::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: + void MergeFrom(const ProMessage& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -7401,7 +6616,7 @@ class ProMessage final : private: void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); - void SetCachedSize(int size) const final; + void SetCachedSize(int size) const; void InternalSwap(ProMessage* other); private: @@ -7414,10 +6629,7 @@ class ProMessage final : bool is_message_owned = false); public: - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + std::string GetTypeName() const final; // nested types ---------------------------------------------------- @@ -14447,168 +13659,6 @@ inline void ProProof::set_allocated_sig(std::string* sig) { // ------------------------------------------------------------------- -// ProConfig - -// required bytes rotatingPrivKey = 1; -inline bool ProConfig::_internal_has_rotatingprivkey() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool ProConfig::has_rotatingprivkey() const { - return _internal_has_rotatingprivkey(); -} -inline void ProConfig::clear_rotatingprivkey() { - _impl_.rotatingprivkey_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& ProConfig::rotatingprivkey() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.rotatingPrivKey) - return _internal_rotatingprivkey(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void ProConfig::set_rotatingprivkey(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.rotatingprivkey_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.ProConfig.rotatingPrivKey) -} -inline std::string* ProConfig::mutable_rotatingprivkey() { - std::string* _s = _internal_mutable_rotatingprivkey(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.rotatingPrivKey) - return _s; -} -inline const std::string& ProConfig::_internal_rotatingprivkey() const { - return _impl_.rotatingprivkey_.Get(); -} -inline void ProConfig::_internal_set_rotatingprivkey(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.rotatingprivkey_.Set(value, GetArenaForAllocation()); -} -inline std::string* ProConfig::_internal_mutable_rotatingprivkey() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.rotatingprivkey_.Mutable(GetArenaForAllocation()); -} -inline std::string* ProConfig::release_rotatingprivkey() { - // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.rotatingPrivKey) - if (!_internal_has_rotatingprivkey()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.rotatingprivkey_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingprivkey_.IsDefault()) { - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void ProConfig::set_allocated_rotatingprivkey(std::string* rotatingprivkey) { - if (rotatingprivkey != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.rotatingprivkey_.SetAllocated(rotatingprivkey, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.rotatingprivkey_.IsDefault()) { - _impl_.rotatingprivkey_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.rotatingPrivKey) -} - -// required .SessionProtos.ProProof proof = 2; -inline bool ProConfig::_internal_has_proof() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); - return value; -} -inline bool ProConfig::has_proof() const { - return _internal_has_proof(); -} -inline void ProConfig::clear_proof() { - if (_impl_.proof_ != nullptr) _impl_.proof_->Clear(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const ::SessionProtos::ProProof& ProConfig::_internal_proof() const { - const ::SessionProtos::ProProof* p = _impl_.proof_; - return p != nullptr ? *p : reinterpret_cast( - ::SessionProtos::_ProProof_default_instance_); -} -inline const ::SessionProtos::ProProof& ProConfig::proof() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProConfig.proof) - return _internal_proof(); -} -inline void ProConfig::unsafe_arena_set_allocated_proof( - ::SessionProtos::ProProof* proof) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.proof_); - } - _impl_.proof_ = proof; - if (proof) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.ProConfig.proof) -} -inline ::SessionProtos::ProProof* ProConfig::release_proof() { - _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::ProProof* temp = _impl_.proof_; - _impl_.proof_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::SessionProtos::ProProof* ProConfig::unsafe_arena_release_proof() { - // @@protoc_insertion_point(field_release:SessionProtos.ProConfig.proof) - _impl_._has_bits_[0] &= ~0x00000002u; - ::SessionProtos::ProProof* temp = _impl_.proof_; - _impl_.proof_ = nullptr; - return temp; -} -inline ::SessionProtos::ProProof* ProConfig::_internal_mutable_proof() { - _impl_._has_bits_[0] |= 0x00000002u; - if (_impl_.proof_ == nullptr) { - auto* p = CreateMaybeMessage<::SessionProtos::ProProof>(GetArenaForAllocation()); - _impl_.proof_ = p; - } - return _impl_.proof_; -} -inline ::SessionProtos::ProProof* ProConfig::mutable_proof() { - ::SessionProtos::ProProof* _msg = _internal_mutable_proof(); - // @@protoc_insertion_point(field_mutable:SessionProtos.ProConfig.proof) - return _msg; -} -inline void ProConfig::set_allocated_proof(::SessionProtos::ProProof* proof) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.proof_; - } - if (proof) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(proof); - if (message_arena != submessage_arena) { - proof = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, proof, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.proof_ = proof; - // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProConfig.proof) -} - -// ------------------------------------------------------------------- - // ProMessage // required .SessionProtos.ProProof proof = 1; @@ -14788,8 +13838,6 @@ inline void ProMessage::set_flags(uint32_t value) { // ------------------------------------------------------------------- -// ------------------------------------------------------------------- - // @@protoc_insertion_point(namespace_scope) @@ -14798,70 +13846,18 @@ inline void ProMessage::set_flags(uint32_t value) { PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::SessionProtos::Envelope_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::Envelope_Type>() { - return ::SessionProtos::Envelope_Type_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::TypingMessage_Action> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::TypingMessage_Action>() { - return ::SessionProtos::TypingMessage_Action_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::Content_ExpirationType> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::Content_ExpirationType>() { - return ::SessionProtos::Content_ExpirationType_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::CallMessage_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::CallMessage_Type>() { - return ::SessionProtos::CallMessage_Type_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::DataExtractionNotification_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataExtractionNotification_Type>() { - return ::SessionProtos::DataExtractionNotification_Type_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::DataMessage_Quote_QuotedAttachment_Flags> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataMessage_Quote_QuotedAttachment_Flags>() { - return ::SessionProtos::DataMessage_Quote_QuotedAttachment_Flags_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::DataMessage_Reaction_Action> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataMessage_Reaction_Action>() { - return ::SessionProtos::DataMessage_Reaction_Action_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::DataMessage_Flags> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::DataMessage_Flags>() { - return ::SessionProtos::DataMessage_Flags_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::ReceiptMessage_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::ReceiptMessage_Type>() { - return ::SessionProtos::ReceiptMessage_Type_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::AttachmentPointer_Flags> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::AttachmentPointer_Flags>() { - return ::SessionProtos::AttachmentPointer_Flags_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::SharedConfigMessage_Kind> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::SharedConfigMessage_Kind>() { - return ::SessionProtos::SharedConfigMessage_Kind_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::GroupUpdateInfoChangeMessage_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::GroupUpdateInfoChangeMessage_Type>() { - return ::SessionProtos::GroupUpdateInfoChangeMessage_Type_descriptor(); -} template <> struct is_proto_enum< ::SessionProtos::GroupUpdateMemberChangeMessage_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::SessionProtos::GroupUpdateMemberChangeMessage_Type>() { - return ::SessionProtos::GroupUpdateMemberChangeMessage_Type_descriptor(); -} PROTOBUF_NAMESPACE_CLOSE diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 98dcf025..4eb51e88 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -4,6 +4,8 @@ syntax = "proto2"; // iOS - package name determines class prefix package SessionProtos; +option optimize_for = LITE_RUNTIME; + message Envelope { enum Type { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2886d836..f9065d4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,9 +51,10 @@ add_libsession_util_library(crypto multi_encrypt.cpp random.cpp session_encrypt.cpp + session_protocol.cpp sodium_array.cpp xed25519.cpp - pro.cpp + pro_backend.cpp ) add_libsession_util_library(config diff --git a/src/config/internal.hpp b/src/config/internal.hpp index 3466a37a..2b843856 100644 --- a/src/config/internal.hpp +++ b/src/config/internal.hpp @@ -15,15 +15,6 @@ namespace session { -enum class SessionIDPrefix { - standard, - group, - community_blinded_legacy, - community_blinded, - version_blinded, - unblinded, -}; - inline constexpr std::string_view to_string(session::SessionIDPrefix prefix) { switch (prefix) { case session::SessionIDPrefix::unblinded: return "00"sv; diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 72a064ec..c67ac9df 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -149,12 +149,12 @@ bool ProConfig::load(const dict& root) { }; // namespace session::config // Ensure these are byte buffers and we can just use sizeof to build std::spans to interop with C++ -static_assert((sizeof((pro_pro*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); +static_assert((sizeof((pro_pro_config*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); static_assert((sizeof((pro_proof*)0)->gen_index_hash) == 32); static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); -LIBSESSION_C_API bool proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey) { +LIBSESSION_C_API bool pro_proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey) { auto verify_pubkey_span = std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); auto gen_index_hash = @@ -169,7 +169,7 @@ LIBSESSION_C_API bool proof_verify(pro_proof const* proof, uint8_t const* verify return result; } -LIBSESSION_C_API bool pro_verify(pro_pro const* pro, uint8_t const* verify_pubkey) { +LIBSESSION_C_API bool pro_pro_verify(pro_pro_config const* pro, uint8_t const* verify_pubkey) { auto verify_pubkey_span = std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); auto rotating_privkey = diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 5b3d1486..f2b05bef 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -5,6 +5,8 @@ #include "internal.hpp" #include "session/config/contacts.hpp" #include "session/config/error.h" +#include "session/config/pro.h" +#include "session/config/pro.hpp" #include "session/config/user_profile.hpp" #include "session/export.h" #include "session/types.hpp" @@ -147,7 +149,7 @@ std::chrono::sys_seconds UserProfile::get_profile_updated() const { return std::chrono::sys_seconds{}; } -std::optional UserProfile::get_pro_data() const { +std::optional UserProfile::get_pro_config() const { std::optional result = {}; if (const config::dict* s = data["s"].dict(); s) { ProConfig pro = {}; @@ -157,7 +159,7 @@ std::optional UserProfile::get_pro_data() const { return result; } -void UserProfile::set_pro_data(ProConfig const &pro) { +void UserProfile::set_pro_config(ProConfig const &pro) { auto root = data["s"]; root["r"] = pro.rotating_privkey; @@ -276,4 +278,43 @@ LIBSESSION_C_API int64_t user_profile_get_profile_updated(config_object* conf) { return unbox(conf)->get_profile_updated().time_since_epoch().count(); } +LIBSESSION_C_API bool user_profile_get_pro_data(const config_object* conf, pro_pro_config *pro) { + if (auto val = unbox(conf)->get_pro_config(); val) { + static_assert(sizeof pro->proof.gen_index_hash == sizeof(val->proof.gen_index_hash)); + static_assert(sizeof pro->proof.rotating_pubkey == sizeof(val->proof.rotating_pubkey)); + static_assert(sizeof pro->proof.sig == sizeof(val->proof.sig)); + pro->proof.version = val->proof.version; + std::memcpy( + pro->proof.gen_index_hash, + val->proof.gen_index_hash.data(), + val->proof.gen_index_hash.size()); + std::memcpy( + pro->proof.rotating_pubkey, + val->proof.rotating_pubkey.data(), + val->proof.rotating_pubkey.size()); + pro->proof.expiry_unix_ts = val->proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro->proof.sig, val->proof.sig.data(), val->proof.sig.size()); + return true; + } + return false; +} + +LIBSESSION_C_API void user_profile_set_pro_data(config_object* conf, const pro_pro_config *pro) { + ProConfig val = {}; + val.proof.version = pro->proof.version; + std::memcpy( + val.proof.gen_index_hash.data(), + pro->proof.gen_index_hash, + val.proof.gen_index_hash.size()); + std::memcpy( + val.proof.rotating_pubkey.data(), + pro->proof.rotating_pubkey, + val.proof.rotating_pubkey.size()); + val.proof.expiry_unix_ts = + std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts)); + std::memcpy(val.proof.sig.data(), pro->proof.sig, val.proof.sig.size()); + unbox(conf)->set_pro_config(val); +} + + } // extern "C" diff --git a/src/pro.cpp b/src/pro_backend.cpp similarity index 55% rename from src/pro.cpp rename to src/pro_backend.cpp index f629dc21..97e1cd06 100644 --- a/src/pro.cpp +++ b/src/pro_backend.cpp @@ -4,14 +4,12 @@ #include #include -#include +#include #include -#include -#include "SessionProtos.pb.h" -namespace session::pro { +namespace session::pro_backend { -static_assert(BACKEND_PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert(PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); master_rotating_sigs build_get_proof_sigs( const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts) { // Derive the public keys @@ -107,69 +105,4 @@ std::string add_payment_request::to_json() const { oxenc::to_hex(rotating_sig)); return result; } - -DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( - std::span ed25519_privkey, - std::span ciphertext, - std::chrono::sys_seconds unix_ts) { - DecryptIncomingWithPro result = {}; - std::tie(result.plaintext, result.ed25519_pubkey) = session::decrypt_incoming(ed25519_privkey, ciphertext); - - SessionProtos::Content content = {}; - if (!content.ParseFromArray(result.plaintext.data(), result.plaintext.size())) - throw std::runtime_error{"Parse decrypted message for pro metadata failed"}; - - if (content.has_promessageconfig()) { - const SessionProtos::ProMessageConfig& config = content.promessageconfig(); - if (!config.has_proof()) - throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); - if (!config.has_flags()) - throw std::runtime_error("Parse decrypted message failed, pro config missing flags"); - - const SessionProtos::ProProof& proto_proof = config.proof(); - std::uint32_t proto_flags = config.flags(); - - if ((proto_flags & ~session::pro::FeatureFlag_All) > 0) - throw std::runtime_error("Parse decrypted message failed, pro config specified invalid flags"); - - // Parse the proof from protobufs - session::config::ProProof& proof = result.pro_proof; - // clang-format off - size_t proof_errors = 0; - proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); - proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); - proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); - proof_errors += !proto_proof.has_expiryunixts(); - proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); - // clang-format on - - if (proof_errors == 0) - throw std::runtime_error("Parse decrypted message failed, pro metadata was malformed"); - - // Fill out result, we have parsed successfully - result.pro_flags = proto_flags; - - std::memcpy( - proof.gen_index_hash.data(), - proto_proof.genindexhash().data(), - proto_proof.genindexhash().size()); - std::memcpy( - proof.rotating_pubkey.data(), - proto_proof.rotatingpublickey().data(), - proto_proof.rotatingpublickey().size()); - proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); - std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); - - if (proof.verify(session::pro::BACKEND_PUBKEY)) - result.pro_status = Status::Valid; - - if (result.pro_status == Status::Valid) { - if (unix_ts >= result.pro_proof.expiry_unix_ts) - result.pro_status = Status::Expired; - } - } - return result; -} - } // namespace session::pro diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index b1003d66..36246618 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -1033,4 +1033,4 @@ LIBSESSION_C_API bool session_decrypt_xchacha20( } } -} // extern "C" \ No newline at end of file +} // extern "C" diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp new file mode 100644 index 00000000..f350a76e --- /dev/null +++ b/src/session_protocol.cpp @@ -0,0 +1,305 @@ +#include + +#include +#include +#include +#include +#include +#include + +#include "SessionProtos.pb.h" +#include "WebSocketResources.pb.h" + +namespace session { + +ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures extra) { + ProFeatures result = session_pro_features_nil; + if (msg.size() >= SESSION_PRO_10k_CHARACTER_LIMIT) + result |= session_pro_features_10k_character_limit; + if (extra & session_pro_extra_features_animated_avatar) + result |= session_pro_features_animated_avatar; + if (extra & session_pro_extra_features_pro_badge) + result |= session_pro_features_pro_badge; + return result; +} + +array_uc64 sign_msg_for_pro(std::span msg, const array_uc64& rotating_priv_key) { + // Sign the msg with the rotating public pro key and the pro proof if given + array_uc64 result = {}; + static_assert(result.max_size() == crypto_sign_ed25519_BYTES); + crypto_sign_ed25519_detached(result.data(), nullptr, msg.data(), msg.size(), rotating_priv_key.data()); + return result; +} + +std::vector encrypt_for_namespaced_destination( + std::span plaintext, + std::span ed25519_privkey, + const Destination& dest, + config::Namespace space) { + + enum class Mode { + Envelope, + Plaintext, + EncryptForBlindedRecipient, + }; + + enum class AfterEnvelope { + Nil, + EnvelopeIsCipherText, + WrapInWSMessage, + KeysEncryptMessage, + }; + + struct EncodeContext { + Mode mode; + + // Parameters for BuildMode => Envelope + bool before_envelope_encrypt_for_recipient_deterministic; + std::vector before_envelope_ciphertext; + std::optional> envelope_src; + std::optional envelope_type; + AfterEnvelope after_envelope; + }; + + // Figure out how to encrypt the message based on the destination and setup the encoding context + EncodeContext enc = {}; + switch (dest.type) { + case DestinationType::ClosedGroup: { + bool has_03_prefix = + dest.closed_group_pubkey[0] == static_cast(SessionIDPrefix::group); + if (has_03_prefix) { + if (space == config::Namespace::GroupMessages) { + if (!dest.closed_group_keys) + throw std::runtime_error( + "API misuse: Sending to a closed group into the group messages " + "namespace requires the closed group keys to be set"); + enc.mode = Mode::Envelope; + enc.after_envelope = AfterEnvelope::KeysEncryptMessage; + enc.envelope_type = + SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; + } else if (space == config::Namespace::RevokedRetrievableGroupMessages) { + enc.mode = Mode::Plaintext; + } else { + // Config messages should be sent directly rather than via this method (just + // return plaintext and no-op). See: + // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L494 + enc.mode = Mode::Plaintext; + } + } else { + enc.mode = Mode::Envelope; + enc.before_envelope_encrypt_for_recipient_deterministic = true; + enc.envelope_type = + SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; + enc.after_envelope = AfterEnvelope::WrapInWSMessage; + + if (!dest.closed_group_swarm_public_key) + throw std::runtime_error( + "API misuse: Closed group swarm public key must be set on non 0x03 " + "prefixed group keys"); + enc.envelope_src = *dest.closed_group_swarm_public_key; + } + } break; + + case DestinationType::Contact: { + if (space == config::Namespace::Default) { + enc.mode = Mode::Envelope; + enc.before_envelope_encrypt_for_recipient_deterministic = true; + enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; + enc.after_envelope = AfterEnvelope::EnvelopeIsCipherText; + } else { + // Config messages should be sent directly rather than via this method (return just + // the plaintext and no-op) See: + // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L498 + enc.mode = Mode::Plaintext; + } + } break; + + case DestinationType::SyncMessage: { + enc.mode = Mode::Envelope; + enc.before_envelope_encrypt_for_recipient_deterministic = true; + enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; + enc.after_envelope = AfterEnvelope::EnvelopeIsCipherText; + } break; + + case DestinationType::OpenGroup: { + enc.mode = Mode::Plaintext; + } break; + + case DestinationType::OpenGroupInbox: { + enc.mode = Mode::EncryptForBlindedRecipient; + } break; + } + + // Do the encryption work + std::vector result; + switch (enc.mode) { + case Mode::Envelope: { + assert(enc.envelope_type.has_value()); + std::span src_text = plaintext; + if (enc.before_envelope_encrypt_for_recipient_deterministic) { + enc.before_envelope_ciphertext = session::encrypt_for_recipient_deterministic( + ed25519_privkey, dest.recipient_pubkey, plaintext); + src_text = enc.before_envelope_ciphertext; + } + + // Create envelope + // Set sourcedevice to 1 as per: + // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Utilities/MessageWrapper.swift#L57 + SessionProtos::Envelope envelope = {}; + envelope.set_type(*enc.envelope_type); + envelope.set_sourcedevice(1); + envelope.set_timestamp(dest.sent_timestamp_ms.count()); + envelope.set_content(src_text.data(), src_text.size()); + if (enc.envelope_src) + envelope.set_source(reinterpret_cast(enc.envelope_src->data()), enc.envelope_src->size()); + if (dest.pro_sig) + envelope.set_prosig(reinterpret_cast(dest.pro_sig->data()), dest.pro_sig->size()); + + switch (enc.after_envelope) { + case AfterEnvelope::Nil: + assert(false && "Dev error, after envelope action was not set"); + break; + + case AfterEnvelope::WrapInWSMessage: { + // Make request + WebSocketProtos::WebSocketRequestMessage req_msg = {}; + req_msg.set_body(envelope.SerializeAsString()); + + // Put into message + WebSocketProtos::WebSocketMessage msg = {}; + msg.set_type( + WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); + msg.set_allocated_request(&req_msg); + + // Write message as ciphertext + result.resize(msg.ByteSizeLong()); + msg.SerializeToArray(result.data(), result.size()); + } break; + + case AfterEnvelope::KeysEncryptMessage: { + assert(dest.closed_group_keys && + "Dev error, API miuse was not detected. We should throw an exception " + "when this happens"); + + std::string bytes = envelope.SerializeAsString(); + result = dest.closed_group_keys->encrypt_message( + std::span( + reinterpret_cast(bytes.data()), bytes.size())); + } break; + + case AfterEnvelope::EnvelopeIsCipherText: { + result.resize(envelope.ByteSizeLong()); + envelope.SerializeToArray(result.data(), result.size()); + } break; + } + } break; + + case Mode::Plaintext: { + result = std::vector(plaintext.begin(), plaintext.end()); + } break; + + case Mode::EncryptForBlindedRecipient: { + result = encrypt_for_blinded_recipient( + ed25519_privkey, + dest.open_group_inbox_server_pubkey, + dest.recipient_pubkey, // recipient blinded pubkey + plaintext); + } break; + } + + return result; +} + +DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( + std::span ed25519_privkey, + std::span ciphertext, + std::chrono::sys_seconds unix_ts) { + DecryptIncomingWithPro result = {}; + + SessionProtos::Envelope envelope = {}; + if (!envelope.ParseFromArray(ciphertext.data(), ciphertext.size())) + throw std::runtime_error{"Parse envelope from ciphertext failed"}; + + if (!envelope.has_content()) + throw std::runtime_error{"Parse decrypted message failed, missing content"}; + + const std::string& content_str = envelope.content(); + auto content_span = std::span( + reinterpret_cast(content_str.data()), content_str.size()); + std::tie(result.plaintext, result.ed25519_pubkey) = + session::decrypt_incoming(ed25519_privkey, content_span); + + SessionProtos::Content content = {}; + if (!envelope.ParseFromArray(result.plaintext.data(), result.plaintext.size())) + throw std::runtime_error{"Parse content from envelope failed"}; + + if (content.has_promessage()) { + // Parse the signature from the envelope if the content had a pro component to it + if (!envelope.has_prosig()) + throw std::runtime_error("Parse envelope failed, pro message is missing signature"); + + const std::string& pro_sig = envelope.prosig(); + if (pro_sig.size() != crypto_sign_ed25519_BYTES) + throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); + + SessionProtos::ProMessage pro_msg = content.promessage(); + if (!pro_msg.has_proof()) + throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); + if (!pro_msg.has_flags()) + throw std::runtime_error("Parse decrypted message failed, pro config missing flags"); + + const SessionProtos::ProProof& proto_proof = pro_msg.proof(); + std::uint32_t proto_flags = pro_msg.flags(); + + // Parse the proof from protobufs + session::config::ProProof& proof = result.pro_proof; + // clang-format off + size_t proof_errors = 0; + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); + proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); + proof_errors += !proto_proof.has_expiryunixts(); + proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); + // clang-format on + if (proof_errors) + throw std::runtime_error("Parse decrypted message failed, pro metadata was malformed"); + + // Verify the sig since we have extracted the rotating public key from the embedded proof + int verify_result = crypto_sign_ed25519_verify_detached( + reinterpret_cast(pro_sig.data()), + reinterpret_cast(content_str.data()), + content_str.size(), + reinterpret_cast(proto_proof.rotatingpublickey().data())); + if (verify_result != 0) + throw std::runtime_error("Parse decrypted message failed, pro signature is invalid"); + + // Fill out the resulting proof structure, we have parsed successfully + result.pro_flags = proto_flags; + std::memcpy(result.pro_sig.data(), pro_sig.data(), pro_sig.size()); + + std::memcpy( + proof.gen_index_hash.data(), + proto_proof.genindexhash().data(), + proto_proof.genindexhash().size()); + std::memcpy( + proof.rotating_pubkey.data(), + proto_proof.rotatingpublickey().data(), + proto_proof.rotatingpublickey().size()); + proof.expiry_unix_ts = + std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); + std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); + + // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It has been + // authorised by the backend as having a valid backing payment). + if (proof.verify(session::pro_backend::PUBKEY)) + result.pro_status = ProStatus::Valid; + + // Check if the proof has expired + if (result.pro_status == ProStatus::Valid) { + if (unix_ts >= result.pro_proof.expiry_unix_ts) + result.pro_status = ProStatus::Expired; + } + } + return result; +} +} // namespace session From 855da0915418e1b06dcae49f550c6a3aef3997ab Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 8 Aug 2025 17:02:59 +1000 Subject: [PATCH 016/171] Update decrypt function to return the envelope and the metadata --- include/session/session_protocol.hpp | 47 ++++++++++++++++------ src/session_protocol.cpp | 59 ++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 18 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 5296a80f..9a60be7c 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -60,19 +60,44 @@ struct Destination { using ProFeatures = session_pro_features; using ProExtraFeatures = session_pro_extra_features; -struct DecryptIncomingWithPro +enum class EnvelopeType { - std::vector plaintext; - std::vector ed25519_pubkey; - config::ProProof pro_proof; - ProStatus pro_status; - session_pro_features pro_flags; + SessionMessage, + ClosedGroupMessage, +}; + +typedef uint32_t EnvelopeFlags; +enum EnvelopeFlags_ +{ + EnvelopeFlags_Source = 1 << 0, + EnvelopeFlags_SourceDevice = 1 << 1, + EnvelopeFlags_ServerTimestamp = 1 << 2, + EnvelopeFlags_ProSig = 1 << 3, +}; + +struct Envelope +{ + EnvelopeFlags flags; + EnvelopeType type; + uint64_t timestamp; + + // Optional fields + array_uc33 source; + uint32_t source_device; + uint64_t server_timestamp; array_uc64 pro_sig; }; -struct PrepareMsgForPro { - ProFeatures flags; - array_uc64 sig; +struct DecryptedEnvelope +{ + Envelope envelope; + std::vector content_plaintext; + std::vector sender_ed25519_pubkey; + + config::ProProof pro_proof; + ProStatus pro_status; + ProFeatures pro_flags; + array_uc64 pro_sig; }; ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures flags); @@ -86,8 +111,8 @@ std::vector encrypt_for_namespaced_destination( const Destination& dest, config::Namespace space); -DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( +DecryptedEnvelope decrypt_envelope( std::span ed25519_privkey, - std::span ciphertext, + std::span envelope_plaintext, std::chrono::sys_seconds unix_ts); } // namespace session diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index f350a76e..2f465fc1 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -210,27 +211,67 @@ std::vector encrypt_for_namespaced_destination( return result; } -DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( +DecryptedEnvelope decrypt_envelope( std::span ed25519_privkey, - std::span ciphertext, + std::span envelope_plaintext, std::chrono::sys_seconds unix_ts) { - DecryptIncomingWithPro result = {}; - + DecryptedEnvelope result = {}; SessionProtos::Envelope envelope = {}; - if (!envelope.ParseFromArray(ciphertext.data(), ciphertext.size())) + if (!envelope.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) throw std::runtime_error{"Parse envelope from ciphertext failed"}; + // Parse type (unconditionallty) + if (!envelope.has_type()) + throw std::runtime_error("Parse envelope failed, missing type"); + + switch (envelope.type()) { + case SessionProtos::Envelope_Type_SESSION_MESSAGE: + result.envelope.type = EnvelopeType::SessionMessage; + break; + + case SessionProtos::Envelope_Type_CLOSED_GROUP_MESSAGE: + result.envelope.type = EnvelopeType::ClosedGroupMessage; + break; + } + + // Parse source (optional) + if (envelope.has_source()) { + // Libsession is now responsible for creating the envelope. The only data that we send in + // the source is a Session public key (see: encrypt_for_namespaced_destination) + const std::string& source = envelope.source(); + if (source.size() != result.envelope.source.max_size()) + throw std::runtime_error( + fmt::format( + "Parse envelope failed, source had unexpected size ({} bytes)", + source.size())); + std::memcpy(result.envelope.source.data(), source.data(), source.size()); + result.envelope.flags |= EnvelopeFlags_Source; + } + + // Parse source device (optional) + if (envelope.has_sourcedevice()) { + result.envelope.source_device = envelope.sourcedevice(); + result.envelope.flags |= EnvelopeFlags_SourceDevice; + } + + // Parse server timestamp (optional) + if (envelope.has_servertimestamp()) { + result.envelope.server_timestamp = envelope.servertimestamp(); + result.envelope.flags |= EnvelopeFlags_ServerTimestamp; + } + + // Parse content (unconditionallty) if (!envelope.has_content()) throw std::runtime_error{"Parse decrypted message failed, missing content"}; const std::string& content_str = envelope.content(); auto content_span = std::span( reinterpret_cast(content_str.data()), content_str.size()); - std::tie(result.plaintext, result.ed25519_pubkey) = + std::tie(result.content_plaintext, result.sender_ed25519_pubkey) = session::decrypt_incoming(ed25519_privkey, content_span); SessionProtos::Content content = {}; - if (!envelope.ParseFromArray(result.plaintext.data(), result.plaintext.size())) + if (!envelope.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) throw std::runtime_error{"Parse content from envelope failed"}; if (content.has_promessage()) { @@ -242,6 +283,10 @@ DecryptIncomingWithPro decrypt_incoming_with_pro_metadata( if (pro_sig.size() != crypto_sign_ed25519_BYTES) throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); + static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); + std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); + result.envelope.flags |= EnvelopeFlags_ProSig; + SessionProtos::ProMessage pro_msg = content.promessage(); if (!pro_msg.has_proof()) throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); From 030f072b9a55f0d101612972e8dee107ca568575 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 8 Aug 2025 17:52:27 +1000 Subject: [PATCH 017/171] Add documentation for new session protocol functions --- include/session/session_protocol.hpp | 151 ++++++++++++++++++++++----- src/session_protocol.cpp | 54 +++++----- 2 files changed, 149 insertions(+), 56 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 9a60be7c..82a63353 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include + +#include #include #include @@ -21,7 +22,6 @@ enum class ProStatus { Expired, // Pro proof was set, is verified; has expired }; - enum class DestinationType { Contact, SyncMessage, @@ -34,14 +34,17 @@ struct Destination { DestinationType type; // Signature over the plaintext with the user's Session Pro rotating public key if they have - // Session Pro and opt into sending a message with pro features. + // Session Pro and opt into sending a message with pro features. If this is specified, the pro + // message component in `Content` must have been set with the corresponding proof for this + // signature. std::optional pro_sig; // Set to the recipient of the message if it requires one. Ignored otherwise (for example // ignored in OpenGroup) array_uc32 recipient_pubkey; - // The timestamp to assign to the message envelope if the message requires one. Ignored otherwise + // The timestamp to assign to the message envelope if the message requires one. Ignored + // otherwise std::chrono::milliseconds sent_timestamp_ms; // When type => OpenGroupInbox: set this pubkey to the server's key @@ -49,7 +52,7 @@ struct Destination { // When type => ClosedGroup: set the following 'closed_group' prefixed fields array_uc33 closed_group_pubkey; - const session::config::groups::Keys *closed_group_keys; + const session::config::groups::Keys* closed_group_keys; // Set to the closed group's swarm public key (needed for Android) for a non 0x03 prefixed // `closed_group_pubkey`. Ignored otherwise. This will be set as the envelope source. See: @@ -57,62 +60,156 @@ struct Destination { std::optional closed_group_swarm_public_key; }; -using ProFeatures = session_pro_features; -using ProExtraFeatures = session_pro_extra_features; - -enum class EnvelopeType -{ - SessionMessage, - ClosedGroupMessage, +enum class EnvelopeType { + SessionMessage, + ClosedGroupMessage, }; typedef uint32_t EnvelopeFlags; -enum EnvelopeFlags_ -{ +enum EnvelopeFlags_ { EnvelopeFlags_Source = 1 << 0, EnvelopeFlags_SourceDevice = 1 << 1, EnvelopeFlags_ServerTimestamp = 1 << 2, EnvelopeFlags_ProSig = 1 << 3, }; -struct Envelope -{ +struct Envelope { EnvelopeFlags flags; EnvelopeType type; uint64_t timestamp; - // Optional fields + /// Optional fields. These fields are set if the appropriate flag has been set in `flags` + /// otherwise the corresponding values are to be ignored and those fields will be + /// zero-initialised. array_uc33 source; uint32_t source_device; uint64_t server_timestamp; array_uc64 pro_sig; }; -struct DecryptedEnvelope -{ +using ProFeatures = session_pro_features; +using ProExtraFeatures = session_pro_extra_features; + +struct DecryptedEnvelope { + // The envelope parsed from the plaintext Envelope envelope; + + // Decrypted envelope content into plaintext std::vector content_plaintext; + + // Sender public key extracted from the encrypted content payload std::vector sender_ed25519_pubkey; - config::ProProof pro_proof; + // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. + // The status is set to `Nil` if there is no Session Pro proof in the message. Otherwise it's + // set to one of the other values to which the remaining pro fields will be populated with data + // parsed from the envelope. ProStatus pro_status; - ProFeatures pro_flags; - array_uc64 pro_sig; + + // The embedded Session Pro proof, only set if the status was not `Nil`. + config::ProProof pro_proof; + + // Session Pro features that were used in the embedded message, only set if the status was not + // `Nil`. + ProFeatures pro_features; }; -ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures flags); +struct EncryptedForNamespaceDest +{ + // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to + // the destination and namespace does not require encryption. In this case `ciphertext` is not + // set and the user should proceed with the original plaintext. + bool encrypted; + + // The plaintext encrypted in a manner suitable for the desired destination and namespace. This + // is not set if `encrypted` is false. + std::vector ciphertext; +}; -array_uc64 sign_msg_for_pro( - std::span msg, const array_uc64& rotating_priv_key); +/// API: session_protocol/get_pro_features_for_msg +/// +/// Determine the Pro features that are used in a given conversation message. +/// +/// Inputs: +/// - `msg` -- the conversation message to determine if the message is requires access to the 10k +/// character limit available in Session Pro +/// - `flags` -- extra pro features that are known by clients that they wish to be activated on +/// this message +/// +/// Outputs: +/// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in +/// `Content` +ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures flags); -std::vector encrypt_for_namespaced_destination( +/// API: session_protocol/encrypt_for_namespaced_destination +/// +/// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of +/// `Content`), encrypt and/or wrap the plaintext in the necessary structures for transmission on +/// the Session Protocol. +/// +/// This function supports all combinatoric combinations of the destination type and namespace +/// including returning plaintext if the message is not meant to be encrypted and or wrapping in the +/// additional websocket wrapper or encrypting the envelope with the closed group keys if necessary +/// e.t.c. +/// +/// Calling this function requires filling out the options in the `Destination` struct with the +/// appropriate values for the desired combination of destination type and namespace. Check the +/// annotation on `Destination` for more information. +/// +/// This function throws if the API is misused (i.e.: A field was not set, but was required to be +/// set for the given destination and namespace. For example the closed group keys not being set +/// when sending to a group prefixed [0x3] key in a closed group into the group message namespace) +/// but otherwise always returns a struct with values. +/// +/// Inputs: +/// - `plaintext` -- the protobuf serialised payload containing the protobuf encoded stream, +/// `Content`. It must not be already be encrypted. +/// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be +/// passed as a 32-byte seed. Used to encrypt the plaintext. +/// - `dest` -- the extra metadata indicating the destination of the message and the necessary data +/// to encrypt a message for that destination. +/// - `space` -- the namespace to encrypt the message for +/// +/// Outputs: +/// - The encryption result for the plaintext. If the destination and namespace combination did not +/// require encryption, no payload is returned in the ciphertext and the user should proceed with +/// the plaintext. This should be validated by checking the `encrypted` flag on the result. +EncryptedForNamespaceDest encrypt_for_namespaced_destination( std::span plaintext, std::span ed25519_privkey, const Destination& dest, config::Namespace space); +/// API: session_protocol/decrypt_envelope +/// +/// Given an unencrypted plaintext representation of an envelope (i.e.: protobuf encoded stream of +/// `Envelope`) parse the envelope and return the envelope content decrypted to plaintext with the +/// passed in key. +/// +/// If the message does not use Session Pro features, the pro status will be set to nil and all +/// other pro fields are to be ignored. If the pro status is non-nil then the pro fields will be +/// populated with data about the Session Pro proof embedded in the envelope including the features +/// used and if the proof was valid/expired e.t.c. +/// +/// This function will throw if parsing failed such as a required field is missing, the field is +/// smaller or larger than expected, decryption failed, or an invariant failed. Notably this +/// function does not throw if the Session Pro proof failed to verify. Always check the pro status +/// field to verify if the Session Pro was present and/or valid or invalid. +/// +/// Inputs: +/// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be +/// passed as a 32-byte seed. Used to decrypt the encrypted content. +/// - `envelope_plaintext` -- the protobuf serialised payload containing the message envelope. The +/// envelope must already be decrypted if it was originally encrypted (i.e.: closed group +/// envelopes). +/// - `unix_ts` -- pass in the current system time which is used to determine, if present in the +/// envelope, whether or not the Session Pro proof has expired or not. +/// +/// Outputs: +/// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata +/// within the envelope if there were any. DecryptedEnvelope decrypt_envelope( std::span ed25519_privkey, std::span envelope_plaintext, std::chrono::sys_seconds unix_ts); -} // namespace session +} // namespace session diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 2f465fc1..dd24cfea 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -24,20 +24,13 @@ ProFeatures get_pro_features_for_msg(std::span msg, ProExtr return result; } -array_uc64 sign_msg_for_pro(std::span msg, const array_uc64& rotating_priv_key) { - // Sign the msg with the rotating public pro key and the pro proof if given - array_uc64 result = {}; - static_assert(result.max_size() == crypto_sign_ed25519_BYTES); - crypto_sign_ed25519_detached(result.data(), nullptr, msg.data(), msg.size(), rotating_priv_key.data()); - return result; -} - -std::vector encrypt_for_namespaced_destination( +EncryptedForNamespaceDest encrypt_for_namespaced_destination( std::span plaintext, std::span ed25519_privkey, const Destination& dest, config::Namespace space) { + EncryptedForNamespaceDest result = {}; enum class Mode { Envelope, Plaintext, @@ -132,7 +125,6 @@ std::vector encrypt_for_namespaced_destination( } // Do the encryption work - std::vector result; switch (enc.mode) { case Mode::Envelope: { assert(enc.envelope_type.has_value()); @@ -156,6 +148,7 @@ std::vector encrypt_for_namespaced_destination( if (dest.pro_sig) envelope.set_prosig(reinterpret_cast(dest.pro_sig->data()), dest.pro_sig->size()); + result.encrypted = true; switch (enc.after_envelope) { case AfterEnvelope::Nil: assert(false && "Dev error, after envelope action was not set"); @@ -173,8 +166,8 @@ std::vector encrypt_for_namespaced_destination( msg.set_allocated_request(&req_msg); // Write message as ciphertext - result.resize(msg.ByteSizeLong()); - msg.SerializeToArray(result.data(), result.size()); + result.ciphertext.resize(msg.ByteSizeLong()); + msg.SerializeToArray(result.ciphertext.data(), result.ciphertext.size()); } break; case AfterEnvelope::KeysEncryptMessage: { @@ -183,24 +176,26 @@ std::vector encrypt_for_namespaced_destination( "when this happens"); std::string bytes = envelope.SerializeAsString(); - result = dest.closed_group_keys->encrypt_message( + result.ciphertext = dest.closed_group_keys->encrypt_message( std::span( reinterpret_cast(bytes.data()), bytes.size())); } break; case AfterEnvelope::EnvelopeIsCipherText: { - result.resize(envelope.ByteSizeLong()); - envelope.SerializeToArray(result.data(), result.size()); + result.ciphertext.resize(envelope.ByteSizeLong()); + envelope.SerializeToArray(result.ciphertext.data(), result.ciphertext.size()); } break; } + } break; case Mode::Plaintext: { - result = std::vector(plaintext.begin(), plaintext.end()); + // No-op. We do not populate the ciphertext because there was no encryption. } break; case Mode::EncryptForBlindedRecipient: { - result = encrypt_for_blinded_recipient( + result.encrypted = true; + result.ciphertext = encrypt_for_blinded_recipient( ed25519_privkey, dest.open_group_inbox_server_pubkey, dest.recipient_pubkey, // recipient blinded pubkey @@ -315,12 +310,11 @@ DecryptedEnvelope decrypt_envelope( reinterpret_cast(content_str.data()), content_str.size(), reinterpret_cast(proto_proof.rotatingpublickey().data())); - if (verify_result != 0) - throw std::runtime_error("Parse decrypted message failed, pro signature is invalid"); + result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::Invalid; // Fill out the resulting proof structure, we have parsed successfully - result.pro_flags = proto_flags; - std::memcpy(result.pro_sig.data(), pro_sig.data(), pro_sig.size()); + result.pro_features = proto_flags; + std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); std::memcpy( proof.gen_index_hash.data(), @@ -334,15 +328,17 @@ DecryptedEnvelope decrypt_envelope( std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); - // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It has been - // authorised by the backend as having a valid backing payment). - if (proof.verify(session::pro_backend::PUBKEY)) - result.pro_status = ProStatus::Valid; - - // Check if the proof has expired if (result.pro_status == ProStatus::Valid) { - if (unix_ts >= result.pro_proof.expiry_unix_ts) - result.pro_status = ProStatus::Expired; + // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It has been + // authorised by the backend as having a valid backing payment). + if (proof.verify(session::pro_backend::PUBKEY)) + result.pro_status = ProStatus::Valid; + + // Check if the proof has expired + if (result.pro_status == ProStatus::Valid) { + if (unix_ts >= result.pro_proof.expiry_unix_ts) + result.pro_status = ProStatus::Expired; + } } } return result; From 21e44380cf714b0030a0080aeab8285fb9b46476 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 11 Aug 2025 17:20:47 +1000 Subject: [PATCH 018/171] Add c bindings for new encryption functions --- include/session/config/namespaces.h | 35 +++ include/session/config/namespaces.hpp | 25 +-- include/session/session_protocol.h | 161 +++++++++++-- include/session/session_protocol.hpp | 33 +-- include/session/types.h | 21 ++ src/CMakeLists.txt | 1 + src/session_protocol.cpp | 310 ++++++++++++++++++++++---- src/types.cpp | 21 ++ 8 files changed, 513 insertions(+), 94 deletions(-) create mode 100644 include/session/config/namespaces.h create mode 100644 include/session/types.h create mode 100644 src/types.cpp diff --git a/include/session/config/namespaces.h b/include/session/config/namespaces.h new file mode 100644 index 00000000..a2a7aee7 --- /dev/null +++ b/include/session/config/namespaces.h @@ -0,0 +1,35 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum NAMESPACE { + // Messages sent to an updated closed 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 closed 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 diff --git a/include/session/config/namespaces.hpp b/include/session/config/namespaces.hpp index 1383ebac..8ac4abd6 100644 --- a/include/session/config/namespaces.hpp +++ b/include/session/config/namespaces.hpp @@ -1,32 +1,31 @@ #pragma once #include +#include "namespaces.h" namespace session::config { enum class Namespace : std::int16_t { - // Messages sent to an updated closed group which should be able to be retrieved by revoked - // members are stored in this namespace - RevokedRetrievableGroupMessages = -11, + RevokedRetrievableGroupMessages = NAMESPACE_REVOKED_RETRIEVABLE_GROUP_MESSAGES, // Messages sent to one-to-one conversations are stored in this namespace - Default = 0, - UserProfile = 2, - Contacts = 3, - ConvoInfoVolatile = 4, - UserGroups = 5, + 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, + 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 diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index f8872ef8..3ae234d7 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -1,33 +1,164 @@ #include +#include "config/namespaces.h" +#include "config/pro.h" #include "export.h" +#include "types.h" + +struct config_group_keys; #ifdef __cplusplus extern "C" { #endif enum { - SESSION_PRO_10k_CHARACTER_LIMIT = 10'000, + PRO_10K_CHARACTER_LIMIT = 10'000, +}; + +typedef uint64_t PRO_EXTRA_FEATURES; +enum PRO_EXTRA_FEATURES_ { + PRO_EXTRA_FEATURES_NIL = 0, + PRO_EXTRA_FEATURES_PRO_BADGE = 0 << 1, + PRO_EXTRA_FEATURES_ANIMATED_AVATAR = 1 << 1, +}; + +typedef uint64_t PRO_FEATURES; +enum PRO_FEATURES_ { + PRO_FEATURES_NIL = 0, + PRO_FEATURES_10K_CHARACTER_LIMIT = 1 << 0, + PRO_FEATURES_PRO_BADGE = 1 << 1, + PRO_FEATURES_ANIMATED_AVATAR = 1 << 2, + PRO_FEATURES_ALL = + PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR +}; + +enum PRO_STATUS { + PRO_STATUS_NIL, // Pro proof was not set + PRO_STATUS_INVALID, // Pro proof was set; signature validation failed + PRO_STATUS_VALID, // Pro proof was set, is verified; has not expired + PRO_STATUS_EXPIRED, // Pro proof was set, is verified; has expired +}; + +enum DESTINATION_TYPE { + DESTINATION_TYPE_CONTACT, + DESTINATION_TYPE_SYNC_MESSAGE, + DESTINATION_TYPE_CLOSED_GROUP, + DESTINATION_TYPE_OPEN_GROUP, + DESTINATION_TYPE_OPEN_GROUP_INBOX, }; -typedef uint64_t session_pro_extra_features; -enum session_pro_extra_features_ { - session_pro_extra_nil = 0, - session_pro_extra_features_pro_badge = 0 << 1, - session_pro_extra_features_animated_avatar = 1 << 1, +struct session_protocol_destination { + DESTINATION_TYPE type; + + // Signature over the plaintext with the user's Session Pro rotating public key if they have + // Session Pro and opt into sending a message with pro features. If this is specified, the pro + // message component in `Content` must have been set with the corresponding proof for this + // signature. + uint8_t pro_sig[64]; + bool has_pro_sig; + + // Set to the recipient of the message if it requires one. Ignored otherwise (for example + // ignored in OpenGroup) + uint8_t recipient_pubkey[32]; + + // The timestamp to assign to the message envelope if the message requires one. Ignored + // otherwise + uint64_t sent_timestamp_ms; + + // When type => OpenGroupInbox: set this pubkey to the server's key + uint8_t open_group_inbox_server_pubkey[32]; + + // When type => ClosedGroup: set the following 'closed_group' prefixed fields + uint8_t closed_group_pubkey[33]; + const config_group_keys* closed_group_keys; + + // Set to the closed group's swarm public key (needed for Android) for a non 0x03 prefixed + // `closed_group_pubkey`. Ignored otherwise. This will be set as the envelope source. See: + // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 + uint8_t closed_group_swarm_public_key[33]; + bool has_closed_group_swarm_public_key; +}; + +enum ENVELOPE_TYPE { + ENVELOPE_TYPE_SESSION_MESSAGE, + ENVELOPE_TYPE_CLOSED_GROUP_MESSGE, }; -typedef uint64_t session_pro_features; -enum session_pro_features_ { - session_pro_features_nil = 0, - session_pro_features_10k_character_limit = 1 << 0, - session_pro_features_pro_badge = 1 << 1, - session_pro_features_animated_avatar = 1 << 2, - session_pro_features_all = session_pro_features_10k_character_limit | - session_pro_features_pro_badge | - session_pro_features_animated_avatar, +typedef uint32_t ENVELOPE_FLAGS; +enum ENVELOPE_FLAGS_ { + ENVELOPE_FLAGS_SOURCE = 1 << 0, + ENVELOPE_FLAGS_SOURCE_DEVICE = 1 << 1, + ENVELOPE_FLAGS_SERVER_TIMESTAMP = 1 << 2, + ENVELOPE_FLAGS_PRO_SIG = 1 << 3, }; +struct session_protocol_envelope { + ENVELOPE_FLAGS flags; + ENVELOPE_TYPE type; + uint64_t timestamp; + + /// Optional fields. These fields are set if the appropriate flag has been set in `flags` + /// otherwise the corresponding values are to be ignored and those fields will be + /// zero-initialised. + uint8_t source[33]; + uint32_t source_device; + uint64_t server_timestamp; + uint8_t pro_sig[64]; +}; + +struct session_protocol_decrypted_envelope { + bool success; + + // The envelope parsed from the plaintext + session_protocol_envelope envelope; + + // Decrypted envelope content into plaintext + span_u8 content_plaintext; + + // Sender public key extracted from the encrypted content payload + uint8_t sender_ed25519_pubkey[32]; + + // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. + // The status is set to `Nil` if there is no Session Pro proof in the message. Otherwise it's + // set to one of the other values to which the remaining pro fields will be populated with data + // parsed from the envelope. + PRO_STATUS pro_status; + + // The embedded Session Pro proof, only set if the status was not `Nil`. + pro_proof pro_proof; + + // Session Pro features that were used in the embedded message, only set if the status was not + // `Nil`. + PRO_FEATURES pro_features; +}; + +struct session_protocol_encrypted_for_destination { + bool success; + + // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to + // the destination and namespace does not require encryption. In this case `ciphertext` is not + // set and the user should proceed with the original plaintext. + bool encrypted; + + // The plaintext encrypted in a manner suitable for the desired destination and namespace. This + // is not set if `encrypted` is false. + span_u8 ciphertext; +}; + +LIBSESSION_EXPORT +PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags); + +LIBSESSION_EXPORT +session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( + const span_u8 plaintext, + const span_u8 ed25519_privkey, + const session_protocol_destination* dest, + NAMESPACE space); + +LIBSESSION_EXPORT +session_protocol_decrypted_envelope session_protocol_decrypt_envelope( + const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts); + #ifdef __cplusplus } #endif diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 82a63353..bdb814b8 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -61,20 +61,12 @@ struct Destination { }; enum class EnvelopeType { - SessionMessage, - ClosedGroupMessage, -}; - -typedef uint32_t EnvelopeFlags; -enum EnvelopeFlags_ { - EnvelopeFlags_Source = 1 << 0, - EnvelopeFlags_SourceDevice = 1 << 1, - EnvelopeFlags_ServerTimestamp = 1 << 2, - EnvelopeFlags_ProSig = 1 << 3, + SessionMessage = ENVELOPE_TYPE_SESSION_MESSAGE, + ClosedGroupMessage = ENVELOPE_TYPE_CLOSED_GROUP_MESSGE, }; struct Envelope { - EnvelopeFlags flags; + ENVELOPE_FLAGS flags; EnvelopeType type; uint64_t timestamp; @@ -87,9 +79,6 @@ struct Envelope { array_uc64 pro_sig; }; -using ProFeatures = session_pro_features; -using ProExtraFeatures = session_pro_extra_features; - struct DecryptedEnvelope { // The envelope parsed from the plaintext Envelope envelope; @@ -98,7 +87,7 @@ struct DecryptedEnvelope { std::vector content_plaintext; // Sender public key extracted from the encrypted content payload - std::vector sender_ed25519_pubkey; + array_uc32 sender_ed25519_pubkey; // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. // The status is set to `Nil` if there is no Session Pro proof in the message. Otherwise it's @@ -109,12 +98,12 @@ struct DecryptedEnvelope { // The embedded Session Pro proof, only set if the status was not `Nil`. config::ProProof pro_proof; - // Session Pro features that were used in the embedded message, only set if the status was not - // `Nil`. - ProFeatures pro_features; + // Session Pro bit flag features that were used in the embedded message, only set if the status + // was not `Nil`. + PRO_FEATURES pro_features; }; -struct EncryptedForNamespaceDest +struct EncryptedForDestination { // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to // the destination and namespace does not require encryption. In this case `ciphertext` is not @@ -139,9 +128,9 @@ struct EncryptedForNamespaceDest /// Outputs: /// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in /// `Content` -ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures flags); +PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_FEATURES flags); -/// API: session_protocol/encrypt_for_namespaced_destination +/// API: session_protocol/encrypt_for_destination /// /// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of /// `Content`), encrypt and/or wrap the plaintext in the necessary structures for transmission on @@ -174,7 +163,7 @@ ProFeatures get_pro_features_for_msg(std::span msg, ProExtr /// - The encryption result for the plaintext. If the destination and namespace combination did not /// require encryption, no payload is returned in the ciphertext and the user should proceed with /// the plaintext. This should be validated by checking the `encrypted` flag on the result. -EncryptedForNamespaceDest encrypt_for_namespaced_destination( +EncryptedForDestination encrypt_for_destination( std::span plaintext, std::span ed25519_privkey, const Destination& dest, diff --git a/include/session/types.h b/include/session/types.h new file mode 100644 index 00000000..b7e542cf --- /dev/null +++ b/include/session/types.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct span_u8 +{ + uint8_t *data; + size_t size; +}; + +span_u8 span_u8_alloc_or_throw(size_t size); +span_u8 span_u8_copy_or_throw(const void *data, size_t size); + +#ifdef __cplusplus +} +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9065d4b..720426d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,7 @@ add_libsession_util_library(crypto sodium_array.cpp xed25519.cpp pro_backend.cpp + types.cpp ) add_libsession_util_library(config diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index dd24cfea..a57c7a87 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,6 +1,7 @@ -#include #include +#include +#include #include #include #include @@ -10,27 +11,51 @@ #include "SessionProtos.pb.h" #include "WebSocketResources.pb.h" +#include "session/export.h" namespace session { -ProFeatures get_pro_features_for_msg(std::span msg, ProExtraFeatures extra) { - ProFeatures result = session_pro_features_nil; - if (msg.size() >= SESSION_PRO_10k_CHARACTER_LIMIT) - result |= session_pro_features_10k_character_limit; - if (extra & session_pro_extra_features_animated_avatar) - result |= session_pro_features_animated_avatar; - if (extra & session_pro_extra_features_pro_badge) - result |= session_pro_features_pro_badge; +PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_EXTRA_FEATURES extra) { + PRO_FEATURES result = PRO_FEATURES_NIL; + + if (msg.size() >= PRO_10K_CHARACTER_LIMIT) + result |= PRO_FEATURES_10K_CHARACTER_LIMIT; + + if (extra & PRO_EXTRA_FEATURES_ANIMATED_AVATAR) + result |= PRO_FEATURES_ANIMATED_AVATAR; + + if (extra & PRO_EXTRA_FEATURES_PRO_BADGE) + result |= PRO_FEATURES_PRO_BADGE; + + assert((result & ~PRO_FEATURES_ALL) == 0); return result; } -EncryptedForNamespaceDest encrypt_for_namespaced_destination( - std::span plaintext, - std::span ed25519_privkey, - const Destination& dest, - config::Namespace space) { - - EncryptedForNamespaceDest result = {}; +struct EncryptedForDestinationInternal +{ + bool encrypted; + std::vector ciphertext_cpp; + span_u8 ciphertext_c; +}; + +enum class UseMalloc { No, Yes }; +static EncryptedForDestinationInternal encrypt_for_destination_internal( + const std::span plaintext, + const std::span ed25519_privkey, + DestinationType dest_type, + const uint8_t* dest_pro_sig, + const uint8_t* dest_recipient_pubkey, + std::chrono::milliseconds dest_sent_timestamp_ms, + const uint8_t* dest_open_group_inbox_server_pubkey, + const uint8_t* dest_closed_group_pubkey, + const config::groups::Keys* dest_closed_group_keys, + const uint8_t* dest_closed_group_swarm_public_key, + config::Namespace space, + UseMalloc use_malloc) { + + // All incoming arguments are passed in from typed, fixed-sized arrays so we do not check + // the pointer lengths of those arguments. + EncryptedForDestinationInternal result = {}; enum class Mode { Envelope, Plaintext, @@ -57,13 +82,13 @@ EncryptedForNamespaceDest encrypt_for_namespaced_destination( // Figure out how to encrypt the message based on the destination and setup the encoding context EncodeContext enc = {}; - switch (dest.type) { + switch (dest_type) { case DestinationType::ClosedGroup: { bool has_03_prefix = - dest.closed_group_pubkey[0] == static_cast(SessionIDPrefix::group); + dest_closed_group_pubkey[0] == static_cast(SessionIDPrefix::group); if (has_03_prefix) { if (space == config::Namespace::GroupMessages) { - if (!dest.closed_group_keys) + if (!dest_closed_group_keys) throw std::runtime_error( "API misuse: Sending to a closed group into the group messages " "namespace requires the closed group keys to be set"); @@ -86,11 +111,11 @@ EncryptedForNamespaceDest encrypt_for_namespaced_destination( SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; - if (!dest.closed_group_swarm_public_key) + if (!dest_closed_group_swarm_public_key) throw std::runtime_error( "API misuse: Closed group swarm public key must be set on non 0x03 " "prefixed group keys"); - enc.envelope_src = *dest.closed_group_swarm_public_key; + enc.envelope_src = {dest_closed_group_swarm_public_key, sizeof(array_uc33)}; } } break; @@ -131,7 +156,7 @@ EncryptedForNamespaceDest encrypt_for_namespaced_destination( std::span src_text = plaintext; if (enc.before_envelope_encrypt_for_recipient_deterministic) { enc.before_envelope_ciphertext = session::encrypt_for_recipient_deterministic( - ed25519_privkey, dest.recipient_pubkey, plaintext); + ed25519_privkey, {dest_recipient_pubkey, sizeof(array_uc32)}, src_text); src_text = enc.before_envelope_ciphertext; } @@ -141,12 +166,12 @@ EncryptedForNamespaceDest encrypt_for_namespaced_destination( SessionProtos::Envelope envelope = {}; envelope.set_type(*enc.envelope_type); envelope.set_sourcedevice(1); - envelope.set_timestamp(dest.sent_timestamp_ms.count()); + envelope.set_timestamp(dest_sent_timestamp_ms.count()); envelope.set_content(src_text.data(), src_text.size()); if (enc.envelope_src) envelope.set_source(reinterpret_cast(enc.envelope_src->data()), enc.envelope_src->size()); - if (dest.pro_sig) - envelope.set_prosig(reinterpret_cast(dest.pro_sig->data()), dest.pro_sig->size()); + if (dest_pro_sig) + envelope.set_prosig(reinterpret_cast(dest_pro_sig), sizeof(array_uc64)); result.encrypted = true; switch (enc.after_envelope) { @@ -166,24 +191,43 @@ EncryptedForNamespaceDest encrypt_for_namespaced_destination( msg.set_allocated_request(&req_msg); // Write message as ciphertext - result.ciphertext.resize(msg.ByteSizeLong()); - msg.SerializeToArray(result.ciphertext.data(), result.ciphertext.size()); + void *dest = nullptr; + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); + msg.SerializeToArray(result.ciphertext_c.data, result.ciphertext_c.size); + } else { + result.ciphertext_cpp.resize(msg.ByteSizeLong()); + msg.SerializeToArray( + result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); + } } break; case AfterEnvelope::KeysEncryptMessage: { - assert(dest.closed_group_keys && + assert(dest_closed_group_keys && "Dev error, API miuse was not detected. We should throw an exception " - "when this happens"); + "when this happens earlier"); std::string bytes = envelope.SerializeAsString(); - result.ciphertext = dest.closed_group_keys->encrypt_message( - std::span( - reinterpret_cast(bytes.data()), bytes.size())); + std::vector ciphertext = dest_closed_group_keys->encrypt_message( + {reinterpret_cast(bytes.data()), bytes.size()}); + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = + span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + } else { + result.ciphertext_cpp = std::move(ciphertext); + } } break; case AfterEnvelope::EnvelopeIsCipherText: { - result.ciphertext.resize(envelope.ByteSizeLong()); - envelope.SerializeToArray(result.ciphertext.data(), result.ciphertext.size()); + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); + envelope.SerializeToArray( + result.ciphertext_c.data, result.ciphertext_c.size); + } else { + result.ciphertext_cpp.resize(envelope.ByteSizeLong()); + envelope.SerializeToArray( + result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); + } } break; } @@ -195,17 +239,61 @@ EncryptedForNamespaceDest encrypt_for_namespaced_destination( case Mode::EncryptForBlindedRecipient: { result.encrypted = true; - result.ciphertext = encrypt_for_blinded_recipient( + std::vector ciphertext = encrypt_for_blinded_recipient( ed25519_privkey, - dest.open_group_inbox_server_pubkey, - dest.recipient_pubkey, // recipient blinded pubkey + {dest_open_group_inbox_server_pubkey, sizeof(array_uc32)}, + {dest_recipient_pubkey, sizeof(array_uc32)}, // recipient blinded pubkey plaintext); + + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + } else { + result.ciphertext_cpp = std::move(ciphertext); + } } break; } return result; } +EncryptedForDestination encrypt_for_destination( + std::span plaintext, + std::span ed25519_privkey, + const Destination& dest, + config::Namespace space) { + + EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( + /*plaintext=*/plaintext, + /*ed25519_privkey=*/ed25519_privkey, + /*dest_type=*/dest.type, + /*dest_pro_sig=*/dest.pro_sig ? dest.pro_sig->data() : nullptr, + /*dest_recipient_pubkey=*/dest.recipient_pubkey.data(), + /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, + /*dest_open_group_inbox_server_pubkey=*/dest.open_group_inbox_server_pubkey.data(), + /*dest_closed_group_pubkey=*/dest.closed_group_pubkey.data(), + /*dest_closed_group_keys=*/dest.closed_group_keys, + /*dest_closed_group_swarm_public_key=*/dest.closed_group_swarm_public_key + ? dest.closed_group_swarm_public_key->data() + : nullptr, + /*space=*/space, + /*use_malloc=*/UseMalloc::No); + + EncryptedForDestination result = { + .encrypted = result_internal.encrypted, + .ciphertext = std::move(result_internal.ciphertext_cpp), + }; + return result; +} + +struct DecryptedEnvelopeInternal { + Envelope envelope; + std::vector content_plaintext; + std::vector sender_ed25519_pubkey; + ProStatus pro_status; + config::ProProof pro_proof; + PRO_FEATURES pro_features; +}; + DecryptedEnvelope decrypt_envelope( std::span ed25519_privkey, std::span envelope_plaintext, @@ -240,31 +328,44 @@ DecryptedEnvelope decrypt_envelope( "Parse envelope failed, source had unexpected size ({} bytes)", source.size())); std::memcpy(result.envelope.source.data(), source.data(), source.size()); - result.envelope.flags |= EnvelopeFlags_Source; + result.envelope.flags |= ENVELOPE_FLAGS_SOURCE; } // Parse source device (optional) if (envelope.has_sourcedevice()) { result.envelope.source_device = envelope.sourcedevice(); - result.envelope.flags |= EnvelopeFlags_SourceDevice; + result.envelope.flags |= ENVELOPE_FLAGS_SOURCE_DEVICE; } // Parse server timestamp (optional) if (envelope.has_servertimestamp()) { result.envelope.server_timestamp = envelope.servertimestamp(); - result.envelope.flags |= EnvelopeFlags_ServerTimestamp; + result.envelope.flags |= ENVELOPE_FLAGS_SERVER_TIMESTAMP; } - // Parse content (unconditionallty) + // Parse content if (!envelope.has_content()) throw std::runtime_error{"Parse decrypted message failed, missing content"}; + // Decrypt content const std::string& content_str = envelope.content(); auto content_span = std::span( reinterpret_cast(content_str.data()), content_str.size()); - std::tie(result.content_plaintext, result.sender_ed25519_pubkey) = + auto [content_plaintext, sender_ed25519_pubkey] = session::decrypt_incoming(ed25519_privkey, content_span); - + assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + + result.content_plaintext = std::move(content_plaintext); + std::memcpy( + result.sender_ed25519_pubkey.data(), + sender_ed25519_pubkey.data(), + result.sender_ed25519_pubkey.size()); + + // TODO: We parse the content in libsession to extract pro metadata but we return the unparsed + // blob back to the caller. This is temporary, eventually we will return a proxy structure for + // the protobuf Content type to the user. We avoid returning the direct protobuf type to keep + // the interface simple and avoid leaking protobuf implementation detail into the libsession + // interface. SessionProtos::Content content = {}; if (!envelope.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) throw std::runtime_error{"Parse content from envelope failed"}; @@ -280,7 +381,7 @@ DecryptedEnvelope decrypt_envelope( static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); - result.envelope.flags |= EnvelopeFlags_ProSig; + result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; SessionProtos::ProMessage pro_msg = content.promessage(); if (!pro_msg.has_proof()) @@ -344,3 +445,124 @@ DecryptedEnvelope decrypt_envelope( return result; } } // namespace session + +using namespace session; + +LIBSESSION_EXPORT +PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags) +{ + PRO_FEATURES result = get_pro_features_for_msg({msg.data, msg.size}, flags); + return result; +} + +LIBSESSION_EXPORT session_protocol_encrypted_for_destination +session_protocol_encrypt_for_destination( + const span_u8 plaintext, + const span_u8 ed25519_privkey, + const session_protocol_destination* dest, + NAMESPACE space) +{ + session_protocol_encrypted_for_destination result = {}; + try { + EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( + /*plaintext=*/{plaintext.data, plaintext.size}, + /*ed25519_privkey=*/{ed25519_privkey.data, ed25519_privkey.size}, + /*dest_type=*/static_cast(dest->type), + /*dest_pro_sig=*/dest->has_pro_sig ? dest->pro_sig : nullptr, + /*dest_recipient_pubkey=*/dest->recipient_pubkey, + /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), + /*dest_open_group_inbox_server_pubkey=*/dest->open_group_inbox_server_pubkey, + /*dest_closed_group_pubkey=*/dest->closed_group_pubkey, + /*dest_closed_group_keys=*/ + static_cast(dest->closed_group_keys->internals), + /*dest_closed_group_swarm_public_key=*/dest->has_closed_group_swarm_public_key + ? dest->closed_group_swarm_public_key + : nullptr, + /*space=*/static_cast(space), + /*use_malloc=*/UseMalloc::Yes); + + result = { + .success = true, + .encrypted = result_internal.encrypted, + .ciphertext = result_internal.ciphertext_c, + }; + } catch (...) { + } + + return result; +} + +LIBSESSION_EXPORT +session_protocol_decrypted_envelope session_protocol_decrypt_envelope( + const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts) +{ + session_protocol_decrypted_envelope result = {}; + try { + DecryptedEnvelope result_cpp = decrypt_envelope( + {ed25519_privkey.data, ed25519_privkey.size}, + {envelope_plaintext.data, envelope_plaintext.size}, + std::chrono::sys_seconds(std::chrono::seconds(unix_ts))); + + // Marshall into c type + result = { + .success = false, + .envelope = + { + .flags = result_cpp.envelope.flags, + .type = static_cast(result_cpp.envelope.type), + .timestamp = result_cpp.envelope.timestamp, + .source = {}, + .source_device = result_cpp.envelope.source_device, + .server_timestamp = result_cpp.envelope.server_timestamp, + .pro_sig = {}, + }, + .content_plaintext = {}, + .sender_ed25519_pubkey = {}, + .pro_status = static_cast(result_cpp.pro_status), + .pro_proof = + { + .version = result_cpp.pro_proof.version, + .gen_index_hash = {}, + .rotating_pubkey = {}, + .expiry_unix_ts = static_cast( + result_cpp.pro_proof.expiry_unix_ts.time_since_epoch() + .count()), + .sig = {}, + }, + .pro_features = result_cpp.pro_features}; + + std::memcpy( + result.envelope.source, + result_cpp.envelope.source.data(), + sizeof(result.envelope.source)); + std::memcpy( + result.envelope.pro_sig, + result_cpp.envelope.pro_sig.data(), + sizeof(result.envelope.pro_sig)); + + result.content_plaintext = span_u8_copy_or_throw( + result_cpp.content_plaintext.data(), result_cpp.content_plaintext.size()); + std::memcpy( + result.sender_ed25519_pubkey, + result_cpp.sender_ed25519_pubkey.data(), + sizeof(result.sender_ed25519_pubkey)); + + std::memcpy( + result.pro_proof.gen_index_hash, + result_cpp.pro_proof.gen_index_hash.data(), + sizeof(result.pro_proof.gen_index_hash)); + std::memcpy( + result.pro_proof.rotating_pubkey, + result_cpp.pro_proof.rotating_pubkey.data(), + sizeof(result.pro_proof.rotating_pubkey)); + std::memcpy( + result.pro_proof.sig, + result_cpp.pro_proof.sig.data(), + sizeof(result.pro_proof.sig)); + + result.success = true; + } catch (...) { + } + + return result; +} diff --git a/src/types.cpp b/src/types.cpp new file mode 100644 index 00000000..a2c53461 --- /dev/null +++ b/src/types.cpp @@ -0,0 +1,21 @@ +#include + +#include + +span_u8 span_u8_alloc_or_throw(size_t size) +{ + span_u8 result = {}; + result.size = size; + result.data = static_cast(malloc(size)); + if (!result.data) + throw std::runtime_error( + fmt::format("Failed to allocate {} bytes for span, out of memory", size)); + return result; +} + +span_u8 span_u8_copy_or_throw(const void *data, size_t size) +{ + span_u8 result = span_u8_alloc_or_throw(size); + std::memcpy(result.data, data, result.size); + return result; +} From 1ad719c5f719c558e354ada3fdb9e77108e97c90 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 11 Aug 2025 17:41:38 +1000 Subject: [PATCH 019/171] Revise docs for session protocol c header --- include/session/session_protocol.h | 127 +++++++++++++++++------------ 1 file changed, 77 insertions(+), 50 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 3ae234d7..72d10759 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -5,6 +5,9 @@ #include "export.h" #include "types.h" +/// The C header for session_protocol. See the CPP header for more indepth comments. Only the +/// differences between the C and CPP headers are documented to avoid duplication. + struct config_group_keys; #ifdef __cplusplus @@ -33,10 +36,10 @@ enum PRO_FEATURES_ { }; enum PRO_STATUS { - PRO_STATUS_NIL, // Pro proof was not set - PRO_STATUS_INVALID, // Pro proof was set; signature validation failed - PRO_STATUS_VALID, // Pro proof was set, is verified; has not expired - PRO_STATUS_EXPIRED, // Pro proof was set, is verified; has expired + PRO_STATUS_NIL, + PRO_STATUS_INVALID, + PRO_STATUS_VALID, + PRO_STATUS_EXPIRED, }; enum DESTINATION_TYPE { @@ -50,33 +53,20 @@ enum DESTINATION_TYPE { struct session_protocol_destination { DESTINATION_TYPE type; - // Signature over the plaintext with the user's Session Pro rotating public key if they have - // Session Pro and opt into sending a message with pro features. If this is specified, the pro - // message component in `Content` must have been set with the corresponding proof for this - // signature. - uint8_t pro_sig[64]; + // The pro signature is optional, set this flag to true to make the encryption function take + // into account the signature or otherwise the signature is ignored. bool has_pro_sig; - - // Set to the recipient of the message if it requires one. Ignored otherwise (for example - // ignored in OpenGroup) + uint8_t pro_sig[64]; uint8_t recipient_pubkey[32]; - - // The timestamp to assign to the message envelope if the message requires one. Ignored - // otherwise uint64_t sent_timestamp_ms; - - // When type => OpenGroupInbox: set this pubkey to the server's key uint8_t open_group_inbox_server_pubkey[32]; - - // When type => ClosedGroup: set the following 'closed_group' prefixed fields uint8_t closed_group_pubkey[33]; const config_group_keys* closed_group_keys; - // Set to the closed group's swarm public key (needed for Android) for a non 0x03 prefixed - // `closed_group_pubkey`. Ignored otherwise. This will be set as the envelope source. See: - // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 - uint8_t closed_group_swarm_public_key[33]; + // The closed group swarm public key is optional but should be set for a non 0x03 prefix + // `closed_group_pubkey`. Otherwise the public key is ignored when encrypting for a destination. bool has_closed_group_swarm_public_key; + uint8_t closed_group_swarm_public_key[33]; }; enum ENVELOPE_TYPE { @@ -96,10 +86,6 @@ struct session_protocol_envelope { ENVELOPE_FLAGS flags; ENVELOPE_TYPE type; uint64_t timestamp; - - /// Optional fields. These fields are set if the appropriate flag has been set in `flags` - /// otherwise the corresponding values are to be ignored and those fields will be - /// zero-initialised. uint8_t source[33]; uint32_t source_device; uint64_t server_timestamp; @@ -107,47 +93,65 @@ struct session_protocol_envelope { }; struct session_protocol_decrypted_envelope { + // Indicates if the decryption was successful. If the decryption step failed and threw an + // exception, this is false. bool success; - - // The envelope parsed from the plaintext session_protocol_envelope envelope; - - // Decrypted envelope content into plaintext span_u8 content_plaintext; - - // Sender public key extracted from the encrypted content payload uint8_t sender_ed25519_pubkey[32]; - - // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. - // The status is set to `Nil` if there is no Session Pro proof in the message. Otherwise it's - // set to one of the other values to which the remaining pro fields will be populated with data - // parsed from the envelope. PRO_STATUS pro_status; - - // The embedded Session Pro proof, only set if the status was not `Nil`. pro_proof pro_proof; - - // Session Pro features that were used in the embedded message, only set if the status was not - // `Nil`. PRO_FEATURES pro_features; }; struct session_protocol_encrypted_for_destination { + // Indicates if the decryption was successful. If the decryption step failed and threw an + // exception, this is false. bool success; - - // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to - // the destination and namespace does not require encryption. In this case `ciphertext` is not - // set and the user should proceed with the original plaintext. bool encrypted; - - // The plaintext encrypted in a manner suitable for the desired destination and namespace. This - // is not set if `encrypted` is false. span_u8 ciphertext; }; +/// API: session_protocol/session_protocol_get_pro_features_for_msg +/// +/// Determine the Pro features that are used in a given conversation message. +/// +/// Inputs: +/// - `msg` -- the conversation message to determine if the message is requires access to the 10k +/// character limit available in Session Pro +/// - `flags` -- extra pro features that are known by clients that they wish to be activated on +/// this message +/// +/// Outputs: +/// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in +/// `Content` LIBSESSION_EXPORT PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags); +/// API: session_protocol/session_protocol_encrypt_for_destination +/// +/// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of +/// `Content`), encrypt and/or wrap the plaintext in the necessary structures for transmission on +/// the Session Protocol. +/// +/// See: session_protocol/encrypt_for_destination for more information +/// +/// Inputs: +/// - `plaintext` -- the protobuf serialised payload containing the protobuf encoded stream, +/// `Content`. It must not be already be encrypted. +/// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be +/// passed as a 32-byte seed. Used to encrypt the plaintext. +/// - `dest` -- the extra metadata indicating the destination of the message and the necessary data +/// to encrypt a message for that destination. +/// - `space` -- the namespace to encrypt the message for +/// +/// Outputs: +/// - The encryption result for the plaintext. If the destination and namespace combination did not +/// require encryption, no payload is returned in the ciphertext and the user should proceed with +/// the plaintext. This should be validated by checking the `encrypted` flag on the result. +/// +/// The success flag is set if encryption was successful, if the underlying implementation threw +/// an exception then this is set to false. LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( const span_u8 plaintext, @@ -155,6 +159,29 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat const session_protocol_destination* dest, NAMESPACE space); +/// API: session_protocol/session_protocol_decrypt_envelope +/// +/// Given an unencrypted plaintext representation of an envelope (i.e.: protobuf encoded stream of +/// `Envelope`) parse the envelope and return the envelope content decrypted to plaintext with the +/// passed in key. +/// +/// See: session_protocol/decrypt_envelope for more information +/// +/// Inputs: +/// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be +/// passed as a 32-byte seed. Used to decrypt the encrypted content. +/// - `envelope_plaintext` -- the protobuf serialised payload containing the message envelope. The +/// envelope must already be decrypted if it was originally encrypted (i.e.: closed group +/// envelopes). +/// - `unix_ts` -- pass in the current system time which is used to determine, if present in the +/// envelope, whether or not the Session Pro proof has expired or not. +/// +/// Outputs: +/// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata +/// within the envelope if there were any. +/// +/// The success flag is set if encryption was successful, if the underlying implementation threw +/// an exception then this is set to false. LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts); From 58df586b166c4f9a77d250238b3d25e6c800bb15 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 12 Aug 2025 11:48:01 +1000 Subject: [PATCH 020/171] Fix incorrect detection of higher char limits and non-optional pro sigs --- include/session/session_protocol.h | 7 ++- include/session/session_protocol.hpp | 26 ++++++++- include/session/types.h | 13 ++++- src/session_protocol.cpp | 83 ++++++++++++++++++---------- 4 files changed, 94 insertions(+), 35 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 72d10759..84f56c6b 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -15,7 +15,10 @@ extern "C" { #endif enum { - PRO_10K_CHARACTER_LIMIT = 10'000, + /// Number of characters that a standard message can use. If the message exceeds this then the + /// message must activate the higher character limit feature provided by Session Pro which + /// allows messages up to 10k characters. + PRO_STANDARD_CHARACTER_LIMIT = 2'000, }; typedef uint64_t PRO_EXTRA_FEATURES; @@ -85,7 +88,7 @@ enum ENVELOPE_FLAGS_ { struct session_protocol_envelope { ENVELOPE_FLAGS flags; ENVELOPE_TYPE type; - uint64_t timestamp; + uint64_t timestamp_ms; uint8_t source[33]; uint32_t source_device; uint64_t server_timestamp; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index bdb814b8..8c31621f 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -9,6 +9,28 @@ /// A complimentary file to session encrypt which has the low level encryption function for Session /// protocol types. This file contains high-level helper functions for decoding payloads on the /// Session protocol. Prefer functions here before resorting to the lower-level cryptography. + +// NOTE: CPP doesn't support named bitfields without casting or operator overloads but C-style +// enums support it very well. The only issue is that using a native C-style enum enforces some type +// restrictions that compilers dislike when attempting to manipulate bit fields. For example: +// +// enum Feature {x = 1 << 0, y = 1 << 1} +// Feature f = x | y +// +// Causes the compiler to complain about trying to do bit ops/assign an unsigned integer to an enum +// `Feature`. We use a common C pattern/trick by suffixing an underscore to the the original enum, +// then type define the non-suffixed enum to an unsigned integer: +// +// enum Feature_ {x = 1 << 0, y = 1 << 1} +// typedef U64 Feature +// Feature f = x | y +// +// Does not trigger errors as the underlying type of `f` is actually an unsigned integer. The type +// define is merely a hint to the user to what flags are to be used when manipulating the variable. +// +// Hence in the CPP file we use C-style enums for bitfields and CPP-style enums for non-bitfield +// enums where we can to benefit from the type-safety of strong enums. + namespace session { namespace config::groups { @@ -68,7 +90,7 @@ enum class EnvelopeType { struct Envelope { ENVELOPE_FLAGS flags; EnvelopeType type; - uint64_t timestamp; + std::chrono::milliseconds timestamp; /// Optional fields. These fields are set if the appropriate flag has been set in `flags` /// otherwise the corresponding values are to be ignored and those fields will be @@ -76,6 +98,8 @@ struct Envelope { array_uc33 source; uint32_t source_device; uint64_t server_timestamp; + + /// Signature by the sending client's rotating key array_uc64 pro_sig; }; diff --git a/include/session/types.h b/include/session/types.h index b7e542cf..529a5354 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -7,13 +7,20 @@ extern "C" { #endif -struct span_u8 -{ - uint8_t *data; +/// C friendly buffer structure that is a pointer and lenght to a span of bytes. +struct span_u8 { + uint8_t* data; size_t size; }; +/// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this +/// function throws a runtime exception. The `data` pointer is span must be freed once the span +/// is no longer needed. span_u8 span_u8_alloc_or_throw(size_t size); + +/// Create a span of bytes that copies the payload at `data` for `size` bytes. If allocation fails +/// this function throws a runtime exception. The `data` pointer is span must be freed once the span +/// is no longer needed. span_u8 span_u8_copy_or_throw(const void *data, size_t size); #ifdef __cplusplus diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index a57c7a87..c24bcf34 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,7 +1,8 @@ #include +#include #include +#include -#include #include #include #include @@ -18,7 +19,7 @@ namespace session { PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_EXTRA_FEATURES extra) { PRO_FEATURES result = PRO_FEATURES_NIL; - if (msg.size() >= PRO_10K_CHARACTER_LIMIT) + if (msg.size() >= PRO_STANDARD_CHARACTER_LIMIT) result |= PRO_FEATURES_10K_CHARACTER_LIMIT; if (extra & PRO_EXTRA_FEATURES_ANIMATED_AVATAR) @@ -31,8 +32,10 @@ PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_EXTRA_FE return result; } -struct EncryptedForDestinationInternal -{ +// Interop between the C and CPP API. The C api will request malloc which writes to `ciphertext_c`. +// This pointer is taken verbatim and avoids requiring a copy from the CPP vector. The CPP api will +// steal the contents from `ciphertext_cpp`. +struct EncryptedForDestinationInternal { bool encrypted; std::vector ciphertext_cpp; span_u8 ciphertext_c; @@ -62,20 +65,27 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( EncryptForBlindedRecipient, }; + // The step to partake after enveloping the content payload enum class AfterEnvelope { Nil, - EnvelopeIsCipherText, - WrapInWSMessage, - KeysEncryptMessage, + EnvelopeIsCipherText, // No extra bit-mangling required after enveloping + WrapInWSMessage, // Wrap in the protobuf websocket message after enveloping + KeysEncryptMessage, // Encrypt with the closed group keys after ennveloping }; struct EncodeContext { Mode mode; - // Parameters for BuildMode => Envelope bool before_envelope_encrypt_for_recipient_deterministic; + + // Ciphertext storing the result of encrypt for recipient deterministic, if it was necessary + // to encrypt before enveloping. std::vector before_envelope_ciphertext; + + // Payload to set the envelope source if necessary. std::optional> envelope_src; + + // Type of message to mark the enevelope as std::optional envelope_type; AfterEnvelope after_envelope; }; @@ -169,9 +179,20 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( envelope.set_timestamp(dest_sent_timestamp_ms.count()); envelope.set_content(src_text.data(), src_text.size()); if (enc.envelope_src) - envelope.set_source(reinterpret_cast(enc.envelope_src->data()), enc.envelope_src->size()); - if (dest_pro_sig) - envelope.set_prosig(reinterpret_cast(dest_pro_sig), sizeof(array_uc64)); + envelope.set_source( + reinterpret_cast(enc.envelope_src->data()), + enc.envelope_src->size()); + + if (dest_pro_sig) { + envelope.set_prosig( + reinterpret_cast(dest_pro_sig), sizeof(array_uc64)); + } else { + // If there's no pro signature specified, we still fill out the pro signature with a + // dummy 64 byte stream. This is to make pro and non-pro messages indistinguishable. + std::string *pro_sig = envelope.mutable_prosig(); + pro_sig->resize(sizeof(array_uc64)); + randombytes_buf(pro_sig->data(), pro_sig->size()); + } result.encrypted = true; switch (enc.after_envelope) { @@ -191,7 +212,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( msg.set_allocated_request(&req_msg); // Write message as ciphertext - void *dest = nullptr; + void* dest = nullptr; if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); msg.SerializeToArray(result.ciphertext_c.data, result.ciphertext_c.size); @@ -320,7 +341,7 @@ DecryptedEnvelope decrypt_envelope( // Parse source (optional) if (envelope.has_source()) { // Libsession is now responsible for creating the envelope. The only data that we send in - // the source is a Session public key (see: encrypt_for_namespaced_destination) + // the source is a Session public key (see: encrypt_for_destination) const std::string& source = envelope.source(); if (source.size() != result.envelope.source.max_size()) throw std::runtime_error( @@ -370,19 +391,25 @@ DecryptedEnvelope decrypt_envelope( if (!envelope.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) throw std::runtime_error{"Parse content from envelope failed"}; - if (content.has_promessage()) { - // Parse the signature from the envelope if the content had a pro component to it - if (!envelope.has_prosig()) - throw std::runtime_error("Parse envelope failed, pro message is missing signature"); + // A signature must always be present on the envelope. This is to make a pro and non-pro + // envelope indistinguishable. If the message does not have pro then this signature must still + // be set but will be ignored. So in all instances a signature must be attached (real or + // dummy). + if (!envelope.has_prosig()) + throw std::runtime_error("Parse envelope failed, pro message is missing signature"); - const std::string& pro_sig = envelope.prosig(); - if (pro_sig.size() != crypto_sign_ed25519_BYTES) - throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); + const std::string& pro_sig = envelope.prosig(); + if (pro_sig.size() != crypto_sign_ed25519_BYTES) + throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); + static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); - static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); - std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); + std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); + + if (content.has_promessage()) { + // Mark the envelope as having a pro signature that the caller can use. result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; + // Extract the pro message SessionProtos::ProMessage pro_msg = content.promessage(); if (!pro_msg.has_proof()) throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); @@ -449,8 +476,7 @@ DecryptedEnvelope decrypt_envelope( using namespace session; LIBSESSION_EXPORT -PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags) -{ +PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags) { PRO_FEATURES result = get_pro_features_for_msg({msg.data, msg.size}, flags); return result; } @@ -460,8 +486,7 @@ session_protocol_encrypt_for_destination( const span_u8 plaintext, const span_u8 ed25519_privkey, const session_protocol_destination* dest, - NAMESPACE space) -{ + NAMESPACE space) { session_protocol_encrypted_for_destination result = {}; try { EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( @@ -494,8 +519,7 @@ session_protocol_encrypt_for_destination( LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts) -{ + const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts) { session_protocol_decrypted_envelope result = {}; try { DecryptedEnvelope result_cpp = decrypt_envelope( @@ -510,7 +534,8 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( { .flags = result_cpp.envelope.flags, .type = static_cast(result_cpp.envelope.type), - .timestamp = result_cpp.envelope.timestamp, + .timestamp_ms = static_cast( + result_cpp.envelope.timestamp.count()), .source = {}, .source_device = result_cpp.envelope.source_device, .server_timestamp = result_cpp.envelope.server_timestamp, From 9b33f674d795a64fe66b76d68bea052b5027f910 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 12 Aug 2025 12:23:53 +1000 Subject: [PATCH 021/171] Note that closed groups handles both legacy/non-legacy keys --- include/session/session_protocol.h | 4 ++-- include/session/session_protocol.hpp | 15 ++++++++++++--- src/session_protocol.cpp | 19 ++++++++++--------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 84f56c6b..9b09b622 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -68,8 +68,8 @@ struct session_protocol_destination { // The closed group swarm public key is optional but should be set for a non 0x03 prefix // `closed_group_pubkey`. Otherwise the public key is ignored when encrypting for a destination. - bool has_closed_group_swarm_public_key; - uint8_t closed_group_swarm_public_key[33]; + bool has_closed_group_public_key; + uint8_t closed_group_public_key[33]; }; enum ENVELOPE_TYPE { diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 8c31621f..213d8e85 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -47,7 +47,12 @@ enum class ProStatus { enum class DestinationType { Contact, SyncMessage, + + /// Both legacy and non-legacy closed groups are to be identified as `ClosedGroup`. A non-legacy + /// group is detected by the (0x03) prefix byte on the given `dest_closed_group_pubkey` + /// specified in Destination. ClosedGroup, + OpenGroup, OpenGroupInbox, }; @@ -74,12 +79,16 @@ struct Destination { // When type => ClosedGroup: set the following 'closed_group' prefixed fields array_uc33 closed_group_pubkey; + + // Must be set to the group keys for a 0x03 prefix (e.g. groups v2) `closed_group_pubkey` to + // encrypt the message. const session::config::groups::Keys* closed_group_keys; - // Set to the closed group's swarm public key (needed for Android) for a non 0x03 prefixed - // `closed_group_pubkey`. Ignored otherwise. This will be set as the envelope source. See: + // Must be set to the closed group's public key (needed for Android) for a non 0x03 prefixed + // `closed_group_pubkey` (e.g. legacy closed groups). Ignored otherwise. This will be set as the + // envelope source. See: // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 - std::optional closed_group_swarm_public_key; + std::optional closed_group_public_key; }; enum class EnvelopeType { diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index c24bcf34..d693d6e4 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -52,7 +52,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( const uint8_t* dest_open_group_inbox_server_pubkey, const uint8_t* dest_closed_group_pubkey, const config::groups::Keys* dest_closed_group_keys, - const uint8_t* dest_closed_group_swarm_public_key, + const uint8_t* dest_closed_group_public_key, config::Namespace space, UseMalloc use_malloc) { @@ -115,17 +115,18 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.mode = Mode::Plaintext; } } else { + // Legacy closed groups which have a 05 prefixed key enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; - if (!dest_closed_group_swarm_public_key) + if (!dest_closed_group_public_key) throw std::runtime_error( - "API misuse: Closed group swarm public key must be set on non 0x03 " - "prefixed group keys"); - enc.envelope_src = {dest_closed_group_swarm_public_key, sizeof(array_uc33)}; + "API misuse: Closed group public key must be set on non 0x03 prefixed " + "group keys"); + enc.envelope_src = {dest_closed_group_public_key, sizeof(array_uc33)}; } } break; @@ -293,8 +294,8 @@ EncryptedForDestination encrypt_for_destination( /*dest_open_group_inbox_server_pubkey=*/dest.open_group_inbox_server_pubkey.data(), /*dest_closed_group_pubkey=*/dest.closed_group_pubkey.data(), /*dest_closed_group_keys=*/dest.closed_group_keys, - /*dest_closed_group_swarm_public_key=*/dest.closed_group_swarm_public_key - ? dest.closed_group_swarm_public_key->data() + /*dest_closed_group_swarm_public_key=*/dest.closed_group_public_key + ? dest.closed_group_public_key->data() : nullptr, /*space=*/space, /*use_malloc=*/UseMalloc::No); @@ -500,8 +501,8 @@ session_protocol_encrypt_for_destination( /*dest_closed_group_pubkey=*/dest->closed_group_pubkey, /*dest_closed_group_keys=*/ static_cast(dest->closed_group_keys->internals), - /*dest_closed_group_swarm_public_key=*/dest->has_closed_group_swarm_public_key - ? dest->closed_group_swarm_public_key + /*dest_closed_group_swarm_public_key=*/dest->has_closed_group_public_key + ? dest->closed_group_public_key : nullptr, /*space=*/static_cast(space), /*use_malloc=*/UseMalloc::Yes); From 4f5c8e56019b15bc1ed055237c99aaf5ba563b68 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 13 Aug 2025 18:03:22 +1000 Subject: [PATCH 022/171] Avoid required files in pro messages, handle non-encrypted contents in envelope --- include/session/session_protocol.h | 29 +- include/session/session_protocol.hpp | 45 ++-- include/session/types.h | 18 +- proto/SessionProtos.proto | 14 +- src/config/pro.cpp | 2 + src/session_protocol.cpp | 198 ++++++++------ tests/CMakeLists.txt | 1 + tests/test_session_protocol.cpp | 386 +++++++++++++++++++++++++++ tests/utils.hpp | 71 ++++- 9 files changed, 642 insertions(+), 122 deletions(-) create mode 100644 tests/test_session_protocol.cpp diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 9b09b622..1f58fd04 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -24,7 +24,7 @@ enum { typedef uint64_t PRO_EXTRA_FEATURES; enum PRO_EXTRA_FEATURES_ { PRO_EXTRA_FEATURES_NIL = 0, - PRO_EXTRA_FEATURES_PRO_BADGE = 0 << 1, + PRO_EXTRA_FEATURES_PRO_BADGE = 1 << 0, PRO_EXTRA_FEATURES_ANIMATED_AVATAR = 1 << 1, }; @@ -40,7 +40,8 @@ enum PRO_FEATURES_ { enum PRO_STATUS { PRO_STATUS_NIL, - PRO_STATUS_INVALID, + PRO_STATUS_INVALID_PRO_BACKEND_SIG, + PRO_STATUS_INVALID_USER_SIG, PRO_STATUS_VALID, PRO_STATUS_EXPIRED, }; @@ -60,16 +61,11 @@ struct session_protocol_destination { // into account the signature or otherwise the signature is ignored. bool has_pro_sig; uint8_t pro_sig[64]; - uint8_t recipient_pubkey[32]; + uint8_t recipient_pubkey[33]; uint64_t sent_timestamp_ms; uint8_t open_group_inbox_server_pubkey[32]; uint8_t closed_group_pubkey[33]; const config_group_keys* closed_group_keys; - - // The closed group swarm public key is optional but should be set for a non 0x03 prefix - // `closed_group_pubkey`. Otherwise the public key is ignored when encrypting for a destination. - bool has_closed_group_public_key; - uint8_t closed_group_public_key[33]; }; enum ENVELOPE_TYPE { @@ -129,7 +125,7 @@ struct session_protocol_encrypted_for_destination { /// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in /// `Content` LIBSESSION_EXPORT -PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags); +PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags); /// API: session_protocol/session_protocol_encrypt_for_destination /// @@ -153,6 +149,9 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FE /// require encryption, no payload is returned in the ciphertext and the user should proceed with /// the plaintext. This should be validated by checking the `encrypted` flag on the result. /// +/// The retured payload is suitable for sending on the wire (i.e: it has been protobuf +/// encoded/wrapped if necessary). +/// /// The success flag is set if encryption was successful, if the underlying implementation threw /// an exception then this is set to false. LIBSESSION_EXPORT @@ -176,8 +175,11 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// - `envelope_plaintext` -- the protobuf serialised payload containing the message envelope. The /// envelope must already be decrypted if it was originally encrypted (i.e.: closed group /// envelopes). -/// - `unix_ts` -- pass in the current system time which is used to determine, if present in the -/// envelope, whether or not the Session Pro proof has expired or not. +/// - `unix_ts` -- pass in the current system time which is used to determine, whether or not the +/// Session Pro proof has expired or not if it is in the payload. Ignored otherwise +/// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in +/// the proof, validating whether or not the attached proof was indeed issued by an authorised +/// issuer /// /// Outputs: /// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata @@ -187,7 +189,10 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// an exception then this is set to false. LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts); + const span_u8 ed25519_privkey, + const span_u8 envelope_plaintext, + uint64_t unix_ts, + const span_u8 pro_backend_pubkey); #ifdef __cplusplus } diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 213d8e85..8955e078 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -38,10 +38,11 @@ namespace config::groups { } enum class ProStatus { - Nil, // Pro proof was not set - Invalid, // Pro proof was set; signature validation failed - Valid, // Pro proof was set, is verified; has not expired - Expired, // Pro proof was set, is verified; has expired + Nil, // Pro proof was not set + InvalidProBackendSig, // Pro proof was set; proof sig was not produced by the Pro backend key + InvalidUserSig, // Pro proof was set; envelope sig was not produced by the Rotating key + Valid, // Pro proof was set, is verified; has not expired + Expired, // Pro proof was set, is verified; has expired }; enum class DestinationType { @@ -60,18 +61,17 @@ enum class DestinationType { struct Destination { DestinationType type; - // Signature over the plaintext with the user's Session Pro rotating public key if they have - // Session Pro and opt into sending a message with pro features. If this is specified, the pro - // message component in `Content` must have been set with the corresponding proof for this - // signature. + // Signature over the unencrypted plaintext with the user's Session Pro rotating public key if + // they have Session Pro and opt into sending a message with pro features. If this is specified, + // the pro message component in `Content` must have been set with the corresponding proof for + // this signature. std::optional pro_sig; // Set to the recipient of the message if it requires one. Ignored otherwise (for example // ignored in OpenGroup) - array_uc32 recipient_pubkey; + array_uc33 recipient_pubkey; - // The timestamp to assign to the message envelope if the message requires one. Ignored - // otherwise + // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; // When type => OpenGroupInbox: set this pubkey to the server's key @@ -83,12 +83,6 @@ struct Destination { // Must be set to the group keys for a 0x03 prefix (e.g. groups v2) `closed_group_pubkey` to // encrypt the message. const session::config::groups::Keys* closed_group_keys; - - // Must be set to the closed group's public key (needed for Android) for a non 0x03 prefixed - // `closed_group_pubkey` (e.g. legacy closed groups). Ignored otherwise. This will be set as the - // envelope source. See: - // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 - std::optional closed_group_public_key; }; enum class EnvelopeType { @@ -161,7 +155,7 @@ struct EncryptedForDestination /// Outputs: /// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in /// `Content` -PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_FEATURES flags); +PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags); /// API: session_protocol/encrypt_for_destination /// @@ -196,6 +190,9 @@ PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_FEATURES /// - The encryption result for the plaintext. If the destination and namespace combination did not /// require encryption, no payload is returned in the ciphertext and the user should proceed with /// the plaintext. This should be validated by checking the `encrypted` flag on the result. +/// +/// The retured payload is suitable for sending on the wire (i.e: it has been protobuf +/// encoded/wrapped if necessary). EncryptedForDestination encrypt_for_destination( std::span plaintext, std::span ed25519_privkey, @@ -219,13 +216,16 @@ EncryptedForDestination encrypt_for_destination( /// field to verify if the Session Pro was present and/or valid or invalid. /// /// Inputs: -/// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be +/// - `ed25519_privkey` -- the libsodium-style secret key of the receiver, 64 bytes. Can also be /// passed as a 32-byte seed. Used to decrypt the encrypted content. /// - `envelope_plaintext` -- the protobuf serialised payload containing the message envelope. The /// envelope must already be decrypted if it was originally encrypted (i.e.: closed group /// envelopes). -/// - `unix_ts` -- pass in the current system time which is used to determine, if present in the -/// envelope, whether or not the Session Pro proof has expired or not. +/// - `unix_ts` -- pass in the current system time which is used to determine, whether or not the +/// Session Pro proof has expired or not if it is in the payload. Ignored otherwise +/// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in +/// the proof, validating whether or not the attached proof was indeed issued by an authorised +/// issuer /// /// Outputs: /// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata @@ -233,5 +233,6 @@ EncryptedForDestination encrypt_for_destination( DecryptedEnvelope decrypt_envelope( std::span ed25519_privkey, std::span envelope_plaintext, - std::chrono::sys_seconds unix_ts); + std::chrono::sys_seconds unix_ts, + const array_uc32& pro_backend_pubkey); } // namespace session diff --git a/include/session/types.h b/include/session/types.h index 529a5354..adca1f36 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -3,14 +3,30 @@ #include #include +#if defined(__cplusplus) +#include +#endif + #ifdef __cplusplus extern "C" { #endif -/// C friendly buffer structure that is a pointer and lenght to a span of bytes. +/// C friendly buffer structure that is a pointer and length to a span of bytes. struct span_u8 { uint8_t* data; size_t size; + +#if defined(__cplusplus) + std::span cpp_span() const { return {data, size}; } +#endif +}; + +struct bytes32 { + uint8_t data[32]; +}; + +struct bytes64 { + uint8_t data[64]; }; /// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 4eb51e88..309dbca1 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -330,14 +330,14 @@ message GroupUpdateDeleteMemberContentMessage { } message ProProof { - required uint32 version = 1; - required bytes genIndexHash = 2; - required bytes rotatingPublicKey = 3; - required uint64 expiryUnixTs = 4; - required bytes sig = 5; + optional uint32 version = 1; + optional bytes genIndexHash = 2; + optional bytes rotatingPublicKey = 3; + optional uint64 expiryUnixTs = 4; + optional bytes sig = 5; } message ProMessage { - required ProProof proof = 1; - required uint32 flags = 2; + optional ProProof proof = 1; + optional uint32 flags = 2; } diff --git a/src/config/pro.cpp b/src/config/pro.cpp index c67ac9df..a997fdd5 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -12,6 +12,8 @@ session::array_uc32 proof_hash_internal( std::span gen_index_hash, std::span rotating_pubkey, std::uint64_t expiry_unix_ts) { + // This must match the hashing routine at + // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 session::array_uc32 result = {}; crypto_generichash_blake2b_state state; crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index d693d6e4..0167a972 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "SessionProtos.pb.h" #include "WebSocketResources.pb.h" @@ -16,10 +17,10 @@ namespace session { -PRO_FEATURES get_pro_features_for_msg(std::span msg, PRO_EXTRA_FEATURES extra) { +PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES extra) { PRO_FEATURES result = PRO_FEATURES_NIL; - if (msg.size() >= PRO_STANDARD_CHARACTER_LIMIT) + if (msg_size > PRO_STANDARD_CHARACTER_LIMIT) result |= PRO_FEATURES_10K_CHARACTER_LIMIT; if (extra & PRO_EXTRA_FEATURES_ANIMATED_AVATAR) @@ -43,21 +44,26 @@ struct EncryptedForDestinationInternal { enum class UseMalloc { No, Yes }; static EncryptedForDestinationInternal encrypt_for_destination_internal( - const std::span plaintext, - const std::span ed25519_privkey, + std::span plaintext, + std::span ed25519_privkey, DestinationType dest_type, - const uint8_t* dest_pro_sig, - const uint8_t* dest_recipient_pubkey, + std::span dest_pro_sig, + std::span dest_recipient_pubkey, std::chrono::milliseconds dest_sent_timestamp_ms, - const uint8_t* dest_open_group_inbox_server_pubkey, - const uint8_t* dest_closed_group_pubkey, + std::span dest_open_group_inbox_server_pubkey, + std::span dest_closed_group_pubkey, const config::groups::Keys* dest_closed_group_keys, - const uint8_t* dest_closed_group_public_key, config::Namespace space, UseMalloc use_malloc) { - // All incoming arguments are passed in from typed, fixed-sized arrays so we do not check - // the pointer lengths of those arguments. + assert(dest_pro_sig.empty() || dest_pro_sig.size() == crypto_sign_ed25519_BYTES); + assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); + assert(dest_open_group_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + assert(dest_closed_group_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); + + // All incoming arguments are passed in from typed, fixed-sized arrays so we do not need to + // throw if these sizes are wrong. It being wrong would be a development error. + EncryptedForDestinationInternal result = {}; enum class Mode { Envelope, @@ -103,6 +109,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( "API misuse: Sending to a closed group into the group messages " "namespace requires the closed group keys to be set"); enc.mode = Mode::Envelope; + enc.before_envelope_encrypt_for_recipient_deterministic = false; enc.after_envelope = AfterEnvelope::KeysEncryptMessage; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; @@ -121,12 +128,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; - - if (!dest_closed_group_public_key) - throw std::runtime_error( - "API misuse: Closed group public key must be set on non 0x03 prefixed " - "group keys"); - enc.envelope_src = {dest_closed_group_public_key, sizeof(array_uc33)}; + enc.envelope_src = dest_closed_group_pubkey; } } break; @@ -164,11 +166,11 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( switch (enc.mode) { case Mode::Envelope: { assert(enc.envelope_type.has_value()); - std::span src_text = plaintext; + std::span content = plaintext; if (enc.before_envelope_encrypt_for_recipient_deterministic) { enc.before_envelope_ciphertext = session::encrypt_for_recipient_deterministic( - ed25519_privkey, {dest_recipient_pubkey, sizeof(array_uc32)}, src_text); - src_text = enc.before_envelope_ciphertext; + ed25519_privkey, dest_recipient_pubkey, content); + content = enc.before_envelope_ciphertext; } // Create envelope @@ -178,21 +180,20 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( envelope.set_type(*enc.envelope_type); envelope.set_sourcedevice(1); envelope.set_timestamp(dest_sent_timestamp_ms.count()); - envelope.set_content(src_text.data(), src_text.size()); + envelope.set_content(content.data(), content.size()); if (enc.envelope_src) envelope.set_source( reinterpret_cast(enc.envelope_src->data()), enc.envelope_src->size()); - if (dest_pro_sig) { - envelope.set_prosig( - reinterpret_cast(dest_pro_sig), sizeof(array_uc64)); - } else { + if (dest_pro_sig.empty()) { // If there's no pro signature specified, we still fill out the pro signature with a // dummy 64 byte stream. This is to make pro and non-pro messages indistinguishable. std::string *pro_sig = envelope.mutable_prosig(); pro_sig->resize(sizeof(array_uc64)); randombytes_buf(pro_sig->data(), pro_sig->size()); + } else { + envelope.set_prosig(dest_pro_sig.data(), dest_pro_sig.size()); } result.encrypted = true; @@ -202,18 +203,16 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( break; case AfterEnvelope::WrapInWSMessage: { - // Make request - WebSocketProtos::WebSocketRequestMessage req_msg = {}; - req_msg.set_body(envelope.SerializeAsString()); - - // Put into message + // Setup message WebSocketProtos::WebSocketMessage msg = {}; msg.set_type( WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); - msg.set_allocated_request(&req_msg); + + // Make request + WebSocketProtos::WebSocketRequestMessage *req_msg = msg.mutable_request(); + req_msg->set_body(envelope.SerializeAsString()); // Write message as ciphertext - void* dest = nullptr; if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); msg.SerializeToArray(result.ciphertext_c.data, result.ciphertext_c.size); @@ -230,8 +229,8 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( "when this happens earlier"); std::string bytes = envelope.SerializeAsString(); - std::vector ciphertext = dest_closed_group_keys->encrypt_message( - {reinterpret_cast(bytes.data()), bytes.size()}); + std::vector ciphertext = + dest_closed_group_keys->encrypt_message(to_span(bytes)); if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); @@ -263,8 +262,8 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( result.encrypted = true; std::vector ciphertext = encrypt_for_blinded_recipient( ed25519_privkey, - {dest_open_group_inbox_server_pubkey, sizeof(array_uc32)}, - {dest_recipient_pubkey, sizeof(array_uc32)}, // recipient blinded pubkey + dest_open_group_inbox_server_pubkey, + dest_recipient_pubkey, // recipient blinded pubkey plaintext); if (use_malloc == UseMalloc::Yes) { @@ -288,15 +287,12 @@ EncryptedForDestination encrypt_for_destination( /*plaintext=*/plaintext, /*ed25519_privkey=*/ed25519_privkey, /*dest_type=*/dest.type, - /*dest_pro_sig=*/dest.pro_sig ? dest.pro_sig->data() : nullptr, - /*dest_recipient_pubkey=*/dest.recipient_pubkey.data(), + /*dest_pro_sig=*/dest.pro_sig ? *dest.pro_sig : std::span(), + /*dest_recipient_pubkey=*/dest.recipient_pubkey, /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, - /*dest_open_group_inbox_server_pubkey=*/dest.open_group_inbox_server_pubkey.data(), - /*dest_closed_group_pubkey=*/dest.closed_group_pubkey.data(), + /*dest_open_group_inbox_server_pubkey=*/dest.open_group_inbox_server_pubkey, + /*dest_closed_group_pubkey=*/dest.closed_group_pubkey, /*dest_closed_group_keys=*/dest.closed_group_keys, - /*dest_closed_group_swarm_public_key=*/dest.closed_group_public_key - ? dest.closed_group_public_key->data() - : nullptr, /*space=*/space, /*use_malloc=*/UseMalloc::No); @@ -317,13 +313,14 @@ struct DecryptedEnvelopeInternal { }; DecryptedEnvelope decrypt_envelope( - std::span ed25519_privkey, - std::span envelope_plaintext, - std::chrono::sys_seconds unix_ts) { + std::span ed25519_privkey, + std::span envelope_plaintext, + std::chrono::sys_seconds unix_ts, + const array_uc32& pro_backend_pubkey) { DecryptedEnvelope result = {}; SessionProtos::Envelope envelope = {}; if (!envelope.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) - throw std::runtime_error{"Parse envelope from ciphertext failed"}; + throw std::runtime_error{"Parse envelope from plaintext failed"}; // Parse type (unconditionallty) if (!envelope.has_type()) @@ -370,18 +367,64 @@ DecryptedEnvelope decrypt_envelope( throw std::runtime_error{"Parse decrypted message failed, missing content"}; // Decrypt content - const std::string& content_str = envelope.content(); - auto content_span = std::span( - reinterpret_cast(content_str.data()), content_str.size()); - auto [content_plaintext, sender_ed25519_pubkey] = - session::decrypt_incoming(ed25519_privkey, content_span); - assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); - - result.content_plaintext = std::move(content_plaintext); - std::memcpy( - result.sender_ed25519_pubkey.data(), - sender_ed25519_pubkey.data(), - result.sender_ed25519_pubkey.size()); + // The envelope is encrypted in GroupsV2, contents unencrypted. In 1o1 and legacy groups, the + // envelope is encrypted, contents is encrypted. + // + // On Android and Desktop, the envelope source is always set for legacy and v2 groups. This + // means we can use the envelope source to determine if the contents needs decryption. + // + // On iOS legacy groups have the source set. V2 groups on iOS do _not_ have the sender set. + // Reminder: + // + // v2 => envelope encrypted, contents unencrypted + // legacy => envelope unencrypted, contents encrypted + // + // Since all platforms always set the envelope source for a legacy groups message we can use the + // presence of the envelope source and check the prefix to determine if the contents is + // encrypted, i.e. do the following checks: + // + // 1. Is a closed group message + // 2. The source (pubkey) is set (all platforms set this field on legacy groups messages) + // 3. The pubkey has a legacy prefix (0x05) + // + // Refs: + // clang-format off + // Android: + // Legacy https://github.com/session-foundation/session-android/blob/e4c16ae8aa8cae2f75aba565b890082563b07bd2/app/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt#L189 + // v2 https://github.com/session-foundation/session-android/blob/e4c16ae8aa8cae2f75aba565b890082563b07bd2/app/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt#L176 + // Desktop: + // Legacy https://github.com/session-foundation/session-desktop/blob/4c5cd88fa707a01845f86c0de8920faf160653ea/ts/session/sending/MessageWrapper.ts#L140 + // v2 https://github.com/session-foundation/session-desktop/blob/4c5cd88fa707a01845f86c0de8920faf160653ea/ts/session/sending/MessageWrapper.ts#L49 + // iOS: + // Legacy https://github.com/session-foundation/session-ios/blob/932145ab255b2327ca20fc992ac73758b94b07cd/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 + // v2 https://github.com/session-foundation/session-ios/blob/932145ab255b2327ca20fc992ac73758b94b07cd/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L426 + // clang-format on + bool has_encrypted_content = envelope.type() == SessionProtos::Envelope_Type_SESSION_MESSAGE; + if (envelope.type() == SessionProtos::Envelope_Type_CLOSED_GROUP_MESSAGE && envelope.has_source()) { + const std::string& source_pubkey = envelope.source(); + if (source_pubkey.size() != sizeof(array_uc33)) + throw std::runtime_error{ + "Parse closed group message failed, source was not 33 byte public key"}; + + if (source_pubkey[0] != static_cast(SessionIDPrefix::group)) + has_encrypted_content = true; + } + + if (has_encrypted_content) { + std::span content_str = session::to_span(envelope.content()); + auto [content_plaintext, sender_ed25519_pubkey] = + session::decrypt_incoming(ed25519_privkey, content_str); + assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + + result.content_plaintext = std::move(content_plaintext); + std::memcpy( + result.sender_ed25519_pubkey.data(), + sender_ed25519_pubkey.data(), + result.sender_ed25519_pubkey.size()); + } else { + result.content_plaintext.resize(envelope.content().size()); + std::memcpy(result.content_plaintext.data(), envelope.content().data(), envelope.content().size()); + } // TODO: We parse the content in libsession to extract pro metadata but we return the unparsed // blob back to the caller. This is temporary, eventually we will return a proxy structure for @@ -389,8 +432,8 @@ DecryptedEnvelope decrypt_envelope( // the interface simple and avoid leaking protobuf implementation detail into the libsession // interface. SessionProtos::Content content = {}; - if (!envelope.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) - throw std::runtime_error{"Parse content from envelope failed"}; + if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) + throw std::runtime_error{fmt::format("Parse content from envelope failed: {}", result.content_plaintext.size())}; // A signature must always be present on the envelope. This is to make a pro and non-pro // envelope indistinguishable. If the message does not have pro then this signature must still @@ -436,10 +479,10 @@ DecryptedEnvelope decrypt_envelope( // Verify the sig since we have extracted the rotating public key from the embedded proof int verify_result = crypto_sign_ed25519_verify_detached( reinterpret_cast(pro_sig.data()), - reinterpret_cast(content_str.data()), - content_str.size(), + result.content_plaintext.data(), + result.content_plaintext.size(), reinterpret_cast(proto_proof.rotatingpublickey().data())); - result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::Invalid; + result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; // Fill out the resulting proof structure, we have parsed successfully result.pro_features = proto_flags; @@ -460,12 +503,14 @@ DecryptedEnvelope decrypt_envelope( if (result.pro_status == ProStatus::Valid) { // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It has been // authorised by the backend as having a valid backing payment). - if (proof.verify(session::pro_backend::PUBKEY)) + if (proof.verify(pro_backend_pubkey)) result.pro_status = ProStatus::Valid; + else + result.pro_status = ProStatus::InvalidProBackendSig; // Check if the proof has expired if (result.pro_status == ProStatus::Valid) { - if (unix_ts >= result.pro_proof.expiry_unix_ts) + if (unix_ts > result.pro_proof.expiry_unix_ts) result.pro_status = ProStatus::Expired; } } @@ -477,8 +522,8 @@ DecryptedEnvelope decrypt_envelope( using namespace session; LIBSESSION_EXPORT -PRO_FEATURES session_protocol_get_pro_features_for_msg(const span_u8 msg, PRO_FEATURES flags) { - PRO_FEATURES result = get_pro_features_for_msg({msg.data, msg.size}, flags); +PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags) { + PRO_FEATURES result = get_pro_features_for_msg(msg_size, flags); return result; } @@ -494,16 +539,13 @@ session_protocol_encrypt_for_destination( /*plaintext=*/{plaintext.data, plaintext.size}, /*ed25519_privkey=*/{ed25519_privkey.data, ed25519_privkey.size}, /*dest_type=*/static_cast(dest->type), - /*dest_pro_sig=*/dest->has_pro_sig ? dest->pro_sig : nullptr, + /*dest_pro_sig=*/dest->has_pro_sig ? dest->pro_sig : std::span(), /*dest_recipient_pubkey=*/dest->recipient_pubkey, /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), /*dest_open_group_inbox_server_pubkey=*/dest->open_group_inbox_server_pubkey, /*dest_closed_group_pubkey=*/dest->closed_group_pubkey, /*dest_closed_group_keys=*/ static_cast(dest->closed_group_keys->internals), - /*dest_closed_group_swarm_public_key=*/dest->has_closed_group_public_key - ? dest->closed_group_public_key - : nullptr, /*space=*/static_cast(space), /*use_malloc=*/UseMalloc::Yes); @@ -520,13 +562,17 @@ session_protocol_encrypt_for_destination( LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const span_u8 ed25519_privkey, const span_u8 envelope_plaintext, uint64_t unix_ts) { + const span_u8 ed25519_privkey, + const span_u8 envelope_plaintext, + uint64_t unix_ts, + const span_u8 pro_backend_pubkey) { session_protocol_decrypted_envelope result = {}; try { DecryptedEnvelope result_cpp = decrypt_envelope( - {ed25519_privkey.data, ed25519_privkey.size}, - {envelope_plaintext.data, envelope_plaintext.size}, - std::chrono::sys_seconds(std::chrono::seconds(unix_ts))); + ed25519_privkey.cpp_span(), + envelope_plaintext.cpp_span(), + std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), + {}); // Marshall into c type result = { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5be475bb..66b7e7b2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,6 +29,7 @@ set(LIB_SESSION_UTESTS_SOURCES test_proto.cpp test_random.cpp test_session_encrypt.cpp + test_session_protocol.cpp test_xed25519.cpp case_logger.cpp diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp new file mode 100644 index 00000000..86820102 --- /dev/null +++ b/tests/test_session_protocol.cpp @@ -0,0 +1,386 @@ +#include + +#include +#include +#include +#include +#include +#include +#include "SessionProtos.pb.h" + +#include "utils.hpp" + +using namespace session; + +TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { + + using namespace session; + TestKeys keys = get_deterministic_test_keys(); + + // Tuesday, 12 August 2025 03:58:21 UTC + const std::chrono::milliseconds timestamp_ms = std::chrono::seconds(1754971101); + const std::string_view data_body = "hello"; + + SECTION("Encrypt with and w/o pro sig produce same payload size") { + // Same payload size because the encrypt function should put in a dummy signature if one + // wasn't specific to make pro and non-pro envelopes indistinguishable. + + session::Destination dest = {}; + dest.type = DestinationType::Contact; + dest.sent_timestamp_ms = timestamp_ms; + dest.recipient_pubkey = keys.session_pk1; + + // Withhold the pro signature + dest.pro_sig = std::nullopt; + EncryptedForDestination encrypt_without_pro_sig = encrypt_for_destination( + to_span(data_body), keys.ed_sk0, dest, config::Namespace::Default); + + // Set the pro signature + dest.pro_sig.emplace(); + EncryptedForDestination encrypt_with_pro_sig = encrypt_for_destination( + to_span(data_body), keys.ed_sk0, dest, config::Namespace::Default); + + REQUIRE(encrypt_without_pro_sig.encrypted); + REQUIRE(encrypt_with_pro_sig.encrypted); + + // Should have the same payload size + REQUIRE(encrypt_without_pro_sig.ciphertext.size() == encrypt_with_pro_sig.ciphertext.size()); + } + + SECTION("Encrypt/decrypt for contact in default namespace") { + // Build content + std::string plaintext; + { + SessionProtos::Content content = {}; + SessionProtos::DataMessage* data = content.mutable_datamessage(); + data->set_body(std::string(data_body)); + plaintext = content.SerializeAsString(); + REQUIRE(plaintext.size() > data_body.size()); + } + + // Encrypt + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = {}; + dest.type = DestinationType::Contact; + dest.sent_timestamp_ms = timestamp_ms; + REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); + std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + + encrypt_result = session::encrypt_for_destination( + to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); + } + + // Decrypt envelope + DecryptedEnvelope decrypt_result = session::decrypt_envelope( + keys.ed_sk1, + encrypt_result.ciphertext, + std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)), pro_backend::PUBKEY); + + // Verify pro + config::ProProof nil_proof = {}; + REQUIRE(decrypt_result.pro_status == ProStatus::Nil); // Pro was not attached + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); + REQUIRE(decrypt_result.pro_proof.hash() == nil_proof.hash()); + + // Verify it is decryptable + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + } + + SECTION("Ensure get pro fetaures detects large message") { + // Try a message below the size threshold + PRO_FEATURES features = get_pro_features_for_msg( + PRO_STANDARD_CHARACTER_LIMIT, + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); + + // Try a message exceeding the size threshold + features = get_pro_features_for_msg( + PRO_STANDARD_CHARACTER_LIMIT + 1, + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | + PRO_FEATURES_ANIMATED_AVATAR)); + + // Try asking for just one extra feature + features = get_pro_features_for_msg(100, PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(features == PRO_FEATURES_PRO_BADGE); + } + + // Prepare a Session Pro proof + // We reuse test key 1 as the "Session Pro" backend key that signs the proofs as it + // doesn't matter what key really, just that we have one for signing. + const array_uc64& pro_backend_ed_sk = keys.ed_sk1; + const array_uc32& pro_backend_ed_pk = keys.ed_pk1; + + // Generate the user's Session Pro rotating key for testing encrypted payloads with Session + // Pro metadata + const auto user_pro_seed = + "0123456789abcdef0123456789abcdeff00baa00000000000000000000000000"_hexbytes; + array_uc32 user_pro_ed_pk; + array_uc64 user_pro_ed_sk; + crypto_sign_ed25519_seed_keypair( + user_pro_ed_pk.data(), user_pro_ed_sk.data(), user_pro_seed.data()); + + // Build protobuf `Content` message, serialise to `plaintext` and get it signed by the user's + // "Session Pro" key into `sig_over_plaintext_with_user_pro_key` + std::string plaintext; + array_uc64 sig_over_plaintext_with_user_pro_key = {}; + array_uc32 pro_proof_hash = {}; + { + SessionProtos::Content content = {}; + + // Create protobuf `Content.dataMessage` + SessionProtos::DataMessage* data = content.mutable_datamessage(); + data->set_body(std::string(data_body)); + + // Generate a dummy proof + config::ProProof proof = {}; + proof.rotating_pubkey = user_pro_ed_pk; + proof.expiry_unix_ts = std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)); + + // Sign the proof by the dummy "Session Pro Backend" key + pro_proof_hash = proof.hash(); + crypto_sign_ed25519_detached( + proof.sig.data(), + nullptr, + pro_proof_hash.data(), + pro_proof_hash.size(), + pro_backend_ed_sk.data()); + + // Create protobuf `Content.proMessage` + SessionProtos::ProMessage *pro = content.mutable_promessage(); + pro->set_flags(PRO_FEATURES_NIL); + + // Create protobuf `Content.proMessage.proof` + SessionProtos::ProProof *proto_proof = pro->mutable_proof(); + proto_proof->set_version(proof.version); + proto_proof->set_genindexhash(proof.gen_index_hash.data(), proof.gen_index_hash.size()); + proto_proof->set_rotatingpublickey(proof.rotating_pubkey.data(), proof.rotating_pubkey.size()); + proto_proof->set_expiryunixts(proof.expiry_unix_ts.time_since_epoch().count()); + proto_proof->set_sig(proof.sig.data(), proof.sig.size()); + + // Generate the plaintext + plaintext = content.SerializeAsString(); + REQUIRE(plaintext.size() > data_body.size()); + + // Sign the plaintext with the user's pro key + crypto_sign_ed25519_detached( + sig_over_plaintext_with_user_pro_key.data(), + nullptr, + reinterpret_cast(plaintext.data()), + plaintext.size(), + user_pro_ed_sk.data()); + } + + SECTION("Encrypt/decrypt for contact in default namespace with Pro") { + // Build content + std::string plaintext; + array_uc64 sig_over_plaintext_with_user_pro_key = {}; + array_uc32 pro_proof_hash = {}; + { + SessionProtos::Content content = {}; + + // Create protobuf `Content.dataMessage` + SessionProtos::DataMessage* data = content.mutable_datamessage(); + data->set_body(std::string(data_body)); + + // Generate a dummy proof + config::ProProof proof = {}; + proof.rotating_pubkey = user_pro_ed_pk; + proof.expiry_unix_ts = std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)); + + // Sign the proof by the dummy "Session Pro Backend" key + pro_proof_hash = proof.hash(); + crypto_sign_ed25519_detached( + proof.sig.data(), + nullptr, + pro_proof_hash.data(), + pro_proof_hash.size(), + pro_backend_ed_sk.data()); + + // Create protobuf `Content.proMessage` + SessionProtos::ProMessage *pro = content.mutable_promessage(); + pro->set_flags(PRO_FEATURES_NIL); + + // Create protobuf `Content.proMessage.proof` + SessionProtos::ProProof *proto_proof = pro->mutable_proof(); + proto_proof->set_version(proof.version); + proto_proof->set_genindexhash(proof.gen_index_hash.data(), proof.gen_index_hash.size()); + proto_proof->set_rotatingpublickey(proof.rotating_pubkey.data(), proof.rotating_pubkey.size()); + proto_proof->set_expiryunixts(proof.expiry_unix_ts.time_since_epoch().count()); + proto_proof->set_sig(proof.sig.data(), proof.sig.size()); + + // Generate the plaintext + plaintext = content.SerializeAsString(); + REQUIRE(plaintext.size() > data_body.size()); + + // Sign the plaintext with the user's pro key + crypto_sign_ed25519_detached( + sig_over_plaintext_with_user_pro_key.data(), + nullptr, + reinterpret_cast(plaintext.data()), + plaintext.size(), + user_pro_ed_sk.data()); + } + + // Encrypt + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = {}; + dest.type = DestinationType::Contact; + dest.sent_timestamp_ms = timestamp_ms; + dest.pro_sig = sig_over_plaintext_with_user_pro_key; + REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); + std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + + encrypt_result = session::encrypt_for_destination( + to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); + } + + // Decrypt envelope + DecryptedEnvelope decrypt_result = session::decrypt_envelope( + keys.ed_sk1, + encrypt_result.ciphertext, + std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)), + pro_backend_ed_pk); + + // Verify pro + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == pro_proof_hash); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + + // Verify it is decryptable + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + } + + SECTION("Check non-encryptable messages produce plaintext") { + auto dest_list = { + DestinationType::OpenGroup, + DestinationType::OpenGroupInbox, + DestinationType::Contact}; + + for (auto dest_type : dest_list) { + if (dest_type == DestinationType::OpenGroup) + INFO("Trying open groups"); + else if (dest_type == DestinationType::OpenGroupInbox) + INFO("Trying open group inbox"); + else + INFO("Trying contacts to non-default namespace"); + + session::Destination dest = {}; + dest.type = dest_type; + dest.sent_timestamp_ms = timestamp_ms; + dest.pro_sig = sig_over_plaintext_with_user_pro_key; + REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); + std::memcpy( + dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + + config::Namespace space = config::Namespace::Default; + if (dest_type == DestinationType::Contact) { + space = config::Namespace::Contacts; + dest.recipient_pubkey[0] = 0x15; + } + + EncryptedForDestination encrypt_result = + session::encrypt_for_destination(to_span(plaintext), keys.ed_sk0, dest, space); + REQUIRE_FALSE(encrypt_result.encrypted); + REQUIRE(encrypt_result.ciphertext.empty()); + } + } + + + SECTION("Encrypt/decrypt for legacy closed group (w/ encrypted envelope, plaintext content) " + "with Pro") { + + // Encrypt + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = {}; + dest.type = DestinationType::ClosedGroup; + dest.sent_timestamp_ms = timestamp_ms; + dest.pro_sig = sig_over_plaintext_with_user_pro_key; + REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); + std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + + encrypt_result = session::encrypt_for_destination( + to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); + } + + // Decrypt envelope + DecryptedEnvelope decrypt_result = session::decrypt_envelope( + keys.ed_sk1, + encrypt_result.ciphertext, + std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)), + pro_backend_ed_pk); + + // Verify pro + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == pro_proof_hash); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + + // Verify it is decryptable + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + } + + SECTION("Encrypt/decrypt for sync messages with Pro") { + + // Encrypt + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = {}; + dest.type = DestinationType::SyncMessage; + dest.sent_timestamp_ms = timestamp_ms; + dest.pro_sig = sig_over_plaintext_with_user_pro_key; + REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); + std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + + encrypt_result = session::encrypt_for_destination( + to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); + } + + // Decrypt envelope + DecryptedEnvelope decrypt_result = session::decrypt_envelope( + keys.ed_sk1, + encrypt_result.ciphertext, + std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)), + pro_backend_ed_pk); + + // Verify pro + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == pro_proof_hash); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + + // Verify it is decryptable + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + } +} diff --git a/tests/utils.hpp b/tests/utils.hpp index cf4d70cd..4b4474ce 100644 --- a/tests/utils.hpp +++ b/tests/utils.hpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -11,12 +10,11 @@ #include #include #include -#include #include -#include "session/config/base.h" -#include "session/types.hpp" #include "session/util.hpp" +#include "session/types.hpp" +#include using namespace std::literals; using namespace oxenc::literals; @@ -125,3 +123,68 @@ template std::set> make_set(T&&... args) { return {std::forward(args)...}; } + +struct TestKeys { + session::array_uc32 seed0; + session::array_uc64 ed_sk0; + session::array_uc32 ed_pk0; + session::array_uc32 curve_pk0; + session::array_uc33 session_pk0; + + session::array_uc32 seed1; + session::array_uc64 ed_sk1; + session::array_uc32 ed_pk1; + session::array_uc32 curve_pk1; + session::array_uc33 session_pk1; +}; + +static inline TestKeys get_deterministic_test_keys() { + TestKeys result = {}; + + // clang-format off + // Key 0 + { + // Seed + auto seed0 = "0123456789abcdef0123456789abcdef00000000000000000000000000000000"_hexbytes; + std::memcpy(result.seed0.data(), seed0.data(), seed0.size()); + + // Ed25519 + crypto_sign_ed25519_seed_keypair(result.ed_pk0.data(), result.ed_sk0.data(), result.seed0.data()); + + // X25519 + assert(0 == crypto_sign_ed25519_pk_to_curve25519(result.curve_pk0.data(), result.ed_pk0.data())); + + // Session PK + result.session_pk0[0] = 0x05; + std::memcpy(result.session_pk0.data() + 1, result.curve_pk0.data(), result.curve_pk0.size()); + } + + // Key 1 + { + // Seed + auto seed1 = "00112233445566778899aabbccddeeff00000000000000000000000000000000"_hexbytes; + std::memcpy(result.seed1.data(), seed1.data(), seed1.size()); + + // Ed25519 + crypto_sign_ed25519_seed_keypair(result.ed_pk1.data(), result.ed_sk1.data(), result.seed1.data()); + + // X25519 + assert(0 == crypto_sign_ed25519_pk_to_curve25519(result.curve_pk1.data(), result.ed_pk1.data())); + + // Session PK + result.session_pk1[0] = 0x05; + std::memcpy(result.session_pk1.data() + 1, result.curve_pk1.data(), result.curve_pk1.size()); + } + + assert(oxenc::to_hex(result.ed_sk0.begin(), result.ed_sk0.data() + crypto_sign_ed25519_SEEDBYTES) == oxenc::to_hex(result.seed0)); + assert(oxenc::to_hex(result.ed_pk0) == "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"); + assert(oxenc::to_hex(result.curve_pk0) == "d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"); + assert(oxenc::to_hex(result.session_pk0) == "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"); + + assert(oxenc::to_hex(result.ed_sk1.begin(), result.ed_sk1.data() + crypto_sign_ed25519_SEEDBYTES) == oxenc::to_hex(result.seed1)); + assert(oxenc::to_hex(result.ed_pk1) == "5ea34e72bb044654a6a23675690ef5ffaaf1656b02f93fb76655f9cbdbe89876"); + assert(oxenc::to_hex(result.curve_pk1) == "aa654f00fc39fc69fd0db829410ca38177d7732a8d2f0934ab3872ac56d5aa74"); + assert(oxenc::to_hex(result.session_pk1) == "05aa654f00fc39fc69fd0db829410ca38177d7732a8d2f0934ab3872ac56d5aa74"); + // clang-format on + return result; +} From 17fcc1fe78fc27ada9f171d898fee2dec8a63e0d Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 13 Aug 2025 18:03:50 +1000 Subject: [PATCH 023/171] Regen the protobufs w/ non required fields for pro structures --- proto/SessionProtos.pb.cc | 179 +++++++++++++------------------------- proto/SessionProtos.pb.h | 34 +++----- 2 files changed, 75 insertions(+), 138 deletions(-) diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index b5029232..35074b0c 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -3296,9 +3296,6 @@ bool Content::IsInitialized() const { if (_internal_has_sharedconfigmessage()) { if (!_impl_.sharedconfigmessage_->IsInitialized()) return false; } - if (_internal_has_promessage()) { - if (!_impl_.promessage_->IsInitialized()) return false; - } return true; } @@ -10928,9 +10925,6 @@ class ProProof::_Internal { static void set_has_sig(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x0000001f) ^ 0x0000001f) != 0; - } }; ProProof::ProProof(::PROTOBUF_NAMESPACE_ID::Arena* arena, @@ -11063,7 +11057,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required uint32 version = 1; + // optional uint32 version = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { _Internal::set_has_version(&has_bits); @@ -11072,7 +11066,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // required bytes genIndexHash = 2; + // optional bytes genIndexHash = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { auto str = _internal_mutable_genindexhash(); @@ -11081,7 +11075,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // required bytes rotatingPublicKey = 3; + // optional bytes rotatingPublicKey = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { auto str = _internal_mutable_rotatingpublickey(); @@ -11090,7 +11084,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // required uint64 expiryUnixTs = 4; + // optional uint64 expiryUnixTs = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { _Internal::set_has_expiryunixts(&has_bits); @@ -11099,7 +11093,7 @@ const char* ProProof::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // required bytes sig = 5; + // optional bytes sig = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { auto str = _internal_mutable_sig(); @@ -11139,31 +11133,31 @@ uint8_t* ProProof::_InternalSerialize( (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required uint32 version = 1; + // optional uint32 version = 1; if (cached_has_bits & 0x00000010u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_version(), target); } - // required bytes genIndexHash = 2; + // optional bytes genIndexHash = 2; if (cached_has_bits & 0x00000001u) { target = stream->WriteBytesMaybeAliased( 2, this->_internal_genindexhash(), target); } - // required bytes rotatingPublicKey = 3; + // optional bytes rotatingPublicKey = 3; if (cached_has_bits & 0x00000002u) { target = stream->WriteBytesMaybeAliased( 3, this->_internal_rotatingpublickey(), target); } - // required uint64 expiryUnixTs = 4; + // optional uint64 expiryUnixTs = 4; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_expiryunixts(), target); } - // required bytes sig = 5; + // optional bytes sig = 5; if (cached_has_bits & 0x00000004u) { target = stream->WriteBytesMaybeAliased( 5, this->_internal_sig(), target); @@ -11177,76 +11171,48 @@ uint8_t* ProProof::_InternalSerialize( return target; } -size_t ProProof::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProProof) - size_t total_size = 0; - - if (_internal_has_genindexhash()) { - // required bytes genIndexHash = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_genindexhash()); - } - - if (_internal_has_rotatingpublickey()) { - // required bytes rotatingPublicKey = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingpublickey()); - } - - if (_internal_has_sig()) { - // required bytes sig = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_sig()); - } - - if (_internal_has_expiryunixts()) { - // required uint64 expiryUnixTs = 4; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); - } - - if (_internal_has_version()) { - // required uint32 version = 1; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); - } - - return total_size; -} size_t ProProof::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProProof) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x0000001f) ^ 0x0000001f) == 0) { // All required fields are present. - // required bytes genIndexHash = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_genindexhash()); + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; - // required bytes rotatingPublicKey = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_rotatingpublickey()); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000001fu) { + // optional bytes genIndexHash = 2; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_genindexhash()); + } - // required bytes sig = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->_internal_sig()); + // optional bytes rotatingPublicKey = 3; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_rotatingpublickey()); + } - // required uint64 expiryUnixTs = 4; - total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + // optional bytes sig = 5; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_sig()); + } - // required uint32 version = 1; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + // optional uint64 expiryUnixTs = 4; + if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_expiryunixts()); + } - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; + // optional uint32 version = 1; + if (cached_has_bits & 0x00000010u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_version()); + } + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -11298,7 +11264,6 @@ void ProProof::CopyFrom(const ProProof& from) { } bool ProProof::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } @@ -11345,9 +11310,6 @@ class ProMessage::_Internal { static void set_has_flags(HasBits* has_bits) { (*has_bits)[0] |= 2u; } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } }; const ::SessionProtos::ProProof& @@ -11430,7 +11392,7 @@ const char* ProMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ct uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // required .SessionProtos.ProProof proof = 1; + // optional .SessionProtos.ProProof proof = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_proof(), ptr); @@ -11438,7 +11400,7 @@ const char* ProMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ct } else goto handle_unusual; continue; - // required uint32 flags = 2; + // optional uint32 flags = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { _Internal::set_has_flags(&has_bits); @@ -11478,14 +11440,14 @@ uint8_t* ProMessage::_InternalSerialize( (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - // required .SessionProtos.ProProof proof = 1; + // optional .SessionProtos.ProProof proof = 1; if (cached_has_bits & 0x00000001u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::proof(this), _Internal::proof(this).GetCachedSize(), target, stream); } - // required uint32 flags = 2; + // optional uint32 flags = 2; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_flags(), target); @@ -11499,44 +11461,29 @@ uint8_t* ProMessage::_InternalSerialize( return target; } -size_t ProMessage::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:SessionProtos.ProMessage) - size_t total_size = 0; - - if (_internal_has_proof()) { - // required .SessionProtos.ProProof proof = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); - } - - if (_internal_has_flags()) { - // required uint32 flags = 2; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - } - - return total_size; -} size_t ProMessage::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:SessionProtos.ProMessage) size_t total_size = 0; - if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required .SessionProtos.ProProof proof = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.proof_); - - // required uint32 flags = 2; - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + // optional .SessionProtos.ProProof proof = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.proof_); + } + + // optional uint32 flags = 2; + if (cached_has_bits & 0x00000002u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + } + + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } @@ -11580,10 +11527,6 @@ void ProMessage::CopyFrom(const ProMessage& from) { } bool ProMessage::IsInitialized() const { - if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; - if (_internal_has_proof()) { - if (!_impl_.proof_->IsInitialized()) return false; - } return true; } diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index 10c96518..7b37ecf0 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -6422,7 +6422,7 @@ class ProProof final : kExpiryUnixTsFieldNumber = 4, kVersionFieldNumber = 1, }; - // required bytes genIndexHash = 2; + // optional bytes genIndexHash = 2; bool has_genindexhash() const; private: bool _internal_has_genindexhash() const; @@ -6440,7 +6440,7 @@ class ProProof final : std::string* _internal_mutable_genindexhash(); public: - // required bytes rotatingPublicKey = 3; + // optional bytes rotatingPublicKey = 3; bool has_rotatingpublickey() const; private: bool _internal_has_rotatingpublickey() const; @@ -6458,7 +6458,7 @@ class ProProof final : std::string* _internal_mutable_rotatingpublickey(); public: - // required bytes sig = 5; + // optional bytes sig = 5; bool has_sig() const; private: bool _internal_has_sig() const; @@ -6476,7 +6476,7 @@ class ProProof final : std::string* _internal_mutable_sig(); public: - // required uint64 expiryUnixTs = 4; + // optional uint64 expiryUnixTs = 4; bool has_expiryunixts() const; private: bool _internal_has_expiryunixts() const; @@ -6489,7 +6489,7 @@ class ProProof final : void _internal_set_expiryunixts(uint64_t value); public: - // required uint32 version = 1; + // optional uint32 version = 1; bool has_version() const; private: bool _internal_has_version() const; @@ -6506,9 +6506,6 @@ class ProProof final : private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -6639,7 +6636,7 @@ class ProMessage final : kProofFieldNumber = 1, kFlagsFieldNumber = 2, }; - // required .SessionProtos.ProProof proof = 1; + // optional .SessionProtos.ProProof proof = 1; bool has_proof() const; private: bool _internal_has_proof() const; @@ -6657,7 +6654,7 @@ class ProMessage final : ::SessionProtos::ProProof* proof); ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // required uint32 flags = 2; + // optional uint32 flags = 2; bool has_flags() const; private: bool _internal_has_flags() const; @@ -6674,9 +6671,6 @@ class ProMessage final : private: class _Internal; - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -13397,7 +13391,7 @@ inline void GroupUpdateDeleteMemberContentMessage::set_allocated_adminsignature( // ProProof -// required uint32 version = 1; +// optional uint32 version = 1; inline bool ProProof::_internal_has_version() const { bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; @@ -13425,7 +13419,7 @@ inline void ProProof::set_version(uint32_t value) { // @@protoc_insertion_point(field_set:SessionProtos.ProProof.version) } -// required bytes genIndexHash = 2; +// optional bytes genIndexHash = 2; inline bool ProProof::_internal_has_genindexhash() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; @@ -13493,7 +13487,7 @@ inline void ProProof::set_allocated_genindexhash(std::string* genindexhash) { // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.genIndexHash) } -// required bytes rotatingPublicKey = 3; +// optional bytes rotatingPublicKey = 3; inline bool ProProof::_internal_has_rotatingpublickey() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; @@ -13561,7 +13555,7 @@ inline void ProProof::set_allocated_rotatingpublickey(std::string* rotatingpubli // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProProof.rotatingPublicKey) } -// required uint64 expiryUnixTs = 4; +// optional uint64 expiryUnixTs = 4; inline bool ProProof::_internal_has_expiryunixts() const { bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; @@ -13589,7 +13583,7 @@ inline void ProProof::set_expiryunixts(uint64_t value) { // @@protoc_insertion_point(field_set:SessionProtos.ProProof.expiryUnixTs) } -// required bytes sig = 5; +// optional bytes sig = 5; inline bool ProProof::_internal_has_sig() const { bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; @@ -13661,7 +13655,7 @@ inline void ProProof::set_allocated_sig(std::string* sig) { // ProMessage -// required .SessionProtos.ProProof proof = 1; +// optional .SessionProtos.ProProof proof = 1; inline bool ProMessage::_internal_has_proof() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; PROTOBUF_ASSUME(!value || _impl_.proof_ != nullptr); @@ -13751,7 +13745,7 @@ inline void ProMessage::set_allocated_proof(::SessionProtos::ProProof* proof) { // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProMessage.proof) } -// required uint32 flags = 2; +// optional uint32 flags = 2; inline bool ProMessage::_internal_has_flags() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; From 171e07832ec74f01d0c3a3e0202caaf74ade4729 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 16:09:36 +1000 Subject: [PATCH 024/171] Allow envelope decrypt to handle encrypted v2 group envelopes --- include/session/session_protocol.h | 55 ++- include/session/session_protocol.hpp | 76 ++-- proto/SessionProtos.pb.cc | 32 +- proto/SessionProtos.pb.h | 52 +-- proto/SessionProtos.proto | 4 +- src/session_protocol.cpp | 114 +++--- tests/test_session_protocol.cpp | 571 +++++++++++++++++---------- 7 files changed, 554 insertions(+), 350 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 1f58fd04..fba14177 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -91,6 +91,23 @@ struct session_protocol_envelope { uint8_t pro_sig[64]; }; +struct session_protocol_decrypt_envelope_keys { + // Indicate to the envelope decrypting function that it should use the group keys to decrypt the + // envelope (e.g.: for groups v2 envelopes where the envelope is encrypted and the body + // unencrypted). The `group_keys` must be set if this flag is true. The recipient ed25519 + // private key field is ignored if this flag is set. + bool use_group_keys; + + // Keys to use to decrypt the envelope. + const config_group_keys* group_keys; + + // The libsodium-style secret key of the sender, 64 bytes. Can also be passed as a 32-byte seed. + // Used to decrypt the encrypted content. This field is used if `use_group_keys` is false in + // which case the group keys are ignored. This is for envelopes where the envelope itself is + // unencrypted and the contents is encrypted for this secret key. + std::span recipient_ed25519_privkey; +}; + struct session_protocol_decrypted_envelope { // Indicates if the decryption was successful. If the decryption step failed and threw an // exception, this is false. @@ -153,7 +170,7 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEAT /// encoded/wrapped if necessary). /// /// The success flag is set if encryption was successful, if the underlying implementation threw -/// an exception then this is set to false. +/// an exception then this is caught internally and success is set to false. LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( const span_u8 plaintext, @@ -163,20 +180,30 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// API: session_protocol/session_protocol_decrypt_envelope /// -/// Given an unencrypted plaintext representation of an envelope (i.e.: protobuf encoded stream of -/// `Envelope`) parse the envelope and return the envelope content decrypted to plaintext with the -/// passed in key. +/// Given an envelope payload (i.e.: protobuf encoded stream of `Envelope` or encrypted `Envelope` +/// using a Groups v2 key) parse (or decrypt) the envelope and return the envelope content decrypted +/// if necessary. +/// +/// A groups v2 envelope will get decrypted with the group keys. A non-groups v2 envelope will get +/// decrypted with the specified Ed25519 private key in the `keys` object. Only one of these keys +/// need to be set depending on the type of envelope payload passed into the function. /// /// See: session_protocol/decrypt_envelope for more information /// /// Inputs: -/// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be -/// passed as a 32-byte seed. Used to decrypt the encrypted content. -/// - `envelope_plaintext` -- the protobuf serialised payload containing the message envelope. The -/// envelope must already be decrypted if it was originally encrypted (i.e.: closed group -/// envelopes). -/// - `unix_ts` -- pass in the current system time which is used to determine, whether or not the -/// Session Pro proof has expired or not if it is in the payload. Ignored otherwise +/// - `keys` -- the keys to decrypt either the envelope or the envelope contents. Groups v2 +/// envelopes where the envelope is encrypted must set the group key. Envelopes with an encrypted +/// content must set the the libsodium-style secret key of the receiver, 64 bytes. Can also be +/// passed as a 32-byte seed. +/// +/// If a group decryption key is specified, the recipient key is ignored and vice versa. Only one +/// of the keys should be set depending on the type of envelope. +/// +/// - `envelope_payload` -- the envelope payload either encrypted (groups v2 style) or unencrypted +/// (1o1 or legacy groups). +/// - `unix_ts` -- pass in the current system time in seconds which is used to determine, whether or +/// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no +/// proof in the message. /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in /// the proof, validating whether or not the attached proof was indeed issued by an authorised /// issuer @@ -186,11 +213,11 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// within the envelope if there were any. /// /// The success flag is set if encryption was successful, if the underlying implementation threw -/// an exception then this is set to false. +/// an exception then this is caught internally and success is set to false. LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const span_u8 ed25519_privkey, - const span_u8 envelope_plaintext, + const session_protocol_decrypt_envelope_keys* keys, + const span_u8 envelope_payload, uint64_t unix_ts, const span_u8 pro_backend_pubkey); diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 8955e078..6b710b18 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -10,7 +10,10 @@ /// protocol types. This file contains high-level helper functions for decoding payloads on the /// Session protocol. Prefer functions here before resorting to the lower-level cryptography. -// NOTE: CPP doesn't support named bitfields without casting or operator overloads but C-style +// NOTE: In the CPP file we use C-style enums for bitfields and CPP-style enums for non-bitfield +// enums where we can to benefit from the type-safety of strong enums. +// +// CPP doesn't support named bitfields without casting or operator overloads but C-style // enums support it very well. The only issue is that using a native C-style enum enforces some type // restrictions that compilers dislike when attempting to manipulate bit fields. For example: // @@ -27,9 +30,6 @@ // // Does not trigger errors as the underlying type of `f` is actually an unsigned integer. The type // define is merely a hint to the user to what flags are to be used when manipulating the variable. -// -// Hence in the CPP file we use C-style enums for bitfields and CPP-style enums for non-bitfield -// enums where we can to benefit from the type-safety of strong enums. namespace session { @@ -38,11 +38,11 @@ namespace config::groups { } enum class ProStatus { - Nil, // Pro proof was not set - InvalidProBackendSig, // Pro proof was set; proof sig was not produced by the Pro backend key - InvalidUserSig, // Pro proof was set; envelope sig was not produced by the Rotating key - Valid, // Pro proof was set, is verified; has not expired - Expired, // Pro proof was set, is verified; has expired + Nil, // Proof not set + InvalidProBackendSig, // Proof set; pro proof sig was not produced by the Pro backend key + InvalidUserSig, // Proof set; envelope pro sig was not produced by the Rotating key + Valid, // Proof set, is verified; has not expired + Expired, // Proof set, is verified; has expired }; enum class DestinationType { @@ -113,9 +113,13 @@ struct DecryptedEnvelope { // Decrypted envelope content into plaintext std::vector content_plaintext; - // Sender public key extracted from the encrypted content payload + // Sender public key extracted from the encrypted content payload. This is not set if the + // envelope was a groups v2 envelope where the envelope was encrypted and only the x25519 pubkey + // was available. array_uc32 sender_ed25519_pubkey; + array_uc32 sender_x25519_pubkey; + // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. // The status is set to `Nil` if there is no Session Pro proof in the message. Otherwise it's // set to one of the other values to which the remaining pro fields will be populated with data @@ -130,6 +134,24 @@ struct DecryptedEnvelope { PRO_FEATURES pro_features; }; +struct DecryptEnvelopeKey +{ + // Indicate to the envelope decrypting function that it should use the group keys to decrypt the + // envelope (e.g.: for groups v2 envelopes where the envelope is encrypted and the body + // unencrypted). The `group_keys` must be set if this flag is true. The recipient ed25519 + // private key field is ignored if this flag is set. + bool use_group_keys; + + // Keys to use to decrypt the envelope. + const config::groups::Keys* group_keys; + + // The libsodium-style secret key of the sender, 64 bytes. Can also be passed as a 32-byte seed. + // Used to decrypt the encrypted content. This field is used if `use_group_keys` is false in + // which case the group keys are ignored. This is for envelopes where the envelope itself is + // unencrypted and the contents is encrypted for this secret key. + std::span recipient_ed25519_privkey; +}; + struct EncryptedForDestination { // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to @@ -201,9 +223,13 @@ EncryptedForDestination encrypt_for_destination( /// API: session_protocol/decrypt_envelope /// -/// Given an unencrypted plaintext representation of an envelope (i.e.: protobuf encoded stream of -/// `Envelope`) parse the envelope and return the envelope content decrypted to plaintext with the -/// passed in key. +/// Given an envelope payload (i.e.: protobuf encoded stream of `Envelope` or encrypted `Envelope` +/// using a Groups v2 key) parse (or decrypt) the envelope and return the envelope content decrypted +/// if necessary. +/// +/// A groups v2 envelope will get decrypted with the group keys. A non-groups v2 envelope will get +/// decrypted with the specified Ed25519 private key in the `keys` object. Only one of these keys +/// need to be set depending on the type of envelope payload passed into the function. /// /// If the message does not use Session Pro features, the pro status will be set to nil and all /// other pro fields are to be ignored. If the pro status is non-nil then the pro fields will be @@ -216,13 +242,19 @@ EncryptedForDestination encrypt_for_destination( /// field to verify if the Session Pro was present and/or valid or invalid. /// /// Inputs: -/// - `ed25519_privkey` -- the libsodium-style secret key of the receiver, 64 bytes. Can also be -/// passed as a 32-byte seed. Used to decrypt the encrypted content. -/// - `envelope_plaintext` -- the protobuf serialised payload containing the message envelope. The -/// envelope must already be decrypted if it was originally encrypted (i.e.: closed group -/// envelopes). -/// - `unix_ts` -- pass in the current system time which is used to determine, whether or not the -/// Session Pro proof has expired or not if it is in the payload. Ignored otherwise +/// - `keys` -- the keys to decrypt either the envelope or the envelope contents. Groups v2 +/// envelopes where the envelope is encrypted must set the group key. Envelopes with an encrypted +/// content must set the the libsodium-style secret key of the receiver, 64 bytes. Can also be +/// passed as a 32-byte seed. +/// +/// If a group decryption key is specified, the recipient key is ignored and vice versa. Only one +/// of the keys should be set depending on the type of envelope. +/// +/// - `envelope_payload` -- the envelope payload either encrypted (groups v2 style) or unencrypted +/// (1o1 or legacy groups). +/// - `unix_ts` -- pass in the current system time in seconds which is used to determine, whether or +/// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no +/// proof in the message. /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in /// the proof, validating whether or not the attached proof was indeed issued by an authorised /// issuer @@ -231,8 +263,8 @@ EncryptedForDestination encrypt_for_destination( /// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata /// within the envelope if there were any. DecryptedEnvelope decrypt_envelope( - std::span ed25519_privkey, - std::span envelope_plaintext, + const DecryptEnvelopeKey& keys, + std::span envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey); } // namespace session diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index 35074b0c..7b56cc16 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -500,7 +500,7 @@ PROTOBUF_CONSTEXPR ProMessage::ProMessage( /*decltype(_impl_._has_bits_)*/{} , /*decltype(_impl_._cached_size_)*/{} , /*decltype(_impl_.proof_)*/nullptr - , /*decltype(_impl_.flags_)*/0u} {} + , /*decltype(_impl_.features_)*/uint64_t{0u}} {} struct ProMessageDefaultTypeInternal { PROTOBUF_CONSTEXPR ProMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -11307,7 +11307,7 @@ class ProMessage::_Internal { static void set_has_proof(HasBits* has_bits) { (*has_bits)[0] |= 1u; } - static void set_has_flags(HasBits* has_bits) { + static void set_has_features(HasBits* has_bits) { (*has_bits)[0] |= 2u; } }; @@ -11329,13 +11329,13 @@ ProMessage::ProMessage(const ProMessage& from) decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.proof_){nullptr} - , decltype(_impl_.flags_){}}; + , decltype(_impl_.features_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); if (from._internal_has_proof()) { _this->_impl_.proof_ = new ::SessionProtos::ProProof(*from._impl_.proof_); } - _this->_impl_.flags_ = from._impl_.flags_; + _this->_impl_.features_ = from._impl_.features_; // @@protoc_insertion_point(copy_constructor:SessionProtos.ProMessage) } @@ -11347,7 +11347,7 @@ inline void ProMessage::SharedCtor( decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.proof_){nullptr} - , decltype(_impl_.flags_){0u} + , decltype(_impl_.features_){uint64_t{0u}} }; } @@ -11380,7 +11380,7 @@ void ProMessage::Clear() { GOOGLE_DCHECK(_impl_.proof_ != nullptr); _impl_.proof_->Clear(); } - _impl_.flags_ = 0u; + _impl_.features_ = uint64_t{0u}; _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -11400,11 +11400,11 @@ const char* ProMessage::_InternalParse(const char* ptr, ::_pbi::ParseContext* ct } else goto handle_unusual; continue; - // optional uint32 flags = 2; + // optional uint64 features = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - _Internal::set_has_flags(&has_bits); - _impl_.flags_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _Internal::set_has_features(&has_bits); + _impl_.features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -11447,10 +11447,10 @@ uint8_t* ProMessage::_InternalSerialize( _Internal::proof(this).GetCachedSize(), target, stream); } - // optional uint32 flags = 2; + // optional uint64 features = 2; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_flags(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_features(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -11478,9 +11478,9 @@ size_t ProMessage::ByteSizeLong() const { *_impl_.proof_); } - // optional uint32 flags = 2; + // optional uint64 features = 2; if (cached_has_bits & 0x00000002u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_features()); } } @@ -11512,7 +11512,7 @@ void ProMessage::MergeFrom(const ProMessage& from) { from._internal_proof()); } if (cached_has_bits & 0x00000002u) { - _this->_impl_.flags_ = from._impl_.flags_; + _this->_impl_.features_ = from._impl_.features_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } @@ -11535,8 +11535,8 @@ void ProMessage::InternalSwap(ProMessage* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ProMessage, _impl_.flags_) - + sizeof(ProMessage::_impl_.flags_) + PROTOBUF_FIELD_OFFSET(ProMessage, _impl_.features_) + + sizeof(ProMessage::_impl_.features_) - PROTOBUF_FIELD_OFFSET(ProMessage, _impl_.proof_)>( reinterpret_cast(&_impl_.proof_), reinterpret_cast(&other->_impl_.proof_)); diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index 7b37ecf0..43259bae 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -6634,7 +6634,7 @@ class ProMessage final : enum : int { kProofFieldNumber = 1, - kFlagsFieldNumber = 2, + kFeaturesFieldNumber = 2, }; // optional .SessionProtos.ProProof proof = 1; bool has_proof() const; @@ -6654,17 +6654,17 @@ class ProMessage final : ::SessionProtos::ProProof* proof); ::SessionProtos::ProProof* unsafe_arena_release_proof(); - // optional uint32 flags = 2; - bool has_flags() const; + // optional uint64 features = 2; + bool has_features() const; private: - bool _internal_has_flags() const; + bool _internal_has_features() const; public: - void clear_flags(); - uint32_t flags() const; - void set_flags(uint32_t value); + void clear_features(); + uint64_t features() const; + void set_features(uint64_t value); private: - uint32_t _internal_flags() const; - void _internal_set_flags(uint32_t value); + uint64_t _internal_features() const; + void _internal_set_features(uint64_t value); public: // @@protoc_insertion_point(class_scope:SessionProtos.ProMessage) @@ -6678,7 +6678,7 @@ class ProMessage final : ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::SessionProtos::ProProof* proof_; - uint32_t flags_; + uint64_t features_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_SessionProtos_2eproto; @@ -13745,32 +13745,32 @@ inline void ProMessage::set_allocated_proof(::SessionProtos::ProProof* proof) { // @@protoc_insertion_point(field_set_allocated:SessionProtos.ProMessage.proof) } -// optional uint32 flags = 2; -inline bool ProMessage::_internal_has_flags() const { +// optional uint64 features = 2; +inline bool ProMessage::_internal_has_features() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool ProMessage::has_flags() const { - return _internal_has_flags(); +inline bool ProMessage::has_features() const { + return _internal_has_features(); } -inline void ProMessage::clear_flags() { - _impl_.flags_ = 0u; +inline void ProMessage::clear_features() { + _impl_.features_ = uint64_t{0u}; _impl_._has_bits_[0] &= ~0x00000002u; } -inline uint32_t ProMessage::_internal_flags() const { - return _impl_.flags_; +inline uint64_t ProMessage::_internal_features() const { + return _impl_.features_; } -inline uint32_t ProMessage::flags() const { - // @@protoc_insertion_point(field_get:SessionProtos.ProMessage.flags) - return _internal_flags(); +inline uint64_t ProMessage::features() const { + // @@protoc_insertion_point(field_get:SessionProtos.ProMessage.features) + return _internal_features(); } -inline void ProMessage::_internal_set_flags(uint32_t value) { +inline void ProMessage::_internal_set_features(uint64_t value) { _impl_._has_bits_[0] |= 0x00000002u; - _impl_.flags_ = value; + _impl_.features_ = value; } -inline void ProMessage::set_flags(uint32_t value) { - _internal_set_flags(value); - // @@protoc_insertion_point(field_set:SessionProtos.ProMessage.flags) +inline void ProMessage::set_features(uint64_t value) { + _internal_set_features(value); + // @@protoc_insertion_point(field_set:SessionProtos.ProMessage.features) } #ifdef __GNUC__ diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 309dbca1..58083a39 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -338,6 +338,6 @@ message ProProof { } message ProMessage { - optional ProProof proof = 1; - optional uint32 flags = 2; + optional ProProof proof = 1; + optional uint64 features = 2; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 0167a972..06967c6b 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -313,12 +313,43 @@ struct DecryptedEnvelopeInternal { }; DecryptedEnvelope decrypt_envelope( - std::span ed25519_privkey, - std::span envelope_plaintext, + const DecryptEnvelopeKey& keys, + std::span envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey) { DecryptedEnvelope result = {}; SessionProtos::Envelope envelope = {}; + std::span envelope_plaintext = envelope_payload; + + // The caller is indicating that the envelope_payload is encrypted, if the group keys are + // provided. We will decrypt the payload to get the plaintext. In all other cases, the envelope + // is assumed to be unencrypted and can be used verbatim. + std::vector envelope_plaintext_from_group_keys; + if (keys.use_group_keys) { + if (!keys.group_keys) + throw std::runtime_error( + "API misuse: Envelope decryption with group keys was requested but no key was " + "set"); + + // Decrypt + std::string sender_x25519_pubkey; + std::tie(sender_x25519_pubkey, envelope_plaintext_from_group_keys) = + keys.group_keys->decrypt_message(envelope_plaintext); + if (sender_x25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) + throw std::runtime_error{fmt::format( + "Parse encrypted envelope failed, extracted x25519 pubkey was wrong size: {}", + sender_x25519_pubkey.size())}; + + // Update the plaintext to use the decrypted envelope + envelope_plaintext = envelope_plaintext_from_group_keys; // Update the plaintext + + // Copy keys out + std::memcpy( + result.sender_x25519_pubkey.data(), + sender_x25519_pubkey.data(), + sender_x25519_pubkey.size()); + } + if (!envelope.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) throw std::runtime_error{"Parse envelope from plaintext failed"}; @@ -369,51 +400,11 @@ DecryptedEnvelope decrypt_envelope( // Decrypt content // The envelope is encrypted in GroupsV2, contents unencrypted. In 1o1 and legacy groups, the // envelope is encrypted, contents is encrypted. - // - // On Android and Desktop, the envelope source is always set for legacy and v2 groups. This - // means we can use the envelope source to determine if the contents needs decryption. - // - // On iOS legacy groups have the source set. V2 groups on iOS do _not_ have the sender set. - // Reminder: - // - // v2 => envelope encrypted, contents unencrypted - // legacy => envelope unencrypted, contents encrypted - // - // Since all platforms always set the envelope source for a legacy groups message we can use the - // presence of the envelope source and check the prefix to determine if the contents is - // encrypted, i.e. do the following checks: - // - // 1. Is a closed group message - // 2. The source (pubkey) is set (all platforms set this field on legacy groups messages) - // 3. The pubkey has a legacy prefix (0x05) - // - // Refs: - // clang-format off - // Android: - // Legacy https://github.com/session-foundation/session-android/blob/e4c16ae8aa8cae2f75aba565b890082563b07bd2/app/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt#L189 - // v2 https://github.com/session-foundation/session-android/blob/e4c16ae8aa8cae2f75aba565b890082563b07bd2/app/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt#L176 - // Desktop: - // Legacy https://github.com/session-foundation/session-desktop/blob/4c5cd88fa707a01845f86c0de8920faf160653ea/ts/session/sending/MessageWrapper.ts#L140 - // v2 https://github.com/session-foundation/session-desktop/blob/4c5cd88fa707a01845f86c0de8920faf160653ea/ts/session/sending/MessageWrapper.ts#L49 - // iOS: - // Legacy https://github.com/session-foundation/session-ios/blob/932145ab255b2327ca20fc992ac73758b94b07cd/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L469 - // v2 https://github.com/session-foundation/session-ios/blob/932145ab255b2327ca20fc992ac73758b94b07cd/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L426 - // clang-format on - bool has_encrypted_content = envelope.type() == SessionProtos::Envelope_Type_SESSION_MESSAGE; - if (envelope.type() == SessionProtos::Envelope_Type_CLOSED_GROUP_MESSAGE && envelope.has_source()) { - const std::string& source_pubkey = envelope.source(); - if (source_pubkey.size() != sizeof(array_uc33)) - throw std::runtime_error{ - "Parse closed group message failed, source was not 33 byte public key"}; - - if (source_pubkey[0] != static_cast(SessionIDPrefix::group)) - has_encrypted_content = true; - } - + bool has_encrypted_content = !keys.use_group_keys; if (has_encrypted_content) { std::span content_str = session::to_span(envelope.content()); auto [content_plaintext, sender_ed25519_pubkey] = - session::decrypt_incoming(ed25519_privkey, content_str); + session::decrypt_incoming(keys.recipient_ed25519_privkey, content_str); assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); result.content_plaintext = std::move(content_plaintext); @@ -421,6 +412,12 @@ DecryptedEnvelope decrypt_envelope( result.sender_ed25519_pubkey.data(), sender_ed25519_pubkey.data(), result.sender_ed25519_pubkey.size()); + + if (crypto_sign_ed25519_pk_to_curve25519( + result.sender_x25519_pubkey.data(), result.sender_ed25519_pubkey.data()) != 0) + throw std::runtime_error( + "Parse content failed, ed25519 public key could not be converted to x25519 " + "key."); } else { result.content_plaintext.resize(envelope.content().size()); std::memcpy(result.content_plaintext.data(), envelope.content().data(), envelope.content().size()); @@ -442,11 +439,11 @@ DecryptedEnvelope decrypt_envelope( if (!envelope.has_prosig()) throw std::runtime_error("Parse envelope failed, pro message is missing signature"); + // Copy (maybe dummy) pro signature into our result struct const std::string& pro_sig = envelope.prosig(); if (pro_sig.size() != crypto_sign_ed25519_BYTES) throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); - std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); if (content.has_promessage()) { @@ -454,21 +451,19 @@ DecryptedEnvelope decrypt_envelope( result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; // Extract the pro message - SessionProtos::ProMessage pro_msg = content.promessage(); + const SessionProtos::ProMessage& pro_msg = content.promessage(); if (!pro_msg.has_proof()) throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); - if (!pro_msg.has_flags()) - throw std::runtime_error("Parse decrypted message failed, pro config missing flags"); - - const SessionProtos::ProProof& proto_proof = pro_msg.proof(); - std::uint32_t proto_flags = pro_msg.flags(); + if (!pro_msg.has_features()) + throw std::runtime_error("Parse decrypted message failed, pro config missing features"); // Parse the proof from protobufs + const SessionProtos::ProProof& proto_proof = pro_msg.proof(); session::config::ProProof& proof = result.pro_proof; // clang-format off size_t proof_errors = 0; - proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); - proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); proof_errors += !proto_proof.has_expiryunixts(); proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); @@ -485,7 +480,7 @@ DecryptedEnvelope decrypt_envelope( result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; // Fill out the resulting proof structure, we have parsed successfully - result.pro_features = proto_flags; + result.pro_features = pro_msg.features(); std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); std::memcpy( @@ -562,14 +557,21 @@ session_protocol_encrypt_for_destination( LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const span_u8 ed25519_privkey, + const session_protocol_decrypt_envelope_keys* keys, const span_u8 envelope_plaintext, uint64_t unix_ts, const span_u8 pro_backend_pubkey) { session_protocol_decrypted_envelope result = {}; try { + + DecryptEnvelopeKey keys_cpp = { + .use_group_keys = keys->use_group_keys, + .group_keys = + reinterpret_cast(keys->group_keys->internals), + .recipient_ed25519_privkey = keys->recipient_ed25519_privkey}; + DecryptedEnvelope result_cpp = decrypt_envelope( - ed25519_privkey.cpp_span(), + keys_cpp, envelope_plaintext.cpp_span(), std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), {}); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 86820102..cd13c8c7 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -1,24 +1,114 @@ #include #include -#include -#include -#include +#include #include #include -#include "SessionProtos.pb.h" +#include +#include +#include +#include +#include +#include +#include "WebSocketResources.pb.h" +#include "SessionProtos.pb.h" #include "utils.hpp" using namespace session; +struct SerialisedProtobufContentWithProForTesting { + config::ProProof proof; + std::string plaintext; + array_uc64 sig_over_plaintext_with_user_pro_key; + array_uc32 pro_proof_hash; +}; + +static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_session_pro( + std::string_view data_body, + const array_uc64& user_rotating_privkey, + const array_uc64& pro_backend_privkey, + std::chrono::sys_seconds pro_expiry_unix_ts, + PRO_FEATURES features) { + SerialisedProtobufContentWithProForTesting result = {}; + + // Create protobuf `Content.dataMessage` + SessionProtos::Content content = {}; + SessionProtos::DataMessage* data = content.mutable_datamessage(); + data->set_body(std::string(data_body)); + + // Generate a dummy proof + crypto_sign_ed25519_sk_to_pk(result.proof.rotating_pubkey.data(), user_rotating_privkey.data()); + result.proof.expiry_unix_ts = pro_expiry_unix_ts; + + // Sign the proof by the dummy "Session Pro Backend" key + result.pro_proof_hash = result.proof.hash(); + crypto_sign_ed25519_detached( + result.proof.sig.data(), + nullptr, + result.pro_proof_hash.data(), + result.pro_proof_hash.size(), + pro_backend_privkey.data()); + + // Create protobuf `Content.proMessage` + SessionProtos::ProMessage* pro = content.mutable_promessage(); + pro->set_features(features); + + // Create protobuf `Content.proMessage.proof` + SessionProtos::ProProof* proto_proof = pro->mutable_proof(); + proto_proof->set_version(result.proof.version); + proto_proof->set_genindexhash( + result.proof.gen_index_hash.data(), result.proof.gen_index_hash.size()); + proto_proof->set_rotatingpublickey( + result.proof.rotating_pubkey.data(), result.proof.rotating_pubkey.size()); + proto_proof->set_expiryunixts(result.proof.expiry_unix_ts.time_since_epoch().count()); + proto_proof->set_sig(result.proof.sig.data(), result.proof.sig.size()); + + // Generate the plaintext + result.plaintext = content.SerializeAsString(); + REQUIRE(result.plaintext.size() > data_body.size()); + + // Sign the plaintext with the user's pro key + crypto_sign_ed25519_detached( + result.sig_over_plaintext_with_user_pro_key.data(), + nullptr, + reinterpret_cast(result.plaintext.data()), + result.plaintext.size(), + user_rotating_privkey.data()); + + return result; +} + TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { + // Do tests that require no setup + SECTION("Ensure get pro fetaures detects large message") { + // Try a message below the size threshold + PRO_FEATURES features = get_pro_features_for_msg( + PRO_STANDARD_CHARACTER_LIMIT, + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); + + // Try a message exceeding the size threshold + features = get_pro_features_for_msg( + PRO_STANDARD_CHARACTER_LIMIT + 1, + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | + PRO_FEATURES_ANIMATED_AVATAR)); + + // Try asking for just one extra feature + features = get_pro_features_for_msg(100, PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(features == PRO_FEATURES_PRO_BADGE); + } + + // Tests that require some setup code using namespace session; TestKeys keys = get_deterministic_test_keys(); // Tuesday, 12 August 2025 03:58:21 UTC const std::chrono::milliseconds timestamp_ms = std::chrono::seconds(1754971101); + const std::chrono::sys_seconds timestamp_s = std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)); const std::string_view data_body = "hello"; SECTION("Encrypt with and w/o pro sig produce same payload size") { @@ -44,11 +134,18 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(encrypt_with_pro_sig.encrypted); // Should have the same payload size - REQUIRE(encrypt_without_pro_sig.ciphertext.size() == encrypt_with_pro_sig.ciphertext.size()); + REQUIRE(encrypt_without_pro_sig.ciphertext.size() == + encrypt_with_pro_sig.ciphertext.size()); } - SECTION("Encrypt/decrypt for contact in default namespace") { - // Build content + // Setup a dummy "Session Pro Backend" key + // We reuse test key 1 as the "Session Pro" backend key that signs the proofs as it + // doesn't matter what key really, just that we have one available for signing. + const array_uc64& pro_backend_ed_sk = keys.ed_sk1; + const array_uc32& pro_backend_ed_pk = keys.ed_pk1; + + SECTION("Encrypt/decrypt for contact in default namespace w/o pro attached") { + // Build content without pro attached std::string plaintext; { SessionProtos::Content content = {}; @@ -65,7 +162,8 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { dest.type = DestinationType::Contact; dest.sent_timestamp_ms = timestamp_ms; REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + std::memcpy( + dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); encrypt_result = session::encrypt_for_destination( to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); @@ -73,15 +171,15 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { } // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = false; + decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; DecryptedEnvelope decrypt_result = session::decrypt_envelope( - keys.ed_sk1, - encrypt_result.ciphertext, - std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)), pro_backend::PUBKEY); + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); // Verify pro config::ProProof nil_proof = {}; - REQUIRE(decrypt_result.pro_status == ProStatus::Nil); // Pro was not attached + REQUIRE(decrypt_result.pro_status == ProStatus::Nil); // Pro was not attached REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); REQUIRE(decrypt_result.pro_proof.hash() == nil_proof.hash()); @@ -94,31 +192,6 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(data.body() == data_body); } - SECTION("Ensure get pro fetaures detects large message") { - // Try a message below the size threshold - PRO_FEATURES features = get_pro_features_for_msg( - PRO_STANDARD_CHARACTER_LIMIT, - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); - - // Try a message exceeding the size threshold - features = get_pro_features_for_msg( - PRO_STANDARD_CHARACTER_LIMIT + 1, - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | - PRO_FEATURES_ANIMATED_AVATAR)); - - // Try asking for just one extra feature - features = get_pro_features_for_msg(100, PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(features == PRO_FEATURES_PRO_BADGE); - } - - // Prepare a Session Pro proof - // We reuse test key 1 as the "Session Pro" backend key that signs the proofs as it - // doesn't matter what key really, just that we have one for signing. - const array_uc64& pro_backend_ed_sk = keys.ed_sk1; - const array_uc32& pro_backend_ed_pk = keys.ed_pk1; - // Generate the user's Session Pro rotating key for testing encrypted payloads with Session // Pro metadata const auto user_pro_seed = @@ -130,137 +203,89 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { // Build protobuf `Content` message, serialise to `plaintext` and get it signed by the user's // "Session Pro" key into `sig_over_plaintext_with_user_pro_key` - std::string plaintext; - array_uc64 sig_over_plaintext_with_user_pro_key = {}; - array_uc32 pro_proof_hash = {}; - { - SessionProtos::Content content = {}; - - // Create protobuf `Content.dataMessage` - SessionProtos::DataMessage* data = content.mutable_datamessage(); - data->set_body(std::string(data_body)); - - // Generate a dummy proof - config::ProProof proof = {}; - proof.rotating_pubkey = user_pro_ed_pk; - proof.expiry_unix_ts = std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)); - - // Sign the proof by the dummy "Session Pro Backend" key - pro_proof_hash = proof.hash(); - crypto_sign_ed25519_detached( - proof.sig.data(), - nullptr, - pro_proof_hash.data(), - pro_proof_hash.size(), - pro_backend_ed_sk.data()); - - // Create protobuf `Content.proMessage` - SessionProtos::ProMessage *pro = content.mutable_promessage(); - pro->set_flags(PRO_FEATURES_NIL); - - // Create protobuf `Content.proMessage.proof` - SessionProtos::ProProof *proto_proof = pro->mutable_proof(); - proto_proof->set_version(proof.version); - proto_proof->set_genindexhash(proof.gen_index_hash.data(), proof.gen_index_hash.size()); - proto_proof->set_rotatingpublickey(proof.rotating_pubkey.data(), proof.rotating_pubkey.size()); - proto_proof->set_expiryunixts(proof.expiry_unix_ts.time_since_epoch().count()); - proto_proof->set_sig(proof.sig.data(), proof.sig.size()); - - // Generate the plaintext - plaintext = content.SerializeAsString(); - REQUIRE(plaintext.size() > data_body.size()); - - // Sign the plaintext with the user's pro key - crypto_sign_ed25519_detached( - sig_over_plaintext_with_user_pro_key.data(), - nullptr, - reinterpret_cast(plaintext.data()), - plaintext.size(), - user_pro_ed_sk.data()); - } + SerialisedProtobufContentWithProForTesting protobuf_content_with_pro = + build_protobuf_content_with_session_pro( + /*data_body*/ data_body, + /*user_rotating_privkey*/ user_pro_ed_sk, + /*pro_backend_privkey*/ pro_backend_ed_sk, + /*pro_expiry_unix_ts*/ timestamp_s, + PRO_FEATURES_NIL); + + // Setup base destination object with the pro signature w/ Session pubkey 1 as the recipient + session::Destination base_dest = {}; + base_dest.sent_timestamp_ms = timestamp_ms; + base_dest.pro_sig = protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key; + REQUIRE(base_dest.recipient_pubkey.size() == keys.session_pk1.size()); + std::memcpy( + base_dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + + SECTION("Check non-encryptable messages produce only plaintext") { + auto dest_list = { + DestinationType::OpenGroup, + DestinationType::OpenGroupInbox, + DestinationType::Contact}; - SECTION("Encrypt/decrypt for contact in default namespace with Pro") { - // Build content - std::string plaintext; - array_uc64 sig_over_plaintext_with_user_pro_key = {}; - array_uc32 pro_proof_hash = {}; - { - SessionProtos::Content content = {}; + for (auto dest_type : dest_list) { + if (dest_type == DestinationType::OpenGroup) + INFO("Trying open groups"); + else if (dest_type == DestinationType::OpenGroupInbox) + INFO("Trying open group inbox"); + else + INFO("Trying contacts to non-default namespace"); - // Create protobuf `Content.dataMessage` - SessionProtos::DataMessage* data = content.mutable_datamessage(); - data->set_body(std::string(data_body)); + session::Destination dest = base_dest; + dest.type = dest_type; - // Generate a dummy proof - config::ProProof proof = {}; - proof.rotating_pubkey = user_pro_ed_pk; - proof.expiry_unix_ts = std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)); - - // Sign the proof by the dummy "Session Pro Backend" key - pro_proof_hash = proof.hash(); - crypto_sign_ed25519_detached( - proof.sig.data(), - nullptr, - pro_proof_hash.data(), - pro_proof_hash.size(), - pro_backend_ed_sk.data()); - - // Create protobuf `Content.proMessage` - SessionProtos::ProMessage *pro = content.mutable_promessage(); - pro->set_flags(PRO_FEATURES_NIL); - - // Create protobuf `Content.proMessage.proof` - SessionProtos::ProProof *proto_proof = pro->mutable_proof(); - proto_proof->set_version(proof.version); - proto_proof->set_genindexhash(proof.gen_index_hash.data(), proof.gen_index_hash.size()); - proto_proof->set_rotatingpublickey(proof.rotating_pubkey.data(), proof.rotating_pubkey.size()); - proto_proof->set_expiryunixts(proof.expiry_unix_ts.time_since_epoch().count()); - proto_proof->set_sig(proof.sig.data(), proof.sig.size()); - - // Generate the plaintext - plaintext = content.SerializeAsString(); - REQUIRE(plaintext.size() > data_body.size()); + config::Namespace space = config::Namespace::Default; + if (dest_type == DestinationType::Contact) { + space = config::Namespace::Contacts; + } else if (dest_type == DestinationType::OpenGroupInbox) { + auto [blind15_pk, blind15_sk] = session::blind15_key_pair( + keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); + dest.recipient_pubkey[0] = 0x15; + std::memcpy(dest.recipient_pubkey.data() + 1, blind15_pk.data(), blind15_pk.size()); + } + + EncryptedForDestination encrypt_result = session::encrypt_for_destination( + to_span(protobuf_content_with_pro.plaintext), keys.ed_sk0, dest, space); - // Sign the plaintext with the user's pro key - crypto_sign_ed25519_detached( - sig_over_plaintext_with_user_pro_key.data(), - nullptr, - reinterpret_cast(plaintext.data()), - plaintext.size(), - user_pro_ed_sk.data()); + if (dest_type == DestinationType::OpenGroupInbox) { + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.ciphertext.size()); + } else { + REQUIRE_FALSE(encrypt_result.encrypted); + REQUIRE(encrypt_result.ciphertext.empty()); + } } + } - // Encrypt + SECTION("Encrypt/decrypt for contact in default namespace with Pro") { + // Encrypt content EncryptedForDestination encrypt_result = {}; { - session::Destination dest = {}; + session::Destination dest = base_dest; dest.type = DestinationType::Contact; - dest.sent_timestamp_ms = timestamp_ms; - dest.pro_sig = sig_over_plaintext_with_user_pro_key; - REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); - encrypt_result = session::encrypt_for_destination( - to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + to_span(protobuf_content_with_pro.plaintext), + keys.ed_sk0, + dest, + config::Namespace::Default); REQUIRE(encrypt_result.encrypted); } // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = false; + decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; DecryptedEnvelope decrypt_result = session::decrypt_envelope( - keys.ed_sk1, - encrypt_result.ciphertext, - std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)), - pro_backend_ed_pk); + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == pro_proof_hash); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == protobuf_content_with_pro.pro_proof_hash); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - // Verify it is decryptable + // Verify the content can be parsed w/ protobufs SessionProtos::Content decrypt_content = {}; REQUIRE(decrypt_content.ParseFromArray( decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); @@ -269,74 +294,96 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(data.body() == data_body); } - SECTION("Check non-encryptable messages produce plaintext") { - auto dest_list = { - DestinationType::OpenGroup, - DestinationType::OpenGroupInbox, - DestinationType::Contact}; + SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { - for (auto dest_type : dest_list) { - if (dest_type == DestinationType::OpenGroup) - INFO("Trying open groups"); - else if (dest_type == DestinationType::OpenGroupInbox) - INFO("Trying open group inbox"); - else - INFO("Trying contacts to non-default namespace"); + std::string large_message; + large_message.resize(PRO_STANDARD_CHARACTER_LIMIT + 1); - session::Destination dest = {}; - dest.type = dest_type; - dest.sent_timestamp_ms = timestamp_ms; - dest.pro_sig = sig_over_plaintext_with_user_pro_key; - REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy( - dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + PRO_FEATURES features = + get_pro_features_for_msg(large_message.size(), PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); - config::Namespace space = config::Namespace::Default; - if (dest_type == DestinationType::Contact) { - space = config::Namespace::Contacts; - dest.recipient_pubkey[0] = 0x15; - } + SerialisedProtobufContentWithProForTesting protobuf_content_with_pro_and_features = + build_protobuf_content_with_session_pro( + /*data_body*/ large_message, + /*user_rotating_privkey*/ user_pro_ed_sk, + /*pro_backend_privkey*/ pro_backend_ed_sk, + /*pro_expiry_unix_ts*/ timestamp_s, + features); - EncryptedForDestination encrypt_result = - session::encrypt_for_destination(to_span(plaintext), keys.ed_sk0, dest, space); - REQUIRE_FALSE(encrypt_result.encrypted); - REQUIRE(encrypt_result.ciphertext.empty()); + // Encrypt content + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = base_dest; + dest.type = DestinationType::Contact; + dest.pro_sig = + protobuf_content_with_pro_and_features.sig_over_plaintext_with_user_pro_key; + encrypt_result = session::encrypt_for_destination( + to_span(protobuf_content_with_pro_and_features.plaintext), + keys.ed_sk0, + dest, + config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); } - } + // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = false; + decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + DecryptedEnvelope decrypt_result = session::decrypt_envelope( + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); - SECTION("Encrypt/decrypt for legacy closed group (w/ encrypted envelope, plaintext content) " - "with Pro") { + // Verify pro + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == + protobuf_content_with_pro_and_features.pro_proof_hash); + REQUIRE(decrypt_result.pro_features == + (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); + // Verify the content can be parsed w/ protobufs + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == large_message); + } + + SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with Pro") { // Encrypt EncryptedForDestination encrypt_result = {}; { - session::Destination dest = {}; + Destination dest = base_dest; dest.type = DestinationType::ClosedGroup; - dest.sent_timestamp_ms = timestamp_ms; - dest.pro_sig = sig_over_plaintext_with_user_pro_key; - REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + assert(dest.recipient_pubkey[0] == 0x05); encrypt_result = session::encrypt_for_destination( - to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + to_span(protobuf_content_with_pro.plaintext), + keys.ed_sk0, + dest, + config::Namespace::Default); REQUIRE(encrypt_result.encrypted); } + // Legacy groups wrap in websocket message + WebSocketProtos::WebSocketMessage ws_msg; + REQUIRE(ws_msg.ParseFromArray(encrypt_result.ciphertext.data(), encrypt_result.ciphertext.size())); + REQUIRE(ws_msg.has_request()); + REQUIRE(ws_msg.request().has_body()); + // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = false; + decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; DecryptedEnvelope decrypt_result = session::decrypt_envelope( - keys.ed_sk1, - encrypt_result.ciphertext, - std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)), - pro_backend_ed_pk); + decrypt_keys, to_span(ws_msg.request().body()), timestamp_s, pro_backend_ed_pk); // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == pro_proof_hash); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == protobuf_content_with_pro.pro_proof_hash); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - // Verify it is decryptable + // Verify the content can be parsed w/ protobufs SessionProtos::Content decrypt_content = {}; REQUIRE(decrypt_content.ParseFromArray( decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); @@ -345,42 +392,138 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(data.body() == data_body); } - SECTION("Encrypt/decrypt for sync messages with Pro") { + SECTION("Encrypt/decrypt for groups v2 (w/ encrypted envelope, plaintext content) with Pro") { + // TODO: Finish setting up a fake group + const auto group_v2_seed = + "0123456789abcdef0123456789abcdeff00baadeadb33f000000000000000000"_hexbytes; + array_uc64 group_v2_sk = {}; + array_uc32 group_v2_pk = {}; + crypto_sign_ed25519_seed_keypair( + group_v2_pk.data(), group_v2_sk.data(), group_v2_seed.data()); + + auto group_v2_info = config::groups::Info(group_v2_pk, group_v2_sk, std::nullopt); + auto group_v2_members = config::groups::Members(group_v2_pk, group_v2_sk, std::nullopt); + auto group_v2_keys = config::groups::Keys( + keys.ed_sk0, + group_v2_pk, + group_v2_sk, + std::nullopt, + group_v2_info, + group_v2_members); // Encrypt +#if 0 EncryptedForDestination encrypt_result = {}; { - session::Destination dest = {}; - dest.type = DestinationType::SyncMessage; - dest.sent_timestamp_ms = timestamp_ms; - dest.pro_sig = sig_over_plaintext_with_user_pro_key; - REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy(dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); + Destination dest = base_dest; + dest.type = DestinationType::ClosedGroup; + dest.closed_group_pubkey[0] = 0x03; + std::memcpy(dest.closed_group_pubkey.data() + 1, group_v2_pk.data(), group_v2_pk.size()); + dest.closed_group_keys = &group_v2_keys; encrypt_result = session::encrypt_for_destination( - to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); + to_span(protobuf_content_with_pro.plaintext), + keys.ed_sk0, + dest, + config::Namespace::GroupMessages); REQUIRE(encrypt_result.encrypted); } // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = true; + decrypt_keys.group_keys = &group_v2_keys; + + // TODO: Finish setting up a group so we can check the decrypted result for now this will + // throw because the keys aren't setup correctly. + CHECK_THROWS(session::decrypt_envelope( + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk)); +#endif + } + + SECTION("Encrypt/decrypt for sync messages with Pro") { + // Encrypt + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = base_dest; + dest.type = DestinationType::SyncMessage; + encrypt_result = session::encrypt_for_destination( + to_span(protobuf_content_with_pro.plaintext), + keys.ed_sk0, + dest, + config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); + } + + // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = false; + decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; DecryptedEnvelope decrypt_result = session::decrypt_envelope( - keys.ed_sk1, - encrypt_result.ciphertext, - std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)), - pro_backend_ed_pk); + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == pro_proof_hash); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached + REQUIRE(decrypt_result.pro_proof.hash() == protobuf_content_with_pro.pro_proof_hash); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - // Verify it is decryptable + // Verify the content can be parsed w/ protobufs SessionProtos::Content decrypt_content = {}; REQUIRE(decrypt_content.ParseFromArray( decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); + + // Try decrypt with a timestamp past the pro proof expiry date + DecryptedEnvelope decrypt_result_again = session::decrypt_envelope( + decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts + std::chrono::seconds(1), + pro_backend_ed_pk); + REQUIRE(decrypt_result_again.pro_status == ProStatus::Expired); + + // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) + DecryptEnvelopeKey bad_decrypt_keys = {}; + bad_decrypt_keys.use_group_keys = false; + bad_decrypt_keys.recipient_ed25519_privkey = keys.ed_sk0; + CHECK_THROWS( + session::decrypt_envelope( + bad_decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts, + pro_backend_ed_pk)); + + // Try decrypt with a bad backend key + array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; + bad_pro_backend_ed_pk[0] ^= 1; + decrypt_result_again = session::decrypt_envelope( + decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts, + bad_pro_backend_ed_pk); + REQUIRE(decrypt_result_again.pro_status == ProStatus::InvalidProBackendSig); + } + + SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { + EncryptedForDestination encrypt_result = {}; + { + session::Destination dest = base_dest; + dest.type = DestinationType::SyncMessage; + (*dest.pro_sig)[0] ^= 1; // Break the sig by flipping a bit + encrypt_result = session::encrypt_for_destination( + to_span(protobuf_content_with_pro.plaintext), + keys.ed_sk0, + dest, + config::Namespace::Default); + REQUIRE(encrypt_result.encrypted); + } + + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = false; + decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + DecryptedEnvelope decrypt_result = session::decrypt_envelope( + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); + REQUIRE(decrypt_result.pro_status == ProStatus::InvalidUserSig); } } From 7571f30107d1dd241c762a7602af0e665d258a9c Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 16:19:25 +1000 Subject: [PATCH 025/171] Do not enforce library types in C interface Design of the interface should be accomodating not opionated. This also fixes a bug where the pro backend key wasn't been initialised yet in the C interface --- include/session/session_protocol.h | 10 +++++++--- src/session_protocol.cpp | 30 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index fba14177..08873c22 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -173,8 +173,10 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEAT /// an exception then this is caught internally and success is set to false. LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( - const span_u8 plaintext, + const void *plaintext, + size_t plaintext_len, const span_u8 ed25519_privkey, + size_t ed25519_privkey_len, const session_protocol_destination* dest, NAMESPACE space); @@ -217,9 +219,11 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const session_protocol_decrypt_envelope_keys* keys, - const span_u8 envelope_payload, + const void* envelope_plaintext, + size_t envelope_plaintext_len, uint64_t unix_ts, - const span_u8 pro_backend_pubkey); + const void* pro_backend_pubkey, + size_t pro_backend_pubkey_len); #ifdef __cplusplus } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 06967c6b..425adb4f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -524,15 +524,18 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEAT LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( - const span_u8 plaintext, - const span_u8 ed25519_privkey, + const void *plaintext, + size_t plaintext_len, + const void *ed25519_privkey, + size_t ed25519_privkey_len, const session_protocol_destination* dest, NAMESPACE space) { session_protocol_encrypted_for_destination result = {}; try { EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( - /*plaintext=*/{plaintext.data, plaintext.size}, - /*ed25519_privkey=*/{ed25519_privkey.data, ed25519_privkey.size}, + /*plaintext=*/{static_cast(plaintext), plaintext_len}, + /*ed25519_privkey=*/ + {static_cast(ed25519_privkey), ed25519_privkey_len}, /*dest_type=*/static_cast(dest->type), /*dest_pro_sig=*/dest->has_pro_sig ? dest->pro_sig : std::span(), /*dest_recipient_pubkey=*/dest->recipient_pubkey, @@ -558,12 +561,21 @@ session_protocol_encrypt_for_destination( LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const session_protocol_decrypt_envelope_keys* keys, - const span_u8 envelope_plaintext, + const void* envelope_plaintext, + size_t envelope_plaintext_len, uint64_t unix_ts, - const span_u8 pro_backend_pubkey) { + const void* pro_backend_pubkey, + size_t pro_backend_pubkey_len) { session_protocol_decrypted_envelope result = {}; - try { + // Setup the pro backend pubkey + array_uc32 pro_backend_pubkey_cpp = {}; + if (pro_backend_pubkey_len != sizeof(pro_backend_pubkey_cpp)) + return result; + std::memcpy(pro_backend_pubkey_cpp.data(), pro_backend_pubkey, pro_backend_pubkey_len); + + try { + // Setup decryption keys and decrypt DecryptEnvelopeKey keys_cpp = { .use_group_keys = keys->use_group_keys, .group_keys = @@ -572,9 +584,9 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( DecryptedEnvelope result_cpp = decrypt_envelope( keys_cpp, - envelope_plaintext.cpp_span(), + {static_cast(envelope_plaintext), envelope_plaintext_len}, std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), - {}); + pro_backend_pubkey_cpp); // Marshall into c type result = { From ed2bd5a314875031a499bd2c1f374c962cd1ffd3 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 16:24:42 +1000 Subject: [PATCH 026/171] Pro version field should use a key that sorts to the top Due to BT encoding using sort order to order keys. Version at top means we can conditionally handle version changes easily. --- include/session/config/pro.hpp | 2 +- src/config/pro.cpp | 2 +- src/config/user_profile.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 678b1e09..a2b35f31 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -13,7 +13,7 @@ enum ProProofVersion { ProProofVersion_v0 }; /// keys used currently or in the past (so that we don't reuse): /// -/// v - version +/// @ - version /// g - gen_index_hash /// r - rotating ed25519 pubkey /// e - expiry unix timestamp (in seconds) diff --git a/src/config/pro.cpp b/src/config/pro.cpp index a997fdd5..ec2ef9f1 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -89,7 +89,7 @@ array_uc32 ProProof::hash() const { } bool ProProof::load(const dict& root) { - std::optional version = maybe_int(root, "v"); + std::optional version = maybe_int(root, "@"); std::optional> maybe_gen_index_hash = maybe_vector(root, "g"); std::optional> maybe_rotating_pubkey = maybe_vector(root, "r"); std::optional maybe_expiry_unix_ts = maybe_ts(root, "e"); diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index f2b05bef..8d9446f2 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -165,7 +165,7 @@ void UserProfile::set_pro_config(ProConfig const &pro) { const ProProof& pro_proof = pro.proof; auto proof_dict = root["p"]; - proof_dict["v"] = pro_proof.version; + proof_dict["@"] = pro_proof.version; proof_dict["g"] = pro_proof.gen_index_hash; proof_dict["r"] = pro_proof.rotating_pubkey; proof_dict["e"] = pro_proof.expiry_unix_ts.time_since_epoch().count(); From 33e90b5ef9b39474227d180161bbd897b3f233ca Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 16:47:07 +1000 Subject: [PATCH 027/171] Fix C session protocol using std::span and missing comments --- include/session/session_protocol.h | 31 +++++++++++++--------------- include/session/session_protocol.hpp | 10 ++++----- src/session_protocol.cpp | 4 +++- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 08873c22..93ff0e96 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -21,6 +21,9 @@ enum { PRO_STANDARD_CHARACTER_LIMIT = 2'000, }; +// Bit flags for features that are not currently able to be determined by the state stored in +// Libsession. They are to be passed in by the client into `get_pro_msg_for_features` to return the +// bitset of `PRO_FEATURES` that a message will use. typedef uint64_t PRO_EXTRA_FEATURES; enum PRO_EXTRA_FEATURES_ { PRO_EXTRA_FEATURES_NIL = 0, @@ -28,6 +31,8 @@ enum PRO_EXTRA_FEATURES_ { PRO_EXTRA_FEATURES_ANIMATED_AVATAR = 1 << 1, }; +// Bitset of Session Pro features that a message uses. This bitset is stored in the protobuf +// `Content.proMessage` when a message is sent for other clients to consume. typedef uint64_t PRO_FEATURES; enum PRO_FEATURES_ { PRO_FEATURES_NIL = 0, @@ -38,7 +43,7 @@ enum PRO_FEATURES_ { PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR }; -enum PRO_STATUS { +enum PRO_STATUS { // See session::ProStatus PRO_STATUS_NIL, PRO_STATUS_INVALID_PRO_BACKEND_SIG, PRO_STATUS_INVALID_USER_SIG, @@ -46,7 +51,7 @@ enum PRO_STATUS { PRO_STATUS_EXPIRED, }; -enum DESTINATION_TYPE { +enum DESTINATION_TYPE { // See session::DestinationType DESTINATION_TYPE_CONTACT, DESTINATION_TYPE_SYNC_MESSAGE, DESTINATION_TYPE_CLOSED_GROUP, @@ -54,7 +59,7 @@ enum DESTINATION_TYPE { DESTINATION_TYPE_OPEN_GROUP_INBOX, }; -struct session_protocol_destination { +struct session_protocol_destination { // See session::Destination DESTINATION_TYPE type; // The pro signature is optional, set this flag to true to make the encryption function take @@ -73,6 +78,8 @@ enum ENVELOPE_TYPE { ENVELOPE_TYPE_CLOSED_GROUP_MESSGE, }; +// Indicates which optional fields in the envelope has been populated out of the optional fields in +// an envelope after it has been parsed off the wire. typedef uint32_t ENVELOPE_FLAGS; enum ENVELOPE_FLAGS_ { ENVELOPE_FLAGS_SOURCE = 1 << 0, @@ -92,20 +99,10 @@ struct session_protocol_envelope { }; struct session_protocol_decrypt_envelope_keys { - // Indicate to the envelope decrypting function that it should use the group keys to decrypt the - // envelope (e.g.: for groups v2 envelopes where the envelope is encrypted and the body - // unencrypted). The `group_keys` must be set if this flag is true. The recipient ed25519 - // private key field is ignored if this flag is set. bool use_group_keys; - - // Keys to use to decrypt the envelope. const config_group_keys* group_keys; - - // The libsodium-style secret key of the sender, 64 bytes. Can also be passed as a 32-byte seed. - // Used to decrypt the encrypted content. This field is used if `use_group_keys` is false in - // which case the group keys are ignored. This is for envelopes where the envelope itself is - // unencrypted and the contents is encrypted for this secret key. - std::span recipient_ed25519_privkey; + const void* recipient_ed25519_privkey; + size_t recipient_ed25519_privkey_len; }; struct session_protocol_decrypted_envelope { @@ -173,9 +170,9 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEAT /// an exception then this is caught internally and success is set to false. LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( - const void *plaintext, + const void* plaintext, size_t plaintext_len, - const span_u8 ed25519_privkey, + const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, NAMESPACE space); diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 6b710b18..58b9f7f7 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -48,12 +48,10 @@ enum class ProStatus { enum class DestinationType { Contact, SyncMessage, - /// Both legacy and non-legacy closed groups are to be identified as `ClosedGroup`. A non-legacy /// group is detected by the (0x03) prefix byte on the given `dest_closed_group_pubkey` /// specified in Destination. ClosedGroup, - OpenGroup, OpenGroupInbox, }; @@ -95,14 +93,14 @@ struct Envelope { EnvelopeType type; std::chrono::milliseconds timestamp; - /// Optional fields. These fields are set if the appropriate flag has been set in `flags` - /// otherwise the corresponding values are to be ignored and those fields will be - /// zero-initialised. + // Optional fields. These fields are set if the appropriate flag has been set in `flags` + // otherwise the corresponding values are to be ignored and those fields will be + // zero-initialised. array_uc33 source; uint32_t source_device; uint64_t server_timestamp; - /// Signature by the sending client's rotating key + // Signature by the sending client's rotating key array_uc64 pro_sig; }; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 425adb4f..22f4c188 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -580,7 +580,9 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( .use_group_keys = keys->use_group_keys, .group_keys = reinterpret_cast(keys->group_keys->internals), - .recipient_ed25519_privkey = keys->recipient_ed25519_privkey}; + .recipient_ed25519_privkey = { + static_cast(keys->recipient_ed25519_privkey), + keys->recipient_ed25519_privkey_len}}; DecryptedEnvelope result_cpp = decrypt_envelope( keys_cpp, From 9fd66439f1f5ef3212899c7c89e3ed4364624cc7 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 17:16:20 +1000 Subject: [PATCH 028/171] Fixup some comments, add missing x25519 pubkey from C decrypted envelope --- include/session/session_protocol.h | 12 ++++++----- include/session/session_protocol.hpp | 17 ++++++++------- include/session/types.h | 8 ------- src/session_protocol.cpp | 31 +++++++++++----------------- 4 files changed, 29 insertions(+), 39 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 93ff0e96..9f07e2c6 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -112,6 +112,7 @@ struct session_protocol_decrypted_envelope { session_protocol_envelope envelope; span_u8 content_plaintext; uint8_t sender_ed25519_pubkey[32]; + uint8_t sender_x25519_pubkey[32]; PRO_STATUS pro_status; pro_proof pro_proof; PRO_FEATURES pro_features; @@ -130,8 +131,8 @@ struct session_protocol_encrypted_for_destination { /// Determine the Pro features that are used in a given conversation message. /// /// Inputs: -/// - `msg` -- the conversation message to determine if the message is requires access to the 10k -/// character limit available in Session Pro +/// - `msg_size` -- the size of the message in bytes to determine if the message requires access to +/// the higher character limit available in Session Pro /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// @@ -139,7 +140,7 @@ struct session_protocol_encrypted_for_destination { /// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in /// `Content` LIBSESSION_EXPORT -PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags); +PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); /// API: session_protocol/session_protocol_encrypt_for_destination /// @@ -161,7 +162,8 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEAT /// Outputs: /// - The encryption result for the plaintext. If the destination and namespace combination did not /// require encryption, no payload is returned in the ciphertext and the user should proceed with -/// the plaintext. This should be validated by checking the `encrypted` flag on the result. +/// the plaintext. This should be validated by checking the `encrypted` flag on the result to +/// determine if the ciphertext or plaintext is to be used. /// /// The retured payload is suitable for sending on the wire (i.e: it has been protobuf /// encoded/wrapped if necessary). @@ -205,7 +207,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// proof in the message. /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in /// the proof, validating whether or not the attached proof was indeed issued by an authorised -/// issuer +/// issuer. Ignored if there's no proof in the message. /// /// Outputs: /// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 58b9f7f7..192166e2 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -6,8 +6,8 @@ #include #include -/// A complimentary file to session encrypt which has the low level encryption function for Session -/// protocol types. This file contains high-level helper functions for decoding payloads on the +/// A complimentary file to session encrypt (which has the low level encryption function for Session +/// protocol types). This file contains high-level helper functions for decoding payloads on the /// Session protocol. Prefer functions here before resorting to the lower-level cryptography. // NOTE: In the CPP file we use C-style enums for bitfields and CPP-style enums for non-bitfield @@ -116,6 +116,8 @@ struct DecryptedEnvelope { // was available. array_uc32 sender_ed25519_pubkey; + // The x25519 pubkey, always populated on successful parse. Either it's present from decrypting + // a Groups v2 envelope or it's re-derived from the Ed25519 pubkey. array_uc32 sender_x25519_pubkey; // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. @@ -167,15 +169,15 @@ struct EncryptedForDestination /// Determine the Pro features that are used in a given conversation message. /// /// Inputs: -/// - `msg` -- the conversation message to determine if the message is requires access to the 10k -/// character limit available in Session Pro +/// - `msg_size` -- the size of the message in bytes to determine if the message requires access to +/// the higher character limit available in Session Pro /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// /// Outputs: /// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in /// `Content` -PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags); +PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); /// API: session_protocol/encrypt_for_destination /// @@ -195,7 +197,7 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags); /// This function throws if the API is misused (i.e.: A field was not set, but was required to be /// set for the given destination and namespace. For example the closed group keys not being set /// when sending to a group prefixed [0x3] key in a closed group into the group message namespace) -/// but otherwise always returns a struct with values. +/// but otherwise returns a struct with values. /// /// Inputs: /// - `plaintext` -- the protobuf serialised payload containing the protobuf encoded stream, @@ -209,7 +211,8 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags); /// Outputs: /// - The encryption result for the plaintext. If the destination and namespace combination did not /// require encryption, no payload is returned in the ciphertext and the user should proceed with -/// the plaintext. This should be validated by checking the `encrypted` flag on the result. +/// the plaintext. This should be validated by checking the `encrypted` flag on the result to +/// determine if the ciphertext or plaintext is to be used. /// /// The retured payload is suitable for sending on the wire (i.e: it has been protobuf /// encoded/wrapped if necessary). diff --git a/include/session/types.h b/include/session/types.h index adca1f36..107a084c 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -3,10 +3,6 @@ #include #include -#if defined(__cplusplus) -#include -#endif - #ifdef __cplusplus extern "C" { #endif @@ -15,10 +11,6 @@ extern "C" { struct span_u8 { uint8_t* data; size_t size; - -#if defined(__cplusplus) - std::span cpp_span() const { return {data, size}; } -#endif }; struct bytes32 { diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 22f4c188..5cb0c3c2 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -303,15 +303,6 @@ EncryptedForDestination encrypt_for_destination( return result; } -struct DecryptedEnvelopeInternal { - Envelope envelope; - std::vector content_plaintext; - std::vector sender_ed25519_pubkey; - ProStatus pro_status; - config::ProProof pro_proof; - PRO_FEATURES pro_features; -}; - DecryptedEnvelope decrypt_envelope( const DecryptEnvelopeKey& keys, std::span envelope_payload, @@ -437,7 +428,7 @@ DecryptedEnvelope decrypt_envelope( // be set but will be ignored. So in all instances a signature must be attached (real or // dummy). if (!envelope.has_prosig()) - throw std::runtime_error("Parse envelope failed, pro message is missing signature"); + throw std::runtime_error("Parse envelope failed, message is missing pro signature"); // Copy (maybe dummy) pro signature into our result struct const std::string& pro_sig = envelope.prosig(); @@ -496,11 +487,9 @@ DecryptedEnvelope decrypt_envelope( std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); if (result.pro_status == ProStatus::Valid) { - // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It has been - // authorised by the backend as having a valid backing payment). - if (proof.verify(pro_backend_pubkey)) - result.pro_status = ProStatus::Valid; - else + // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was + // issued by an authoritative backend) + if (!proof.verify(pro_backend_pubkey)) result.pro_status = ProStatus::InvalidProBackendSig; // Check if the proof has expired @@ -517,7 +506,7 @@ DecryptedEnvelope decrypt_envelope( using namespace session; LIBSESSION_EXPORT -PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_FEATURES flags) { +PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) { PRO_FEATURES result = get_pro_features_for_msg(msg_size, flags); return result; } @@ -604,8 +593,10 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( .server_timestamp = result_cpp.envelope.server_timestamp, .pro_sig = {}, }, - .content_plaintext = {}, + .content_plaintext = span_u8_copy_or_throw( + result_cpp.content_plaintext.data(), result_cpp.content_plaintext.size()), .sender_ed25519_pubkey = {}, + .sender_x25519_pubkey = {}, .pro_status = static_cast(result_cpp.pro_status), .pro_proof = { @@ -628,12 +619,14 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( result_cpp.envelope.pro_sig.data(), sizeof(result.envelope.pro_sig)); - result.content_plaintext = span_u8_copy_or_throw( - result_cpp.content_plaintext.data(), result_cpp.content_plaintext.size()); std::memcpy( result.sender_ed25519_pubkey, result_cpp.sender_ed25519_pubkey.data(), sizeof(result.sender_ed25519_pubkey)); + std::memcpy( + result.sender_x25519_pubkey, + result_cpp.sender_x25519_pubkey.data(), + sizeof(result.sender_x25519_pubkey)); std::memcpy( result.pro_proof.gen_index_hash, From 8279c302d103f3c886b1063b533eea0cd9f92d38 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 17:37:30 +1000 Subject: [PATCH 029/171] Linting --- include/session/config/namespaces.h | 1 - include/session/config/namespaces.hpp | 1 + include/session/config/pro.h | 10 +++---- include/session/config/user_profile.h | 6 ++-- include/session/config/user_profile.hpp | 2 +- include/session/pro_backend.hpp | 2 +- include/session/session_protocol.hpp | 6 ++-- include/session/types.h | 4 +-- include/session/types.hpp | 2 +- src/config/user_profile.cpp | 7 ++--- src/pro_backend.cpp | 37 ++++++++++++++++++++----- src/session_protocol.cpp | 24 ++++++++-------- src/types.cpp | 11 +++----- tests/test_config_pro.cpp | 2 +- tests/test_config_userprofile.cpp | 24 ++++++++-------- tests/test_session_protocol.cpp | 25 +++++++++-------- tests/utils.hpp | 4 +-- 17 files changed, 94 insertions(+), 74 deletions(-) diff --git a/include/session/config/namespaces.h b/include/session/config/namespaces.h index a2a7aee7..ea875195 100644 --- a/include/session/config/namespaces.h +++ b/include/session/config/namespaces.h @@ -29,7 +29,6 @@ typedef enum NAMESPACE { NAMESPACE_LOCAL = 9999, } NAMESPACE; - #ifdef __cplusplus } // extern "C" #endif diff --git a/include/session/config/namespaces.hpp b/include/session/config/namespaces.hpp index 8ac4abd6..680f780a 100644 --- a/include/session/config/namespaces.hpp +++ b/include/session/config/namespaces.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include "namespaces.h" namespace session::config { diff --git a/include/session/config/pro.h b/include/session/config/pro.h index cd5c8bc7..581797c3 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -4,8 +4,8 @@ extern "C" { #endif -#include #include +#include #include #include "../export.h" @@ -23,13 +23,13 @@ struct pro_pro_config { pro_proof proof; }; -LIBSESSION_EXPORT pro_proof pro_proof_init(char const *dump, size_t dump_len); +LIBSESSION_EXPORT pro_proof pro_proof_init(char const* dump, size_t dump_len); -LIBSESSION_EXPORT pro_pro_config pro_pro_init(char const *dump, size_t dump_len); +LIBSESSION_EXPORT pro_pro_config pro_pro_init(char const* dump, size_t dump_len); -LIBSESSION_EXPORT bool pro_proof_verify(pro_proof const *proof, uint8_t const *verify_pubkey); +LIBSESSION_EXPORT bool pro_proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey); -LIBSESSION_EXPORT bool pro_pro_verify(pro_pro_config const *pro, uint8_t const *verify_pubkey); +LIBSESSION_EXPORT bool pro_pro_verify(pro_pro_config const* pro, uint8_t const* verify_pubkey); #ifdef __cplusplus } // extern "C" diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index 61df3434..ee7c842e 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -5,8 +5,8 @@ extern "C" { #endif #include "base.h" -#include "profile_pic.h" #include "pro.h" +#include "profile_pic.h" /// API: user_profile/user_profile_init /// @@ -300,7 +300,7 @@ LIBSESSION_EXPORT int64_t user_profile_get_profile_updated(config_object* conf); /// Outputs: /// - `bool` -- True if the user profile had Pro data associated with it. Otherwise false and the /// pro structure will remain untouched. -LIBSESSION_EXPORT bool user_profile_get_pro_config(const config_object* conf, pro_pro_config *pro); +LIBSESSION_EXPORT bool user_profile_get_pro_config(const config_object* conf, pro_pro_config* pro); /// API: user_profile/user_profile_set_pro_config /// @@ -320,7 +320,7 @@ LIBSESSION_EXPORT bool user_profile_get_pro_config(const config_object* conf, pr /// /// Outputs: /// - `void` -- Returns nothing -LIBSESSION_EXPORT void user_profile_set_pro_config(config_object* conf, const pro_pro_config *pro); +LIBSESSION_EXPORT void user_profile_set_pro_config(config_object* conf, const pro_pro_config* pro); #ifdef __cplusplus } // extern "C" diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index 8314ea91..a96c2b49 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -7,8 +7,8 @@ #include "base.hpp" #include "namespaces.hpp" -#include "profile_pic.hpp" #include "pro.hpp" +#include "profile_pic.hpp" namespace session::config { diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 0504f664..442f15ab 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -49,4 +49,4 @@ master_rotating_sigs build_add_payment_sigs( const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); -} // namespace session::pro +} // namespace session::pro_backend diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 192166e2..2a789184 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -134,8 +134,7 @@ struct DecryptedEnvelope { PRO_FEATURES pro_features; }; -struct DecryptEnvelopeKey -{ +struct DecryptEnvelopeKey { // Indicate to the envelope decrypting function that it should use the group keys to decrypt the // envelope (e.g.: for groups v2 envelopes where the envelope is encrypted and the body // unencrypted). The `group_keys` must be set if this flag is true. The recipient ed25519 @@ -152,8 +151,7 @@ struct DecryptEnvelopeKey std::span recipient_ed25519_privkey; }; -struct EncryptedForDestination -{ +struct EncryptedForDestination { // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to // the destination and namespace does not require encryption. In this case `ciphertext` is not // set and the user should proceed with the original plaintext. diff --git a/include/session/types.h b/include/session/types.h index 107a084c..fa6b8872 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #ifdef __cplusplus extern "C" { @@ -29,7 +29,7 @@ span_u8 span_u8_alloc_or_throw(size_t size); /// Create a span of bytes that copies the payload at `data` for `size` bytes. If allocation fails /// this function throws a runtime exception. The `data` pointer is span must be freed once the span /// is no longer needed. -span_u8 span_u8_copy_or_throw(const void *data, size_t size); +span_u8 span_u8_copy_or_throw(const void* data, size_t size); #ifdef __cplusplus } diff --git a/include/session/types.hpp b/include/session/types.hpp index 4cd9022f..1bc2ca00 100644 --- a/include/session/types.hpp +++ b/include/session/types.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace session { using array_uc32 = std::array; diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 8d9446f2..86669b8b 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -159,7 +159,7 @@ std::optional UserProfile::get_pro_config() const { return result; } -void UserProfile::set_pro_config(ProConfig const &pro) { +void UserProfile::set_pro_config(ProConfig const& pro) { auto root = data["s"]; root["r"] = pro.rotating_privkey; @@ -278,7 +278,7 @@ LIBSESSION_C_API int64_t user_profile_get_profile_updated(config_object* conf) { return unbox(conf)->get_profile_updated().time_since_epoch().count(); } -LIBSESSION_C_API bool user_profile_get_pro_data(const config_object* conf, pro_pro_config *pro) { +LIBSESSION_C_API bool user_profile_get_pro_data(const config_object* conf, pro_pro_config* pro) { if (auto val = unbox(conf)->get_pro_config(); val) { static_assert(sizeof pro->proof.gen_index_hash == sizeof(val->proof.gen_index_hash)); static_assert(sizeof pro->proof.rotating_pubkey == sizeof(val->proof.rotating_pubkey)); @@ -299,7 +299,7 @@ LIBSESSION_C_API bool user_profile_get_pro_data(const config_object* conf, pro_p return false; } -LIBSESSION_C_API void user_profile_set_pro_data(config_object* conf, const pro_pro_config *pro) { +LIBSESSION_C_API void user_profile_set_pro_data(config_object* conf, const pro_pro_config* pro) { ProConfig val = {}; val.proof.version = pro->proof.version; std::memcpy( @@ -316,5 +316,4 @@ LIBSESSION_C_API void user_profile_set_pro_data(config_object* conf, const pro_p unbox(conf)->set_pro_config(val); } - } // extern "C" diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 97e1cd06..a40299a5 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -11,7 +11,9 @@ namespace session::pro_backend { static_assert(PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); master_rotating_sigs build_get_proof_sigs( - const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts) { + const array_uc64& master_privkey, + const array_uc64& rotating_privkey, + std::chrono::seconds unix_ts) { // Derive the public keys array_uc32 master_pubkey; array_uc32 rotating_pubkey; @@ -27,13 +29,24 @@ master_rotating_sigs build_get_proof_sigs( crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update(&state, master_pubkey.data(), master_pubkey.size()); crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); - crypto_generichash_blake2b_update(&state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash with both keys master_rotating_sigs result = {}; - crypto_sign_ed25519_detached(result.master_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), master_privkey.data()); - crypto_sign_ed25519_detached(result.rotating_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), rotating_privkey.data()); + crypto_sign_ed25519_detached( + result.master_sig.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + master_privkey.data()); + crypto_sign_ed25519_detached( + result.rotating_sig.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + rotating_privkey.data()); return result; } @@ -61,8 +74,18 @@ master_rotating_sigs build_add_payment_sigs( // Sign the hash with both keys master_rotating_sigs result = {}; - crypto_sign_ed25519_detached(result.master_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), master_privkey.data()); - crypto_sign_ed25519_detached(result.rotating_sig.data(), nullptr, hash_to_sign.data(), hash_to_sign.size(), rotating_privkey.data()); + crypto_sign_ed25519_detached( + result.master_sig.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + master_privkey.data()); + crypto_sign_ed25519_detached( + result.rotating_sig.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + rotating_privkey.data()); return result; } @@ -105,4 +128,4 @@ std::string add_payment_request::to_json() const { oxenc::to_hex(rotating_sig)); return result; } -} // namespace session::pro +} // namespace session::pro_backend diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 5cb0c3c2..f8db66ad 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -189,7 +189,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( if (dest_pro_sig.empty()) { // If there's no pro signature specified, we still fill out the pro signature with a // dummy 64 byte stream. This is to make pro and non-pro messages indistinguishable. - std::string *pro_sig = envelope.mutable_prosig(); + std::string* pro_sig = envelope.mutable_prosig(); pro_sig->resize(sizeof(array_uc64)); randombytes_buf(pro_sig->data(), pro_sig->size()); } else { @@ -209,7 +209,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); // Make request - WebSocketProtos::WebSocketRequestMessage *req_msg = msg.mutable_request(); + WebSocketProtos::WebSocketRequestMessage* req_msg = msg.mutable_request(); req_msg->set_body(envelope.SerializeAsString()); // Write message as ciphertext @@ -332,7 +332,7 @@ DecryptedEnvelope decrypt_envelope( sender_x25519_pubkey.size())}; // Update the plaintext to use the decrypted envelope - envelope_plaintext = envelope_plaintext_from_group_keys; // Update the plaintext + envelope_plaintext = envelope_plaintext_from_group_keys; // Update the plaintext // Copy keys out std::memcpy( @@ -364,10 +364,8 @@ DecryptedEnvelope decrypt_envelope( // the source is a Session public key (see: encrypt_for_destination) const std::string& source = envelope.source(); if (source.size() != result.envelope.source.max_size()) - throw std::runtime_error( - fmt::format( - "Parse envelope failed, source had unexpected size ({} bytes)", - source.size())); + throw std::runtime_error(fmt::format( + "Parse envelope failed, source had unexpected size ({} bytes)", source.size())); std::memcpy(result.envelope.source.data(), source.data(), source.size()); result.envelope.flags |= ENVELOPE_FLAGS_SOURCE; } @@ -411,7 +409,10 @@ DecryptedEnvelope decrypt_envelope( "key."); } else { result.content_plaintext.resize(envelope.content().size()); - std::memcpy(result.content_plaintext.data(), envelope.content().data(), envelope.content().size()); + std::memcpy( + result.content_plaintext.data(), + envelope.content().data(), + envelope.content().size()); } // TODO: We parse the content in libsession to extract pro metadata but we return the unparsed @@ -421,7 +422,8 @@ DecryptedEnvelope decrypt_envelope( // interface. SessionProtos::Content content = {}; if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) - throw std::runtime_error{fmt::format("Parse content from envelope failed: {}", result.content_plaintext.size())}; + throw std::runtime_error{fmt::format( + "Parse content from envelope failed: {}", result.content_plaintext.size())}; // A signature must always be present on the envelope. This is to make a pro and non-pro // envelope indistinguishable. If the message does not have pro then this signature must still @@ -513,9 +515,9 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( - const void *plaintext, + const void* plaintext, size_t plaintext_len, - const void *ed25519_privkey, + const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, NAMESPACE space) { diff --git a/src/types.cpp b/src/types.cpp index a2c53461..5285f954 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1,20 +1,17 @@ -#include - #include +#include -span_u8 span_u8_alloc_or_throw(size_t size) -{ +span_u8 span_u8_alloc_or_throw(size_t size) { span_u8 result = {}; result.size = size; - result.data = static_cast(malloc(size)); + result.data = static_cast(malloc(size)); if (!result.data) throw std::runtime_error( fmt::format("Failed to allocate {} bytes for span, out of memory", size)); return result; } -span_u8 span_u8_copy_or_throw(const void *data, size_t size) -{ +span_u8 span_u8_copy_or_throw(const void* data, size_t size) { span_u8 result = span_u8_alloc_or_throw(size); std::memcpy(result.data, data, result.size); return result; diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 75d02941..58a7c932 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -80,7 +80,7 @@ TEST_CASE("Pro", "[config][pro]") { { session::config::dict bad_dict = good_dict; std::array broken_sig = pro.proof.sig; - broken_sig[0] = ~broken_sig[0]; // Break the sig + broken_sig[0] = ~broken_sig[0]; // Break the sig // clang-format off const session::config::ProProof& proof = pro.proof; diff --git a/tests/test_config_userprofile.cpp b/tests/test_config_userprofile.cpp index e8f2b5f2..7f0a37b5 100644 --- a/tests/test_config_userprofile.cpp +++ b/tests/test_config_userprofile.cpp @@ -63,24 +63,24 @@ TEST_CASE("UserProfile", "[config][user_profile]") { session::config::UserProfile profile{std::span{seed}, std::nullopt}; - CHECK_THROWS(profile.set_name( - "123456789012345678901234567890123456789012345678901234567890123456789" - "0123456789012345678901234567890A")); - CHECK_NOTHROW(profile.set_name_truncated( - "12345678901234567890123456789012345678901234567890123456789" - "01234567890123456789012345678901234567890A")); + CHECK_THROWS( + profile.set_name("123456789012345678901234567890123456789012345678901234567890123456789" + "0123456789012345678901234567890A")); + CHECK_NOTHROW( + profile.set_name_truncated("12345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890A")); CHECK(profile.get_name() == "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" "901234567890"); - CHECK_NOTHROW(profile.set_name_truncated( - "12345678901234567890123456789012345678901234567890123456789" - "01234567890123456789012345678901234567🎂")); + CHECK_NOTHROW( + profile.set_name_truncated("12345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567🎂")); CHECK(profile.get_name() == "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" "901234567"); - CHECK_NOTHROW(profile.set_name_truncated( - "12345678901234567890123456789012345678901234567890123456789" - "012345678901234567890123456789012345🎂🎂")); + CHECK_NOTHROW( + profile.set_name_truncated("12345678901234567890123456789012345678901234567890123456789" + "012345678901234567890123456789012345🎂🎂")); CHECK(profile.get_name() == "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" "9012345🎂"); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index cd13c8c7..2a1334a2 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -2,17 +2,17 @@ #include #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include -#include "WebSocketResources.pb.h" #include "SessionProtos.pb.h" +#include "WebSocketResources.pb.h" #include "utils.hpp" using namespace session; @@ -349,7 +349,8 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(data.body() == large_message); } - SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with Pro") { + SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with " + "Pro") { // Encrypt EncryptedForDestination encrypt_result = {}; { @@ -367,7 +368,8 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { // Legacy groups wrap in websocket message WebSocketProtos::WebSocketMessage ws_msg; - REQUIRE(ws_msg.ParseFromArray(encrypt_result.ciphertext.data(), encrypt_result.ciphertext.size())); + REQUIRE(ws_msg.ParseFromArray( + encrypt_result.ciphertext.data(), encrypt_result.ciphertext.size())); REQUIRE(ws_msg.has_request()); REQUIRE(ws_msg.request().has_body()); @@ -487,12 +489,11 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { DecryptEnvelopeKey bad_decrypt_keys = {}; bad_decrypt_keys.use_group_keys = false; bad_decrypt_keys.recipient_ed25519_privkey = keys.ed_sk0; - CHECK_THROWS( - session::decrypt_envelope( - bad_decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts, - pro_backend_ed_pk)); + CHECK_THROWS(session::decrypt_envelope( + bad_decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts, + pro_backend_ed_pk)); // Try decrypt with a bad backend key array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; diff --git a/tests/utils.hpp b/tests/utils.hpp index 4b4474ce..d02eb009 100644 --- a/tests/utils.hpp +++ b/tests/utils.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -12,9 +13,8 @@ #include #include -#include "session/util.hpp" #include "session/types.hpp" -#include +#include "session/util.hpp" using namespace std::literals; using namespace oxenc::literals; From 429e8e8570bcd0deb176d995fc309fab20cb9d05 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 17:42:23 +1000 Subject: [PATCH 030/171] Fix pro tests breaking due to version change to @ --- tests/test_config_pro.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 58a7c932..8ef9e38a 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -56,7 +56,7 @@ TEST_CASE("Pro", "[config][pro]") { good_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ - /*version*/ {"v", 0}, + /*version*/ {"@", 0}, /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, @@ -87,7 +87,7 @@ TEST_CASE("Pro", "[config][pro]") { bad_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ - /*version*/ {"v", 0}, + /*version*/ {"@", 0}, /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, From 01b29ccf2f7f330df4387b5d711948b35abc6b04 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 15 Aug 2025 12:07:09 +1000 Subject: [PATCH 031/171] Move group msg encryption primitive into session encrypt, avoids circular dependency --- include/session/config/groups/keys.hpp | 53 +----- include/session/session_encrypt.hpp | 105 +++++++++++ include/session/util.hpp | 12 +- src/CMakeLists.txt | 2 +- src/config/groups/keys.cpp | 194 ++------------------ src/config/internal.cpp | 59 ------- src/config/internal.hpp | 13 -- src/session_encrypt.cpp | 236 +++++++++++++++++++++++++ src/util.cpp | 57 ++++++ 9 files changed, 435 insertions(+), 296 deletions(-) diff --git a/include/session/config/groups/keys.hpp b/include/session/config/groups/keys.hpp index 3e20c9b7..83938e5c 100644 --- a/include/session/config/groups/keys.hpp +++ b/include/session/config/groups/keys.hpp @@ -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 @@ -728,12 +694,9 @@ class Keys : public ConfigSig { /// API: groups/Keys::decrypt_message /// - /// Decrypts group message content that was presumably encrypted with `encrypt_message`, - /// verifies the sender signature, decompresses the message (if necessary) and then returns the - /// author pubkey and the plaintext data. + /// Decrypts group message content that encrypted with `encrypt_message`. /// - /// 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 diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index b4b6f5ed..82bca79c 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -108,6 +108,81 @@ std::vector encrypt_for_blinded_recipient( std::span recipient_blinded_id, std::span message); +static constexpr size_t GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE = 1'000'000; + +/// API: crypto/encrypt_for_group +/// +/// Compresses, signs, and encrypts group message content. +/// +/// This function 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 function will throw on failure: +/// - if any of the keys passed in are invalidly sized or non-valid keys +/// - 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 +/// on data passed into encrypt_message; this limitation is in *this* function to match the +/// `decrypt_message` limit which is merely intended to guard against decompression memory +/// exhaustion attacks. +/// +/// Inputs: +/// - `user_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte +/// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey +/// - `group_ed25519_pubkey` -- the 32 byte public key of the group +/// - `group_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte +/// libsodium secret key +/// - `plaintext` -- the binary message to encrypt. +/// - `compress` -- can be specified as `false` to forcibly disable compression. Normally +/// omitted, to use compression if and only if it reduces the size. +/// - `padding` -- the padding multiple: padding will be added as needed to attain a multiple of +/// this value for the final result. 0 or 1 disables padding entirely. Normally omitted to +/// use the default of next-multiple-of-256. +/// +/// Outputs: +/// - `ciphertext` -- the encrypted, etc. value to send to the swarm +std::vector encrypt_for_group( + std::span user_ed25519_privkey, + std::span group_ed25519_pubkey, + std::span group_ed25519_privkey, + std::span plaintext, + bool compress, + size_t padding); + /// API: crypto/sign_for_recipient /// /// Performs the signing steps for session protocol encryption. This is responsible for producing @@ -247,6 +322,36 @@ std::pair, std::string> decrypt_from_blinded_recipien std::span recipient_id, std::span ciphertext); +/// API: crypto/decrypt_group_message +/// +/// Decrypts group message content that was presumably encrypted with `encrypt_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. +/// +/// Inputs: +/// - `decrypt_ed25519_privkey` -- the private key to use to decrypt the message. Can be a 32-byte +/// seed, or a 64-byte libsodium secret key. The public key component is not used. +/// - `group_ed25519_pubkey` -- the 32 byte public key of the group +/// - `ciphertext` -- an encrypted, encoded, signed, (possibly) compressed message as produced +/// by `encrypt_message()`. +/// +/// Outputs: +/// - `std::pair>` -- the session ID (in hex) and the +/// plaintext binary +/// data that was encrypted. +/// +/// On failure this throws a std::exception-derived exception with a `.what()` string containing +/// some diagnostic info on what part failed. Typically a production session client would catch +/// (and possibly log) but otherwise ignore such exceptions and just not process the message if +/// it throws. +std::pair> decrypt_group_message( + std::span decrypt_ed25519_privkey, + std::span group_ed25519_pubkey, + std::span ciphertext); + /// API: crypto/decrypt_ons_response /// /// Decrypts the response of an ONS lookup. diff --git a/include/session/util.hpp b/include/session/util.hpp index 8ff560a4..4f94a932 100644 --- a/include/session/util.hpp +++ b/include/session/util.hpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -280,4 +279,15 @@ static_assert(std::is_same_v< std::chrono::seconds, decltype(std::declval().time_since_epoch())>); +/// ZSTD-compresses a value. `prefix` can be prepended on the returned value, if needed. Throws on +/// serious error. +std::vector zstd_compress( + std::span data, + int level = 1, + std::span prefix = {}); + +/// ZSTD-decompresses a value. Returns nullopt if decompression fails. If max_size is non-zero +/// then this returns nullopt if the decompressed size would exceed that limit. +std::optional> zstd_decompress( + std::span data, size_t max_size = 0); } // namespace session diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 720426d7..8a3c0be7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,6 +85,7 @@ target_link_libraries(util PUBLIC common oxen::logging + libzstd::static ) target_link_libraries(crypto @@ -101,7 +102,6 @@ target_link_libraries(config libsession::protos PRIVATE libsodium::sodium-internal - libzstd::static ) if(ENABLE_ONIONREQ) diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index 534ecc35..dd2eca4d 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -23,6 +23,7 @@ #include "session/config/groups/members.hpp" #include "session/multi_encrypt.hpp" #include "session/xed25519.hpp" +#include "session/session_encrypt.hpp" using namespace std::literals; @@ -1201,203 +1202,42 @@ static constexpr size_t ENCRYPT_OVERHEAD = std::vector Keys::encrypt_message( std::span plaintext, bool compress, size_t padding) const { - if (plaintext.size() > MAX_PLAINTEXT_MESSAGE_SIZE) - throw std::runtime_error{"Cannot encrypt plaintext: message size is too large"}; - std::vector _compressed; - if (compress) { - _compressed = zstd_compress(plaintext); - if (_compressed.size() < plaintext.size()) - plaintext = _compressed; - else { - _compressed.clear(); - compress = false; - } - } - // `plaintext` is now pointing at either the original input data, or at `_compressed` local - // variable containing the compressed form of that data. - - oxenc::bt_dict_producer dict{}; - - // encoded data version (bump this if something changes in an incompatible way) - dict.append("", 1); - - // Sender ed pubkey, by which the message can be validated. Note that there are *two* - // components to this validation: first the regular signature validation of the "s" signature we - // add below, but then also validation that this Ed25519 converts to the Session ID of the - // claimed sender of the message inside the encoded message data. - dict.append( - "a", std::string_view{reinterpret_cast(user_ed25519_sk.data()) + 32, 32}); - - if (!compress) - dict.append("d", to_string_view(plaintext)); - - // We sign `plaintext || group_ed25519_pubkey` rather than just `plaintext` so that if this - // encrypted data will not validate if cross-posted to any other group. We don't actually - // include the pubkey alongside, because that is implicitly known by the group members that - // receive it. assert(_sign_pk); - std::vector to_sign(plaintext.size() + _sign_pk->size()); - std::memcpy(to_sign.data(), plaintext.data(), plaintext.size()); - std::memcpy(to_sign.data() + plaintext.size(), _sign_pk->data(), _sign_pk->size()); - - std::array signature; - crypto_sign_ed25519_detached( - signature.data(), nullptr, to_sign.data(), to_sign.size(), user_ed25519_sk.data()); - dict.append("s", to_string_view(signature)); - - if (compress) - dict.append("z", to_string_view(plaintext)); - - auto encoded = std::move(dict).str(); - - // suppose size == 250, padding = 256 - // so size + overhead(40) == 290 - // need padding of (256 - (290 % 256)) = 256 - 34 = 222 - // thus 290 + 222 = 512 - size_t final_len = ENCRYPT_OVERHEAD + encoded.size(); - if (padding > 1 && final_len % padding != 0) { - size_t to_append = padding - (final_len % padding); - encoded.resize(encoded.size() + to_append); - } - - std::vector ciphertext; - ciphertext.resize(ENCRYPT_OVERHEAD + encoded.size()); - randombytes_buf(ciphertext.data(), crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); - std::span nonce{ - ciphertext.data(), crypto_aead_xchacha20poly1305_ietf_NPUBBYTES}; - if (0 != crypto_aead_xchacha20poly1305_ietf_encrypt( - ciphertext.data() + crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, - nullptr, - to_unsigned(encoded.data()), - encoded.size(), - nullptr, - 0, - nullptr, - nonce.data(), - group_enc_key().data())) - throw std::runtime_error{"Encryption failed"}; - + std::vector ciphertext = encrypt_for_group( + user_ed25519_sk, *_sign_pk, group_enc_key(), plaintext, compress, padding); return ciphertext; } std::pair> Keys::decrypt_message( std::span ciphertext) const { - if (ciphertext.size() < ENCRYPT_OVERHEAD) - throw std::runtime_error{"ciphertext is too small to be encrypted data"}; - - std::vector plain; - - auto nonce = ciphertext.subspan(0, crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); - ciphertext = ciphertext.subspan(crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); - plain.resize(ciphertext.size() - crypto_aead_xchacha20poly1305_ietf_ABYTES); + assert(_sign_pk); + std::pair> result; // // Decrypt, using all the possible keys, starting with a pending one (if we have one) // bool decrypt_success = false; - if (auto pending = pending_key(); - pending && try_decrypting(plain.data(), ciphertext, nonce, *pending)) { - decrypt_success = true; - } else { + if (auto pending = pending_key(); pending) { + try { + result = decrypt_group_message(*pending, *_sign_pk, ciphertext); + decrypt_success = true; + } catch (const std::exception&) { + } + } + + if (!decrypt_success) { for (auto& k : keys_) { - if (try_decrypting(plain.data(), ciphertext, nonce, k.key)) { + try { + result = decrypt_group_message(k.key, *_sign_pk, ciphertext); decrypt_success = true; break; + } catch (const std::exception&) { } } } if (!decrypt_success) // none of the keys worked throw std::runtime_error{"unable to decrypt ciphertext with any current group keys"}; - - // - // Removing any null padding bytes from the end - // - if (auto it = - std::find_if(plain.rbegin(), plain.rend(), [](unsigned char c) { return c != 0; }); - it != plain.rend()) - plain.resize(plain.size() - std::distance(plain.rbegin(), it)); - - // - // Now what we have less should be a bt_dict - // - if (plain.empty() || plain.front() != 'd' || plain.back() != 'e') - throw std::runtime_error{"decrypted data is not a bencoded dict"}; - - oxenc::bt_dict_consumer dict{to_string_view(plain)}; - - if (!dict.skip_until("")) - throw std::runtime_error{"group message version tag (\"\") is missing"}; - if (auto v = dict.consume_integer(); v != 1) - throw std::runtime_error{ - "group message version tag (" + std::to_string(v) + - ") is not compatible (we support v1)"}; - - if (!dict.skip_until("a")) - throw std::runtime_error{"missing message author pubkey"}; - auto ed_pk = to_span(dict.consume_string_view()); - if (ed_pk.size() != 32) - throw std::runtime_error{ - "message author pubkey size (" + std::to_string(ed_pk.size()) + ") is invalid"}; - - std::array x_pk; - if (0 != crypto_sign_ed25519_pk_to_curve25519(x_pk.data(), ed_pk.data())) - throw std::runtime_error{ - "author ed25519 pubkey is invalid (unable to convert it to a session id)"}; - - std::pair> result; - auto& [session_id, data] = result; - session_id.reserve(66); - session_id += "05"; - oxenc::to_hex(x_pk.begin(), x_pk.end(), std::back_inserter(session_id)); - - std::span raw_data; - if (dict.skip_until("d")) { - raw_data = to_span(dict.consume_string_view()); - if (raw_data.empty()) - throw std::runtime_error{"uncompressed message data (\"d\") cannot be empty"}; - } - - if (!dict.skip_until("s")) - throw std::runtime_error{"message signature is missing"}; - auto ed_sig = to_span(dict.consume_string_view()); - if (ed_sig.size() != 64) - throw std::runtime_error{ - "message signature size (" + std::to_string(ed_sig.size()) + ") is invalid"}; - - bool compressed = false; - if (dict.skip_until("z")) { - if (!raw_data.empty()) - throw std::runtime_error{ - "message signature cannot contain both compressed (z) and uncompressed (d) " - "data"}; - raw_data = to_span(dict.consume_string_view()); - if (raw_data.empty()) - throw std::runtime_error{"compressed message data (\"z\") cannot be empty"}; - - compressed = true; - } else if (raw_data.empty()) - throw std::runtime_error{"message must contain compressed (z) or uncompressed (d) data"}; - - // The value we verify is the raw data *followed by* the group Ed25519 pubkey. (See the comment - // in encrypt_message). - assert(_sign_pk); - std::vector to_verify; - to_verify.resize(raw_data.size() + _sign_pk->size()); - std::memcpy(to_verify.data(), raw_data.data(), raw_data.size()); - std::memcpy(to_verify.data() + raw_data.size(), _sign_pk->data(), _sign_pk->size()); - if (0 != crypto_sign_ed25519_verify_detached( - ed_sig.data(), to_verify.data(), to_verify.size(), ed_pk.data())) - throw std::runtime_error{"message signature failed validation"}; - - if (compressed) { - if (auto decomp = zstd_decompress(raw_data, MAX_PLAINTEXT_MESSAGE_SIZE)) { - data = std::move(*decomp); - } else - throw std::runtime_error{"message decompression failed"}; - } else - data.assign(raw_data.begin(), raw_data.end()); - return result; } diff --git a/src/config/internal.cpp b/src/config/internal.cpp index 8ed6f61d..aa802e5c 100644 --- a/src/config/internal.cpp +++ b/src/config/internal.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -242,62 +241,4 @@ void load_unknowns( throw oxenc::bt_deserialize_invalid{"invalid bencoded value type"}; } } - -namespace { - struct zstd_decomp_freer { - void operator()(ZSTD_DStream* z) const { ZSTD_freeDStream(z); } - }; - - using zstd_decomp_ptr = std::unique_ptr; -} // namespace - -std::vector zstd_compress( - std::span data, int level, std::span prefix) { - std::vector compressed; - if (prefix.empty()) - compressed.resize(ZSTD_compressBound(data.size())); - else { - compressed.resize(prefix.size() + ZSTD_compressBound(data.size())); - std::copy(prefix.begin(), prefix.end(), compressed.begin()); - } - auto size = ZSTD_compress( - compressed.data() + prefix.size(), - compressed.size() - prefix.size(), - data.data(), - data.size(), - level); - if (ZSTD_isError(size)) - throw std::runtime_error{"Compression failed: " + std::string{ZSTD_getErrorName(size)}}; - - compressed.resize(prefix.size() + size); - return compressed; -} - -std::optional> zstd_decompress( - std::span data, size_t max_size) { - zstd_decomp_ptr z_decompressor{ZSTD_createDStream()}; - auto* zds = z_decompressor.get(); - - ZSTD_initDStream(zds); - ZSTD_inBuffer input{/*.src=*/data.data(), /*.size=*/data.size(), /*.pos=*/0}; - std::array out_buf; - ZSTD_outBuffer output{/*.dst=*/out_buf.data(), /*.size=*/out_buf.size(), /*.pos=*/0}; - - std::vector decompressed; - - size_t ret; - do { - output.pos = 0; - if (ret = ZSTD_decompressStream(zds, &output, &input); ZSTD_isError(ret)) - return std::nullopt; - - if (max_size > 0 && decompressed.size() + output.pos > max_size) - return std::nullopt; - - decompressed.insert(decompressed.end(), out_buf.begin(), out_buf.begin() + output.pos); - } while (ret > 0 || input.pos < input.size); - - return decompressed; -} - } // namespace session::config diff --git a/src/config/internal.hpp b/src/config/internal.hpp index 2b843856..8d8908e2 100644 --- a/src/config/internal.hpp +++ b/src/config/internal.hpp @@ -254,19 +254,6 @@ void load_unknowns( oxenc::bt_dict_consumer& in, std::string_view previous, std::string_view until); - -/// ZSTD-compresses a value. `prefix` can be prepended on the returned value, if needed. Throws on -/// serious error. -std::vector zstd_compress( - std::span data, - int level = 1, - std::span prefix = {}); - -/// ZSTD-decompresses a value. Returns nullopt if decompression fails. If max_size is non-zero -/// then this returns nullopt if the decompressed size would exceed that limit. -std::optional> zstd_decompress( - std::span data, size_t max_size = 0); - } // namespace session::config namespace fmt { diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 36246618..1614693e 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include #include @@ -360,6 +363,115 @@ std::vector encrypt_for_blinded_recipient( return ciphertext; } +static constexpr size_t GROUPS_ENCRYPT_OVERHEAD = + crypto_aead_xchacha20poly1305_ietf_NPUBBYTES + crypto_aead_xchacha20poly1305_ietf_ABYTES; + +std::vector encrypt_for_group( + std::span user_ed25519_privkey, + std::span group_ed25519_pubkey, + std::span group_ed25519_privkey, + std::span plaintext, + bool compress, + size_t padding) { + if (plaintext.size() > GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE) + throw std::runtime_error{"Cannot encrypt plaintext: message size is too large"}; + + // Generate the user's pubkey if they passed in a 32 byte secret key instead of the + // libsodium-style 64 byte secret key. + cleared_uc64 user_ed25519_privkey_from_seed; + if (user_ed25519_privkey.size() == 32) { + uc32 ignore_pk; + crypto_sign_ed25519_seed_keypair( + ignore_pk.data(), + user_ed25519_privkey_from_seed.data(), + user_ed25519_privkey.data()); + user_ed25519_privkey = { + user_ed25519_privkey_from_seed.data(), user_ed25519_privkey_from_seed.size()}; + } else if (user_ed25519_privkey.size() != 64) { + throw std::invalid_argument{"Invalid user_ed25519_privkey: expected 32 or 64 bytes"}; + } + + if (group_ed25519_privkey.size() != 32 && group_ed25519_privkey.size() != 64) + throw std::invalid_argument{"Invalid group_ed25519_privkey: expected 32 or 64 bytes"}; + if (group_ed25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) + throw std::invalid_argument{"Invalid group_ed25519_pubkey: expected 32 bytes"}; + + std::vector _compressed; + if (compress) { + _compressed = zstd_compress(plaintext); + if (_compressed.size() < plaintext.size()) + plaintext = _compressed; + else { + _compressed.clear(); + compress = false; + } + } + // `plaintext` is now pointing at either the original input data, or at `_compressed` local + // variable containing the compressed form of that data. + + oxenc::bt_dict_producer dict{}; + + // encoded data version (bump this if something changes in an incompatible way) + dict.append("", 1); + + // Sender ed pubkey, by which the message can be validated. Note that there are *two* + // components to this validation: first the regular signature validation of the "s" signature we + // add below, but then also validation that this Ed25519 converts to the Session ID of the + // claimed sender of the message inside the encoded message data. + dict.append( + "a", std::string_view{reinterpret_cast(user_ed25519_privkey.data()) + 32, 32}); + + if (!compress) + dict.append("d", to_string_view(plaintext)); + + // We sign `plaintext || group_ed25519_pubkey` rather than just `plaintext` so that if this + // encrypted data will not validate if cross-posted to any other group. We don't actually + // include the pubkey alongside, because that is implicitly known by the group members that + // receive it. + std::vector to_sign(plaintext.size() + group_ed25519_pubkey.size()); + std::memcpy(to_sign.data(), plaintext.data(), plaintext.size()); + std::memcpy(to_sign.data() + plaintext.size(), group_ed25519_pubkey.data(), group_ed25519_pubkey.size()); + + std::array signature; + crypto_sign_ed25519_detached( + signature.data(), nullptr, to_sign.data(), to_sign.size(), user_ed25519_privkey.data()); + dict.append("s", to_string_view(signature)); + + if (compress) + dict.append("z", to_string_view(plaintext)); + + auto encoded = std::move(dict).str(); + + // suppose size == 250, padding = 256 + // so size + overhead(40) == 290 + // need padding of (256 - (290 % 256)) = 256 - 34 = 222 + // thus 290 + 222 = 512 + size_t final_len = GROUPS_ENCRYPT_OVERHEAD + encoded.size(); + if (padding > 1 && final_len % padding != 0) { + size_t to_append = padding - (final_len % padding); + encoded.resize(encoded.size() + to_append); + } + + std::vector ciphertext; + ciphertext.resize(GROUPS_ENCRYPT_OVERHEAD + encoded.size()); + randombytes_buf(ciphertext.data(), crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); + std::span nonce{ + ciphertext.data(), crypto_aead_xchacha20poly1305_ietf_NPUBBYTES}; + if (0 != crypto_aead_xchacha20poly1305_ietf_encrypt( + ciphertext.data() + crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, + nullptr, + to_unsigned(encoded.data()), + encoded.size(), + nullptr, + 0, + nullptr, + nonce.data(), + group_ed25519_privkey.data())) + throw std::runtime_error{"Encryption failed"}; + + return ciphertext; +} + std::pair, std::string> decrypt_incoming_session_id( std::span ed25519_privkey, std::span ciphertext) { auto [buf, sender_ed_pk] = decrypt_incoming(ed25519_privkey, ciphertext); @@ -566,6 +678,130 @@ std::pair, std::string> decrypt_from_blinded_recipien return result; } +std::pair> decrypt_group_message( + std::span decrypt_ed25519_privkey, + std::span group_ed25519_pubkey, + std::span ciphertext) { + if (ciphertext.size() < GROUPS_ENCRYPT_OVERHEAD) + throw std::runtime_error{"ciphertext is too small to be encrypted data"}; + if (decrypt_ed25519_privkey.size() != 32 && decrypt_ed25519_privkey.size() != 64) + throw std::invalid_argument{"Invalid decrypt_ed25519_privkey: expected 32 or 64 bytes"}; + if (group_ed25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) + throw std::invalid_argument{"Invalid decrypt_ed25519_privkey: expected 32 bytes"}; + + // Note we only use the secret key of the decrypt_ed25519_privkey so we don't care about + // generating the pubkey component if the user only passed in a 32 byte libsodium-style secret + // key. + + std::vector plain; + + auto nonce = ciphertext.subspan(0, crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); + ciphertext = ciphertext.subspan(crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); + plain.resize(ciphertext.size() - crypto_aead_xchacha20poly1305_ietf_ABYTES); + + // Decrypt using specific key + bool decrypt_success = 0 == crypto_aead_xchacha20poly1305_ietf_decrypt( + plain.data(), + nullptr, + nullptr, + ciphertext.data(), + ciphertext.size(), + nullptr, + 0, + nonce.data(), + decrypt_ed25519_privkey.data()); + if (!decrypt_success) // none of the keys worked + throw std::runtime_error{"unable to decrypt ciphertext with any current group keys"}; + + // + // Removing any null padding bytes from the end + // + if (auto it = + std::find_if(plain.rbegin(), plain.rend(), [](unsigned char c) { return c != 0; }); + it != plain.rend()) + plain.resize(plain.size() - std::distance(plain.rbegin(), it)); + + // + // Now what we have less should be a bt_dict + // + if (plain.empty() || plain.front() != 'd' || plain.back() != 'e') + throw std::runtime_error{"decrypted data is not a bencoded dict"}; + + oxenc::bt_dict_consumer dict{to_string_view(plain)}; + + if (!dict.skip_until("")) + throw std::runtime_error{"group message version tag (\"\") is missing"}; + if (auto v = dict.consume_integer(); v != 1) + throw std::runtime_error{ + "group message version tag (" + std::to_string(v) + + ") is not compatible (we support v1)"}; + + if (!dict.skip_until("a")) + throw std::runtime_error{"missing message author pubkey"}; + auto ed_pk = to_span(dict.consume_string_view()); + if (ed_pk.size() != 32) + throw std::runtime_error{ + "message author pubkey size (" + std::to_string(ed_pk.size()) + ") is invalid"}; + + std::array x_pk; + if (0 != crypto_sign_ed25519_pk_to_curve25519(x_pk.data(), ed_pk.data())) + throw std::runtime_error{ + "author ed25519 pubkey is invalid (unable to convert it to a session id)"}; + + std::pair> result; + auto& [session_id, data] = result; + session_id.reserve(66); + session_id += "05"; + oxenc::to_hex(x_pk.begin(), x_pk.end(), std::back_inserter(session_id)); + + std::span raw_data; + if (dict.skip_until("d")) { + raw_data = to_span(dict.consume_string_view()); + if (raw_data.empty()) + throw std::runtime_error{"uncompressed message data (\"d\") cannot be empty"}; + } + + if (!dict.skip_until("s")) + throw std::runtime_error{"message signature is missing"}; + auto ed_sig = to_span(dict.consume_string_view()); + if (ed_sig.size() != 64) + throw std::runtime_error{ + "message signature size (" + std::to_string(ed_sig.size()) + ") is invalid"}; + + bool compressed = false; + if (dict.skip_until("z")) { + if (!raw_data.empty()) + throw std::runtime_error{ + "message signature cannot contain both compressed (z) and uncompressed (d) " + "data"}; + raw_data = to_span(dict.consume_string_view()); + if (raw_data.empty()) + throw std::runtime_error{"compressed message data (\"z\") cannot be empty"}; + + compressed = true; + } else if (raw_data.empty()) + throw std::runtime_error{"message must contain compressed (z) or uncompressed (d) data"}; + + // The value we verify is the raw data *followed by* the group Ed25519 pubkey. (See the comment + // in encrypt_message). + std::vector to_verify(raw_data.size() + group_ed25519_pubkey.size()); + std::memcpy(to_verify.data(), raw_data.data(), raw_data.size()); + std::memcpy(to_verify.data() + raw_data.size(), group_ed25519_pubkey.data(), group_ed25519_pubkey.size()); + if (0 != crypto_sign_ed25519_verify_detached( + ed_sig.data(), to_verify.data(), to_verify.size(), ed_pk.data())) + throw std::runtime_error{"message signature failed validation"}; + + if (compressed) { + if (auto decomp = zstd_decompress(raw_data, GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE)) { + data = std::move(*decomp); + } else + throw std::runtime_error{"message decompression failed"}; + } else + data.assign(raw_data.begin(), raw_data.end()); + + return result; +} + std::string decrypt_ons_response( std::string_view lowercase_name, std::span ciphertext, diff --git a/src/util.cpp b/src/util.cpp index 60409c58..12b5450e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace session { @@ -91,4 +92,60 @@ static_assert(std::is_same_v< std::chrono::seconds, decltype(std::declval().time_since_epoch())>); +namespace { + struct zstd_decomp_freer { + void operator()(ZSTD_DStream* z) const { ZSTD_freeDStream(z); } + }; + + using zstd_decomp_ptr = std::unique_ptr; +} // namespace + +std::vector zstd_compress( + std::span data, int level, std::span prefix) { + std::vector compressed; + if (prefix.empty()) + compressed.resize(ZSTD_compressBound(data.size())); + else { + compressed.resize(prefix.size() + ZSTD_compressBound(data.size())); + std::copy(prefix.begin(), prefix.end(), compressed.begin()); + } + auto size = ZSTD_compress( + compressed.data() + prefix.size(), + compressed.size() - prefix.size(), + data.data(), + data.size(), + level); + if (ZSTD_isError(size)) + throw std::runtime_error{"Compression failed: " + std::string{ZSTD_getErrorName(size)}}; + + compressed.resize(prefix.size() + size); + return compressed; +} + +std::optional> zstd_decompress( + std::span data, size_t max_size) { + zstd_decomp_ptr z_decompressor{ZSTD_createDStream()}; + auto* zds = z_decompressor.get(); + + ZSTD_initDStream(zds); + ZSTD_inBuffer input{/*.src=*/data.data(), /*.size=*/data.size(), /*.pos=*/0}; + std::array out_buf; + ZSTD_outBuffer output{/*.dst=*/out_buf.data(), /*.size=*/out_buf.size(), /*.pos=*/0}; + + std::vector decompressed; + + size_t ret; + do { + output.pos = 0; + if (ret = ZSTD_decompressStream(zds, &output, &input); ZSTD_isError(ret)) + return std::nullopt; + + if (max_size > 0 && decompressed.size() + output.pos > max_size) + return std::nullopt; + + decompressed.insert(decompressed.end(), out_buf.begin(), out_buf.begin() + output.pos); + } while (ret > 0 || input.pos < input.size); + + return decompressed; +} } // namespace session From 69dfa997d48af0ac01d90644172a83533f5d850a Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 18 Aug 2025 16:21:27 +1000 Subject: [PATCH 032/171] Move group encryption into session encrypt This lets the higher-level layer, session protocol to use low level encryption instead of relying on config to decrypt group messages. Decryption of a group message is a low-level cryptography routine which actually belongs in session encrypt. --- include/session/config/groups/keys.h | 13 +++ include/session/config/groups/keys.hpp | 5 + include/session/session_encrypt.h | 82 ++++++++++++++ include/session/session_encrypt.hpp | 17 ++- include/session/session_protocol.h | 11 +- include/session/session_protocol.hpp | 51 +++++---- include/session/types.h | 8 -- src/config/groups/keys.cpp | 29 ++++- src/session_encrypt.cpp | 105 +++++++++++++++--- src/session_protocol.cpp | 145 ++++++++++++++----------- tests/test_session_protocol.cpp | 56 ++++++---- 11 files changed, 378 insertions(+), 144 deletions(-) diff --git a/include/session/config/groups/keys.h b/include/session/config/groups/keys.h index f0ee5025..fbc34a0d 100644 --- a/include/session/config/groups/keys.h +++ b/include/session/config/groups/keys.h @@ -6,6 +6,7 @@ extern "C" { #include "../base.h" #include "../util.h" +#include "../../types.h" // This is an opaque type analagous to `config_object` but specific to the groups keys object. // @@ -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 diff --git a/include/session/config/groups/keys.hpp b/include/session/config/groups/keys.hpp index 83938e5c..c8f7c194 100644 --- a/include/session/config/groups/keys.hpp +++ b/include/session/config/groups/keys.hpp @@ -697,6 +697,11 @@ class Keys : public ConfigSig { /// 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. /// /// Inputs: /// - `ciphertext` -- an encrypted, encoded, signed, (possibly) compressed message as produced diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index f5a1c2b6..eccadc12 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -8,6 +8,7 @@ extern "C" { #include #include "export.h" +#include "types.h" /// API: crypto/session_encrypt_for_recipient_deterministic /// @@ -67,6 +68,53 @@ LIBSESSION_EXPORT bool session_encrypt_for_blinded_recipient( unsigned char** ciphertext_out, size_t* ciphertext_len); +typedef struct { + bool success; + span_u8 ciphertext; +} session_encrypt_group_message; + +/// API: crypto/session_encrypt_for_group +/// +/// Compresses, signs, and encrypts group message content. +/// +/// See: crypto/encrypt_for_group +/// +/// This function will set `success` to false on failure: +/// - if any of the keys passed in are invalidly sized or non-valid keys +/// - 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 +/// on data passed into encrypt_message; this limitation is in *this* function to match the +/// `decrypt_message` limit which is merely intended to guard against decompression memory +/// exhaustion attacks. +/// +/// Inputs: +/// - `user_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte +/// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey +/// - `group_ed25519_pubkey` -- the 32 byte public key of the group +/// - `group_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte +/// libsodium secret key +/// - `plaintext` -- the binary message to encrypt. +/// - `compress` -- can be specified as `false` to forcibly disable compression. Normally +/// omitted, to use compression if and only if it reduces the size. +/// - `padding` -- the padding multiple: padding will be added as needed to attain a multiple of +/// this value for the final result. 0 or 1 disables padding entirely. Normally omitted to +/// use the default of next-multiple-of-256. +/// +/// Outputs: +/// - `ciphertext` -- the encrypted, etc. value to send to the swarm +LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( + const unsigned char *user_ed25519_privkey, + size_t user_ed25519_privkey_len, + const unsigned char *group_ed25519_pubkey, + size_t group_ed25519_pubkey_len, + const unsigned char *group_ed25519_privkey, + size_t group_ed25519_privkey_len, + const unsigned char *plaintext, + size_t plaintext_len, + bool compress, + size_t padding); + /// API: crypto/session_decrypt_incoming /// /// This function attempts to decrypt a message using the SessionProtocol. @@ -166,6 +214,40 @@ LIBSESSION_EXPORT bool session_decrypt_for_blinded_recipient( unsigned char** plaintext_out, size_t* plaintext_len); +typedef struct { + bool success; + size_t index; // Index of the key that successfully decrypted the message + char session_id[66]; // In hex + span_u8 plaintext; +} session_decrypt_group_message_result; + +/// API: crypto/session_decrypt_group_message +/// +/// Decrypts group message content that was presumably encrypted with `session_encrypt_for_group`, +/// verifies the sender signature, decompresses the message (if necessary) and then returns the +/// author pubkey and the plaintext data. +/// +/// See: crypto/decrypt_group_message +/// +/// Inputs: +/// - `decrypt_ed25519_privkey_list` -- the list of private keys to try to decrypt the message with. +/// Can be a 32-byte seed, or a 64-byte libsodium secret key. The public key component is not +/// used. +/// - `group_ed25519_pubkey` -- the 32 byte public key of the group +/// - `ciphertext` -- an encrypted, encoded, signed, (possibly) compressed message as produced +/// by `encrypt_message()`. +/// +/// Outputs: +/// The struct with the results of decryption. On failure this sets the `success` boolean to false +/// and all fields should be ignored except `success`. +session_decrypt_group_message_result session_decrypt_group_message( + const span_u8 *decrypt_ed25519_privkey_list, + size_t decrypt_ed25519_privkey_len, + const unsigned char *group_ed25519_pubkey, + size_t group_ed25519_pubkey_len, + const unsigned char *ciphertext, + size_t ciphertext_len); + /// API: crypto/session_decrypt_ons_response /// /// This function attempts to decrypt an ONS response. diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index 82bca79c..d5e21f48 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -322,9 +322,15 @@ std::pair, std::string> decrypt_from_blinded_recipien std::span recipient_id, std::span ciphertext); +struct DecryptGroupMessage { + size_t index; // Index of the key that successfully decrypted the message + std::string session_id; // In hex + std::vector plaintext; +}; + /// API: crypto/decrypt_group_message /// -/// Decrypts group message content that was presumably encrypted with `encrypt_group_message`, +/// Decrypts group message content that was presumably encrypted with `encrypt_for_group`, /// verifies the sender signature, decompresses the message (if necessary) and then returns the /// author pubkey and the plaintext data. /// @@ -332,8 +338,9 @@ std::pair, std::string> decrypt_from_blinded_recipien /// a compressed value that would decompress to a value larger than 1MB. /// /// Inputs: -/// - `decrypt_ed25519_privkey` -- the private key to use to decrypt the message. Can be a 32-byte -/// seed, or a 64-byte libsodium secret key. The public key component is not used. +/// - `decrypt_ed25519_privkey_list` -- the list of private keys to try to decrypt the message with. +/// Can be a 32-byte seed, or a 64-byte libsodium secret key. The public key component is not +/// used. /// - `group_ed25519_pubkey` -- the 32 byte public key of the group /// - `ciphertext` -- an encrypted, encoded, signed, (possibly) compressed message as produced /// by `encrypt_message()`. @@ -347,8 +354,8 @@ std::pair, std::string> decrypt_from_blinded_recipien /// some diagnostic info on what part failed. Typically a production session client would catch /// (and possibly log) but otherwise ignore such exceptions and just not process the message if /// it throws. -std::pair> decrypt_group_message( - std::span decrypt_ed25519_privkey, +DecryptGroupMessage decrypt_group_message( + std::span> decrypt_ed25519_privkey_list, std::span group_ed25519_pubkey, std::span ciphertext); diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 9f07e2c6..aaee6ea3 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -69,8 +69,8 @@ struct session_protocol_destination { // See session::Destination uint8_t recipient_pubkey[33]; uint64_t sent_timestamp_ms; uint8_t open_group_inbox_server_pubkey[32]; - uint8_t closed_group_pubkey[33]; - const config_group_keys* closed_group_keys; + uint8_t closed_group_ed25519_pubkey[33]; + uint8_t closed_group_ed25519_privkey[32]; }; enum ENVELOPE_TYPE { @@ -99,10 +99,9 @@ struct session_protocol_envelope { }; struct session_protocol_decrypt_envelope_keys { - bool use_group_keys; - const config_group_keys* group_keys; - const void* recipient_ed25519_privkey; - size_t recipient_ed25519_privkey_len; + span_u8 group_ed25519_pubkey; + const span_u8 *ed25519_privkeys; + size_t ed25519_privkeys_len; }; struct session_protocol_decrypted_envelope { diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 2a789184..e56dadcd 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -75,12 +75,14 @@ struct Destination { // When type => OpenGroupInbox: set this pubkey to the server's key array_uc32 open_group_inbox_server_pubkey; - // When type => ClosedGroup: set the following 'closed_group' prefixed fields - array_uc33 closed_group_pubkey; - - // Must be set to the group keys for a 0x03 prefix (e.g. groups v2) `closed_group_pubkey` to - // encrypt the message. - const session::config::groups::Keys* closed_group_keys; + // When type => ClosedGroup: set to the group keys for a 0x03 prefix (e.g. groups v2) + // `closed_group_pubkey` to encrypt the message. Public key of the group for groups v2 messages + array_uc33 closed_group_ed25519_pubkey; + + // When type => ClosedGroup: Set the private key of the group for groups v2 messages. Typically + // the latest encryption key for the group, e.g: `Keys::group_enc_key` or + // `groups_keys_group_enc_key` + array_uc32 closed_group_ed25519_privkey; }; enum class EnvelopeType { @@ -135,20 +137,29 @@ struct DecryptedEnvelope { }; struct DecryptEnvelopeKey { - // Indicate to the envelope decrypting function that it should use the group keys to decrypt the - // envelope (e.g.: for groups v2 envelopes where the envelope is encrypted and the body - // unencrypted). The `group_keys` must be set if this flag is true. The recipient ed25519 - // private key field is ignored if this flag is set. - bool use_group_keys; - - // Keys to use to decrypt the envelope. - const config::groups::Keys* group_keys; - - // The libsodium-style secret key of the sender, 64 bytes. Can also be passed as a 32-byte seed. - // Used to decrypt the encrypted content. This field is used if `use_group_keys` is false in - // which case the group keys are ignored. This is for envelopes where the envelope itself is - // unencrypted and the contents is encrypted for this secret key. - std::span recipient_ed25519_privkey; + // Set the key to decrypt the envelope. If this key is set then it's assumed that the envelope + // payload is encrypted (e.g. groups v2) and that the contents are unencrypted. If this key is + // not set the it's assumed the envelope is not encrypted but the contents are encrypted (e.g.: + // 1o1 or legacy group). + std::optional> group_ed25519_pubkey; + + // List of libsodium-style secret key to decrypt the envelope from. Can also be passed as a 32 + // byte secret key. The public key component is not used. + // + // If the `group_ed25519_pubkey` is set then a list of keys is accepted to attempt to decrypt + // the envelope. For envelopes generated by a group message, we assume that the envelope is + // encrypted and must be decrypted by the group keys associated with it (of which there may be + // many candidate keys depending on how many times the group has been rekeyed). It's recommended + // to pass `Keys::group_keys()` or in the C API use the `groups_keys_size` and + // `group_keys_get_key` combo to retrieve the keys to attempt to use to decrypt this message. + // + // If `group_ed25519_pubkey` is _not_ set then this function assumes the envelope is unencrypted + // but the content is encrypted (e.g.: 1o1 and legacy group messages). The function will attempt + // to decrypt the envelope's contents with the given keys. Typically in these cases you will + // pass exactly 1 key for decryption but this function makes no pre-existing assumptions on the + // number of keys and will attempt all given keys specified regardless until it finds one that + // successfully decrypts the envelope contents. + std::span> ed25519_privkeys; }; struct EncryptedForDestination { diff --git a/include/session/types.h b/include/session/types.h index fa6b8872..db1db396 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -13,14 +13,6 @@ struct span_u8 { size_t size; }; -struct bytes32 { - uint8_t data[32]; -}; - -struct bytes64 { - uint8_t data[64]; -}; - /// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this /// function throws a runtime exception. The `data` pointer is span must be freed once the span /// is no longer needed. diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index dd2eca4d..a2dee3ef 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -1211,15 +1211,16 @@ std::vector Keys::encrypt_message( std::pair> Keys::decrypt_message( std::span ciphertext) const { assert(_sign_pk); - std::pair> result; // // Decrypt, using all the possible keys, starting with a pending one (if we have one) // + DecryptGroupMessage decrypt = {}; bool decrypt_success = false; if (auto pending = pending_key(); pending) { try { - result = decrypt_group_message(*pending, *_sign_pk, ciphertext); + std::span> key_list = {&(*pending), 1}; + decrypt = decrypt_group_message(key_list, *_sign_pk, ciphertext); decrypt_success = true; } catch (const std::exception&) { } @@ -1228,7 +1229,9 @@ std::pair> Keys::decrypt_message( if (!decrypt_success) { for (auto& k : keys_) { try { - result = decrypt_group_message(k.key, *_sign_pk, ciphertext); + std::span key = {k.key.data(), k.key.size()}; + std::span> key_list = {&key, 1}; + decrypt = decrypt_group_message(key_list, *_sign_pk, ciphertext); decrypt_success = true; break; } catch (const std::exception&) { @@ -1238,6 +1241,11 @@ std::pair> Keys::decrypt_message( if (!decrypt_success) // none of the keys worked throw std::runtime_error{"unable to decrypt ciphertext with any current group keys"}; + + + std::pair> result; + result.first = std::move(decrypt.session_id); + result.second = std::move(decrypt.plaintext); return result; } @@ -1348,13 +1356,26 @@ LIBSESSION_C_API size_t groups_keys_size(const config_group_keys* conf) { return unbox(conf).size(); } -LIBSESSION_C_API const unsigned char* group_keys_get_key(const config_group_keys* conf, size_t N) { +LIBSESSION_C_API const unsigned char* groups_keys_get_key(const config_group_keys* conf, size_t N) { auto keys = unbox(conf).group_keys(); if (N >= keys.size()) return nullptr; return keys[N].data(); } +LIBSESSION_C_API const span_u8 groups_keys_group_enc_key(const config_group_keys* conf) +{ + span_u8 result = {}; + try { + std::span key = unbox(conf).group_enc_key(); + result.data = const_cast(key.data()); + result.size = key.size(); + assert(result.size == 32); + } catch (const std::exception& e) { + } + return result; +} + LIBSESSION_C_API bool groups_keys_is_admin(const config_group_keys* conf) { return unbox(conf).admin(); } diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 1614693e..dc234d25 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -678,14 +678,13 @@ std::pair, std::string> decrypt_from_blinded_recipien return result; } -std::pair> decrypt_group_message( - std::span decrypt_ed25519_privkey, +DecryptGroupMessage decrypt_group_message( + std::span> decrypt_ed25519_privkey_list, std::span group_ed25519_pubkey, std::span ciphertext) { + DecryptGroupMessage result = {}; if (ciphertext.size() < GROUPS_ENCRYPT_OVERHEAD) throw std::runtime_error{"ciphertext is too small to be encrypted data"}; - if (decrypt_ed25519_privkey.size() != 32 && decrypt_ed25519_privkey.size() != 64) - throw std::invalid_argument{"Invalid decrypt_ed25519_privkey: expected 32 or 64 bytes"}; if (group_ed25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) throw std::invalid_argument{"Invalid decrypt_ed25519_privkey: expected 32 bytes"}; @@ -699,17 +698,27 @@ std::pair> decrypt_group_message( ciphertext = ciphertext.subspan(crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); plain.resize(ciphertext.size() - crypto_aead_xchacha20poly1305_ietf_ABYTES); - // Decrypt using specific key - bool decrypt_success = 0 == crypto_aead_xchacha20poly1305_ietf_decrypt( - plain.data(), - nullptr, - nullptr, - ciphertext.data(), - ciphertext.size(), - nullptr, - 0, - nonce.data(), - decrypt_ed25519_privkey.data()); + bool decrypt_success = false; + for (size_t index = 0; index < decrypt_ed25519_privkey_list.size(); index++) { + const auto& decrypt_ed25519_privkey = decrypt_ed25519_privkey_list[index]; + if (decrypt_ed25519_privkey.size() != 32 && decrypt_ed25519_privkey.size() != 64) + throw std::invalid_argument{"Invalid decrypt_ed25519_privkey: expected 32 or 64 bytes"}; + decrypt_success = 0 == crypto_aead_xchacha20poly1305_ietf_decrypt( + plain.data(), + nullptr, + nullptr, + ciphertext.data(), + ciphertext.size(), + nullptr, + 0, + nonce.data(), + decrypt_ed25519_privkey.data()); + if (decrypt_success) { + result.index = index; + break; + } + } + if (!decrypt_success) // none of the keys worked throw std::runtime_error{"unable to decrypt ciphertext with any current group keys"}; @@ -748,8 +757,7 @@ std::pair> decrypt_group_message( throw std::runtime_error{ "author ed25519 pubkey is invalid (unable to convert it to a session id)"}; - std::pair> result; - auto& [session_id, data] = result; + auto& [_, session_id, data] = result; session_id.reserve(66); session_id += "05"; oxenc::to_hex(x_pk.begin(), x_pk.end(), std::back_inserter(session_id)); @@ -1098,6 +1106,36 @@ LIBSESSION_C_API bool session_encrypt_for_blinded_recipient( } } +LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( + const unsigned char *user_ed25519_privkey, + size_t user_ed25519_privkey_len, + const unsigned char *group_ed25519_pubkey, + size_t group_ed25519_pubkey_len, + const unsigned char *group_ed25519_privkey, + size_t group_ed25519_privkey_len, + const unsigned char *plaintext, + size_t plaintext_len, + bool compress, + size_t padding) +{ + session_encrypt_group_message result = {}; + try { + std::vector result_cpp = encrypt_for_group( + {user_ed25519_privkey, user_ed25519_privkey_len}, + {group_ed25519_pubkey, group_ed25519_pubkey_len}, + {group_ed25519_privkey, group_ed25519_privkey_len}, + {plaintext, plaintext_len}, + compress, + padding); + result = { + .success = true, + .ciphertext = span_u8_copy_or_throw(result_cpp.data(), result_cpp.size()), + }; + } catch(...) { + } + return result; +} + LIBSESSION_C_API bool session_decrypt_incoming( const unsigned char* ciphertext_in, size_t ciphertext_len, @@ -1175,6 +1213,39 @@ LIBSESSION_C_API bool session_decrypt_for_blinded_recipient( } } +LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_message( + const span_u8 *decrypt_ed25519_privkey_list, + size_t decrypt_ed25519_privkey_len, + const unsigned char *group_ed25519_pubkey, + size_t group_ed25519_pubkey_len, + const unsigned char *ciphertext, + size_t ciphertext_len) +{ + session_decrypt_group_message_result result = {}; + for (size_t index = 0; index < decrypt_ed25519_privkey_len; index++) { + std::span key = { + decrypt_ed25519_privkey_list[index].data, decrypt_ed25519_privkey_list[index].size}; + + DecryptGroupMessage result_cpp = {}; + try { + result_cpp = decrypt_group_message( + {&key, 1}, + {group_ed25519_pubkey, group_ed25519_pubkey_len}, + {ciphertext, ciphertext_len}); + result = { + .success = true, + .index = index, + .plaintext = span_u8_copy_or_throw(result.plaintext.data, result.plaintext.size), + }; + assert(result_cpp.session_id.size() == sizeof(result.session_id)); + std::memcpy(result.session_id, result_cpp.session_id.data(), sizeof(result.session_id)); + break; + } catch (...) { + } + } + return result; +} + LIBSESSION_C_API bool session_decrypt_ons_response( const char* name_in, const unsigned char* ciphertext_in, diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index f8db66ad..bf7d5e1d 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -52,7 +53,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( std::chrono::milliseconds dest_sent_timestamp_ms, std::span dest_open_group_inbox_server_pubkey, std::span dest_closed_group_pubkey, - const config::groups::Keys* dest_closed_group_keys, + std::span dest_closed_group_ed25519_privkey, config::Namespace space, UseMalloc use_malloc) { @@ -60,6 +61,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_open_group_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_closed_group_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); + assert(dest_closed_group_ed25519_privkey.size() == 32 || dest_closed_group_ed25519_privkey.size() == 64); // All incoming arguments are passed in from typed, fixed-sized arrays so we do not need to // throw if these sizes are wrong. It being wrong would be a development error. @@ -104,10 +106,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( dest_closed_group_pubkey[0] == static_cast(SessionIDPrefix::group); if (has_03_prefix) { if (space == config::Namespace::GroupMessages) { - if (!dest_closed_group_keys) - throw std::runtime_error( - "API misuse: Sending to a closed group into the group messages " - "namespace requires the closed group keys to be set"); enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = false; enc.after_envelope = AfterEnvelope::KeysEncryptMessage; @@ -224,13 +222,15 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } break; case AfterEnvelope::KeysEncryptMessage: { - assert(dest_closed_group_keys && - "Dev error, API miuse was not detected. We should throw an exception " - "when this happens earlier"); - std::string bytes = envelope.SerializeAsString(); - std::vector ciphertext = - dest_closed_group_keys->encrypt_message(to_span(bytes)); + std::vector ciphertext = encrypt_for_group( + ed25519_privkey, + dest_closed_group_pubkey, + dest_closed_group_ed25519_privkey, + to_span(bytes), + /*compress*/ true, + /*padding*/ 256); + if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); @@ -291,8 +291,8 @@ EncryptedForDestination encrypt_for_destination( /*dest_recipient_pubkey=*/dest.recipient_pubkey, /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, /*dest_open_group_inbox_server_pubkey=*/dest.open_group_inbox_server_pubkey, - /*dest_closed_group_pubkey=*/dest.closed_group_pubkey, - /*dest_closed_group_keys=*/dest.closed_group_keys, + /*dest_closed_group_ed25519_pubkey=*/dest.closed_group_ed25519_pubkey, + /*dest_closed_group_ed25519_privkey=*/dest.closed_group_ed25519_privkey, /*space=*/space, /*use_malloc=*/UseMalloc::No); @@ -316,29 +316,26 @@ DecryptedEnvelope decrypt_envelope( // provided. We will decrypt the payload to get the plaintext. In all other cases, the envelope // is assumed to be unencrypted and can be used verbatim. std::vector envelope_plaintext_from_group_keys; - if (keys.use_group_keys) { - if (!keys.group_keys) - throw std::runtime_error( - "API misuse: Envelope decryption with group keys was requested but no key was " - "set"); - - // Decrypt - std::string sender_x25519_pubkey; - std::tie(sender_x25519_pubkey, envelope_plaintext_from_group_keys) = - keys.group_keys->decrypt_message(envelope_plaintext); - if (sender_x25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) + if (keys.group_ed25519_pubkey) { + // Decrypt using the keys + DecryptGroupMessage decrypt = decrypt_group_message( + keys.ed25519_privkeys, *keys.group_ed25519_pubkey, envelope_plaintext); + + if (decrypt.session_id.size() != ((crypto_sign_ed25519_PUBLICKEYBYTES + 1) * 2)) throw std::runtime_error{fmt::format( - "Parse encrypted envelope failed, extracted x25519 pubkey was wrong size: {}", - sender_x25519_pubkey.size())}; + "Parse encrypted envelope failed, extracted session ID was wrong size: " + "{}", + decrypt.session_id.size())}; // Update the plaintext to use the decrypted envelope - envelope_plaintext = envelope_plaintext_from_group_keys; // Update the plaintext + envelope_plaintext = std::move(decrypt.plaintext); // Copy keys out - std::memcpy( - result.sender_x25519_pubkey.data(), - sender_x25519_pubkey.data(), - sender_x25519_pubkey.size()); + assert(decrypt.session_id.starts_with("05")); + oxenc::from_hex( + decrypt.session_id.begin() + 2, + decrypt.session_id.end() - 2, + result.sender_x25519_pubkey.begin()); } if (!envelope.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) @@ -389,12 +386,33 @@ DecryptedEnvelope decrypt_envelope( // Decrypt content // The envelope is encrypted in GroupsV2, contents unencrypted. In 1o1 and legacy groups, the // envelope is encrypted, contents is encrypted. - bool has_encrypted_content = !keys.use_group_keys; - if (has_encrypted_content) { + if (keys.group_ed25519_pubkey) { + result.content_plaintext.resize(envelope.content().size()); + std::memcpy( + result.content_plaintext.data(), + envelope.content().data(), + envelope.content().size()); + } else { std::span content_str = session::to_span(envelope.content()); - auto [content_plaintext, sender_ed25519_pubkey] = - session::decrypt_incoming(keys.recipient_ed25519_privkey, content_str); - assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + bool decrypt_success = false; + std::vector content_plaintext; + std::vector sender_ed25519_pubkey; + for (const auto& privkey_it : keys.ed25519_privkeys) { + try { + std::tie(content_plaintext, sender_ed25519_pubkey) = + session::decrypt_incoming(privkey_it, content_str); + assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + decrypt_success = true; + break; + } catch (const std::exception& e) { + } + } + + if (!decrypt_success) { + throw std::runtime_error{fmt::format( + "Envelope content decryption failed, tried {} key(s)", + keys.ed25519_privkeys.size())}; + } result.content_plaintext = std::move(content_plaintext); std::memcpy( @@ -403,16 +421,12 @@ DecryptedEnvelope decrypt_envelope( result.sender_ed25519_pubkey.size()); if (crypto_sign_ed25519_pk_to_curve25519( - result.sender_x25519_pubkey.data(), result.sender_ed25519_pubkey.data()) != 0) + result.sender_x25519_pubkey.data(), result.sender_ed25519_pubkey.data()) != + 0) throw std::runtime_error( - "Parse content failed, ed25519 public key could not be converted to x25519 " + "Parse content failed, ed25519 public key could not be converted to " + "x25519 " "key."); - } else { - result.content_plaintext.resize(envelope.content().size()); - std::memcpy( - result.content_plaintext.data(), - envelope.content().data(), - envelope.content().size()); } // TODO: We parse the content in libsession to extract pro metadata but we return the unparsed @@ -532,9 +546,8 @@ session_protocol_encrypt_for_destination( /*dest_recipient_pubkey=*/dest->recipient_pubkey, /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), /*dest_open_group_inbox_server_pubkey=*/dest->open_group_inbox_server_pubkey, - /*dest_closed_group_pubkey=*/dest->closed_group_pubkey, - /*dest_closed_group_keys=*/ - static_cast(dest->closed_group_keys->internals), + /*dest_closed_group_ed25519_pubkey=*/dest->closed_group_ed25519_pubkey, + /*dest_closed_group_ed25519_privkey=*/dest->closed_group_ed25519_privkey, /*space=*/static_cast(space), /*use_malloc=*/UseMalloc::Yes); @@ -565,22 +578,30 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( return result; std::memcpy(pro_backend_pubkey_cpp.data(), pro_backend_pubkey, pro_backend_pubkey_len); - try { - // Setup decryption keys and decrypt - DecryptEnvelopeKey keys_cpp = { - .use_group_keys = keys->use_group_keys, - .group_keys = - reinterpret_cast(keys->group_keys->internals), - .recipient_ed25519_privkey = { - static_cast(keys->recipient_ed25519_privkey), - keys->recipient_ed25519_privkey_len}}; - - DecryptedEnvelope result_cpp = decrypt_envelope( - keys_cpp, - {static_cast(envelope_plaintext), envelope_plaintext_len}, - std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), - pro_backend_pubkey_cpp); + // Setup decryption keys and decrypt + DecryptEnvelopeKey keys_cpp = {}; + if (keys->group_ed25519_pubkey.size) { + keys_cpp.group_ed25519_pubkey = std::span( + keys->group_ed25519_pubkey.data, keys->group_ed25519_pubkey.size); + } + DecryptedEnvelope result_cpp = {}; + for (size_t index = 0; index < keys->ed25519_privkeys_len; index++) { + std::span key = { + keys->ed25519_privkeys[index].data, keys->ed25519_privkeys[index].size}; + keys_cpp.ed25519_privkeys = {&key, 1}; + try { + result_cpp = decrypt_envelope( + keys_cpp, + {static_cast(envelope_plaintext), envelope_plaintext_len}, + std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), + pro_backend_pubkey_cpp); + break; + } catch (...) { + } + } + + try { // Marshall into c type result = { .success = false, diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 2a1334a2..f9ff4df2 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -171,9 +171,9 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { } // Decrypt envelope + std::span key = keys.ed_sk1; DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = false; - decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + decrypt_keys.ed25519_privkeys = {&key, 1}; DecryptedEnvelope decrypt_result = session::decrypt_envelope( decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); @@ -274,9 +274,9 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { } // Decrypt envelope + std::span key = keys.ed_sk1; DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = false; - decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + decrypt_keys.ed25519_privkeys = {&key, 1}; DecryptedEnvelope decrypt_result = session::decrypt_envelope( decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); @@ -327,9 +327,9 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { } // Decrypt envelope + std::span key = keys.ed_sk1; DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = false; - decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + decrypt_keys.ed25519_privkeys = {&key, 1}; DecryptedEnvelope decrypt_result = session::decrypt_envelope( decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); @@ -374,9 +374,9 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(ws_msg.request().has_body()); // Decrypt envelope + std::span key = keys.ed_sk1; DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = false; - decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + decrypt_keys.ed25519_privkeys = {&key, 1}; DecryptedEnvelope decrypt_result = session::decrypt_envelope( decrypt_keys, to_span(ws_msg.request().body()), timestamp_s, pro_backend_ed_pk); @@ -458,9 +458,9 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { } // Decrypt envelope + std::span key = keys.ed_sk1; DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = false; - decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + decrypt_keys.ed25519_privkeys = {&key, 1}; DecryptedEnvelope decrypt_result = session::decrypt_envelope( decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); @@ -485,16 +485,6 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { pro_backend_ed_pk); REQUIRE(decrypt_result_again.pro_status == ProStatus::Expired); - // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) - DecryptEnvelopeKey bad_decrypt_keys = {}; - bad_decrypt_keys.use_group_keys = false; - bad_decrypt_keys.recipient_ed25519_privkey = keys.ed_sk0; - CHECK_THROWS(session::decrypt_envelope( - bad_decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts, - pro_backend_ed_pk)); - // Try decrypt with a bad backend key array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; bad_pro_backend_ed_pk[0] ^= 1; @@ -504,6 +494,28 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { protobuf_content_with_pro.proof.expiry_unix_ts, bad_pro_backend_ed_pk); REQUIRE(decrypt_result_again.pro_status == ProStatus::InvalidProBackendSig); + + // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) + std::span bad_key = keys.ed_sk0; + DecryptEnvelopeKey bad_decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = {&bad_key, 1}; + REQUIRE_THROWS( + session::decrypt_envelope( + bad_decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts, + pro_backend_ed_pk)); + + // Try decrypt with multiple keys, 1 bad, 1 good key + auto key_list = std::array{bad_key, key}; + DecryptEnvelopeKey multi_decrypt_keys = {}; + multi_decrypt_keys.ed25519_privkeys = key_list; + decrypt_result_again = session::decrypt_envelope( + multi_decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts, + pro_backend_ed_pk); + REQUIRE(decrypt_result_again.pro_status == ProStatus::Valid); } SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { @@ -520,9 +532,9 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(encrypt_result.encrypted); } + std::span key = keys.ed_sk1; DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = false; - decrypt_keys.recipient_ed25519_privkey = keys.ed_sk1; + decrypt_keys.ed25519_privkeys = {&key, 1}; DecryptedEnvelope decrypt_result = session::decrypt_envelope( decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); REQUIRE(decrypt_result.pro_status == ProStatus::InvalidUserSig); From 8d9dd5b4426ad993ba1845d345b115aaf62fed3a Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 18 Aug 2025 21:56:47 +1000 Subject: [PATCH 033/171] Update nomenclamenture, Closed/OpenGroup to Group/Community respectively --- include/session/blinding.h | 10 +-- include/session/config/base.hpp | 2 +- .../session/config/convo_info_volatile.hpp | 4 +- include/session/config/groups/info.hpp | 6 +- include/session/config/groups/keys.h | 2 +- include/session/config/namespaces.h | 4 +- include/session/config/namespaces.hpp | 2 +- include/session/config/user_groups.hpp | 10 +-- include/session/session_encrypt.h | 34 ++++----- include/session/session_encrypt.hpp | 6 +- include/session/session_protocol.h | 14 ++-- include/session/session_protocol.hpp | 34 ++++----- proto/SessionProtos.proto | 4 +- src/config/groups/keys.cpp | 6 +- src/config/internal.hpp | 2 +- src/session_encrypt.cpp | 76 ++++++++++--------- src/session_protocol.cpp | 47 ++++++------ src/util.cpp | 3 +- tests/test_config_convo_info_volatile.cpp | 12 +-- tests/test_config_user_groups.cpp | 14 ++-- tests/test_session_protocol.cpp | 37 +++++---- 21 files changed, 166 insertions(+), 163 deletions(-) diff --git a/include/session/blinding.h b/include/session/blinding.h index e3724883..aa689e35 100644 --- a/include/session/blinding.h +++ b/include/session/blinding.h @@ -15,7 +15,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. @@ -36,7 +36,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. @@ -75,7 +75,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` @@ -97,7 +97,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` @@ -145,7 +145,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: diff --git a/include/session/config/base.hpp b/include/session/config/base.hpp index f1be01f4..64bb7b06 100644 --- a/include/session/config/base.hpp +++ b/include/session/config/base.hpp @@ -944,7 +944,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. diff --git a/include/session/config/convo_info_volatile.hpp b/include/session/config/convo_info_volatile.hpp index 25cece37..3b0f75ee 100644 --- a/include/session/config/convo_info_volatile.hpp +++ b/include/session/config/convo_info_volatile.hpp @@ -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, diff --git a/include/session/config/groups/info.hpp b/include/session/config/groups/info.hpp index 64c2e48f..66c0149c 100644 --- a/include/session/config/groups/info.hpp +++ b/include/session/config/groups/info.hpp @@ -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 @@ -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. /// @@ -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. /// diff --git a/include/session/config/groups/keys.h b/include/session/config/groups/keys.h index fbc34a0d..102436b1 100644 --- a/include/session/config/groups/keys.h +++ b/include/session/config/groups/keys.h @@ -4,9 +4,9 @@ extern "C" { #endif +#include "../../types.h" #include "../base.h" #include "../util.h" -#include "../../types.h" // This is an opaque type analagous to `config_object` but specific to the groups keys object. // diff --git a/include/session/config/namespaces.h b/include/session/config/namespaces.h index ea875195..b9670323 100644 --- a/include/session/config/namespaces.h +++ b/include/session/config/namespaces.h @@ -5,7 +5,7 @@ extern "C" { #endif typedef enum NAMESPACE { - // Messages sent to an updated closed group which should be able to be retrieved by revoked + // 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, @@ -16,7 +16,7 @@ typedef enum NAMESPACE { NAMESPACE_CONVO_INFO_VOLATILE = 4, NAMESPACE_USER_GROUPS = 5, - // Messages sent to a closed group: + // 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) diff --git a/include/session/config/namespaces.hpp b/include/session/config/namespaces.hpp index 680f780a..6945f70a 100644 --- a/include/session/config/namespaces.hpp +++ b/include/session/config/namespaces.hpp @@ -16,7 +16,7 @@ enum class Namespace : std::int16_t { ConvoInfoVolatile = NAMESPACE_CONVO_INFO_VOLATILE, UserGroups = NAMESPACE_USER_GROUPS, - // Messages sent to a closed group: + // 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) diff --git a/include/session/config/user_groups.hpp b/include/session/config/user_groups.hpp index 55febbc9..8a60913b 100644 --- a/include/session/config/user_groups.hpp +++ b/include/session/config/user_groups.hpp @@ -88,8 +88,8 @@ struct base_group_info { notify_mode notifications = notify_mode::defaulted; // When the user wants notifications int64_t mute_until = 0; // unix timestamp (seconds) until which notifications are disabled - std::string name; // human-readable; always set for a legacy closed group, only used before - // joining a new closed group (after joining the group info provide the name) + std::string name; // human-readable; always set for a legacy group, only used before + // joining a new group (after joining the group info provide the name) bool invited = false; // True if this is currently in the invite-but-not-accepted state. @@ -97,7 +97,7 @@ struct base_group_info { void load(const dict& info_dict); }; -/// Struct containing legacy group info (aka "closed groups"). +/// Struct containing legacy group info (aka "groups"). struct legacy_group_info : base_group_info { std::string session_id; // The legacy group "session id" (33 bytes). std::vector enc_pubkey; // bytes (32 or empty) @@ -185,7 +185,7 @@ struct legacy_group_info : base_group_info { constexpr int NOT_REMOVED = 0, KICKED_FROM_GROUP = 1, GROUP_DESTROYED = 2; -/// Struct containing new group info (aka "closed groups v2"). +/// Struct containing new group info (aka "groups v2"). struct group_info : base_group_info { std::string id; // The group pubkey (66 hex digits); this is an ed25519 key, prefixed with "03" // (to distinguish it from a 05 x25519 pubkey session id). @@ -344,7 +344,7 @@ class UserGroups : public ConfigBase { /// API: user_groups/UserGroups::get_group /// - /// Looks up and returns a group (aka new closed group) by group ID (hex, looks like a Session + /// Looks up and returns a group (aka new group) by group ID (hex, looks like a Session /// ID but starting with 03). Returns nullopt if the group was not found, otherwise returns a /// filled out `group_info`. /// diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index eccadc12..758ab857 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -45,7 +45,7 @@ LIBSESSION_EXPORT bool session_encrypt_for_recipient_deterministic( /// - `plaintext_in` -- [in] Pointer to a data buffer containing the encrypted data. /// - `plaintext_len` -- [in] Length of `plaintext_in` /// - `ed25519_privkey` -- [in] the Ed25519 private key of the sender (64 bytes). -/// - `open_group_pubkey` -- [in] the public key of the open group server to route +/// - `community_pubkey` -- [in] the public key of the community server to route /// the blinded message through (32 bytes). /// - `recipient_blinded_id` -- [in] the blinded id of the recipient including the blinding /// prefix (33 bytes), 'blind15' or 'blind25' encryption will be chosed based on this value. @@ -63,7 +63,7 @@ LIBSESSION_EXPORT bool session_encrypt_for_blinded_recipient( const unsigned char* plaintext_in, size_t plaintext_len, const unsigned char* ed25519_privkey, /* 64 bytes */ - const unsigned char* open_group_pubkey, /* 32 bytes */ + const unsigned char* community_pubkey, /* 32 bytes */ const unsigned char* recipient_blinded_id, /* 33 bytes */ unsigned char** ciphertext_out, size_t* ciphertext_len); @@ -104,13 +104,13 @@ typedef struct { /// Outputs: /// - `ciphertext` -- the encrypted, etc. value to send to the swarm LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( - const unsigned char *user_ed25519_privkey, + const unsigned char* user_ed25519_privkey, size_t user_ed25519_privkey_len, - const unsigned char *group_ed25519_pubkey, + const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char *group_ed25519_privkey, + const unsigned char* group_ed25519_privkey, size_t group_ed25519_privkey_len, - const unsigned char *plaintext, + const unsigned char* plaintext, size_t plaintext_len, bool compress, size_t padding); @@ -183,7 +183,7 @@ LIBSESSION_EXPORT bool session_decrypt_incoming_legacy_group( /// - `ciphertext_in` -- [in] Pointer to a data buffer containing the encrypted data. /// - `ciphertext_len` -- [in] Length of `ciphertext_in` /// - `ed25519_privkey` -- [in] the Ed25519 private key of the receiver (64 bytes). -/// - `open_group_pubkey` -- [in] the public key of the open group server to route +/// - `community_pubkey` -- [in] the public key of the community server to route /// the blinded message through (32 bytes). /// - `sender_id` -- [in] the blinded id of the sender including the blinding prefix (33 bytes), /// 'blind15' or 'blind25' decryption will be chosed based on this value. @@ -206,18 +206,18 @@ LIBSESSION_EXPORT bool session_decrypt_incoming_legacy_group( LIBSESSION_EXPORT bool session_decrypt_for_blinded_recipient( const unsigned char* ciphertext_in, size_t ciphertext_len, - const unsigned char* ed25519_privkey, /* 64 bytes */ - const unsigned char* open_group_pubkey, /* 32 bytes */ - const unsigned char* sender_id, /* 33 bytes */ - const unsigned char* recipient_id, /* 33 bytes */ - char* session_id_out, /* 67 byte output buffer */ + const unsigned char* ed25519_privkey, /* 64 bytes */ + const unsigned char* community_pubkey, /* 32 bytes */ + const unsigned char* sender_id, /* 33 bytes */ + const unsigned char* recipient_id, /* 33 bytes */ + char* session_id_out, /* 67 byte output buffer */ unsigned char** plaintext_out, size_t* plaintext_len); typedef struct { bool success; - size_t index; // Index of the key that successfully decrypted the message - char session_id[66]; // In hex + size_t index; // Index of the key that successfully decrypted the message + char session_id[66]; // In hex span_u8 plaintext; } session_decrypt_group_message_result; @@ -241,11 +241,11 @@ typedef struct { /// The struct with the results of decryption. On failure this sets the `success` boolean to false /// and all fields should be ignored except `success`. session_decrypt_group_message_result session_decrypt_group_message( - const span_u8 *decrypt_ed25519_privkey_list, + const span_u8* decrypt_ed25519_privkey_list, size_t decrypt_ed25519_privkey_len, - const unsigned char *group_ed25519_pubkey, + const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char *ciphertext, + const unsigned char* ciphertext, size_t ciphertext_len); /// API: crypto/session_decrypt_ons_response diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index d5e21f48..f3415e09 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -303,7 +303,7 @@ std::pair, std::string> decrypt_incoming_session_id( /// 64-byte /// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey /// from the seed. -/// - `server_pk` -- the public key of the open group server to route the blinded message through +/// - `server_pk` -- the public key of the community server to route the blinded message through /// (32 bytes). /// - `sender_id` -- the blinded id of the sender including the blinding prefix (33 bytes), /// 'blind15' or 'blind25' decryption will be chosed based on this value. @@ -323,8 +323,8 @@ std::pair, std::string> decrypt_from_blinded_recipien std::span ciphertext); struct DecryptGroupMessage { - size_t index; // Index of the key that successfully decrypted the message - std::string session_id; // In hex + size_t index; // Index of the key that successfully decrypted the message + std::string session_id; // In hex std::vector plaintext; }; diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index aaee6ea3..9d504c35 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -54,9 +54,9 @@ enum PRO_STATUS { // See session::ProStatus enum DESTINATION_TYPE { // See session::DestinationType DESTINATION_TYPE_CONTACT, DESTINATION_TYPE_SYNC_MESSAGE, - DESTINATION_TYPE_CLOSED_GROUP, - DESTINATION_TYPE_OPEN_GROUP, - DESTINATION_TYPE_OPEN_GROUP_INBOX, + DESTINATION_TYPE_GROUP, + DESTINATION_TYPE_COMMUNITY, + DESTINATION_TYPE_COMMUNITY_INBOX, }; struct session_protocol_destination { // See session::Destination @@ -68,9 +68,9 @@ struct session_protocol_destination { // See session::Destination uint8_t pro_sig[64]; uint8_t recipient_pubkey[33]; uint64_t sent_timestamp_ms; - uint8_t open_group_inbox_server_pubkey[32]; - uint8_t closed_group_ed25519_pubkey[33]; - uint8_t closed_group_ed25519_privkey[32]; + uint8_t community_inbox_server_pubkey[32]; + uint8_t group_ed25519_pubkey[33]; + uint8_t group_ed25519_privkey[32]; }; enum ENVELOPE_TYPE { @@ -100,7 +100,7 @@ struct session_protocol_envelope { struct session_protocol_decrypt_envelope_keys { span_u8 group_ed25519_pubkey; - const span_u8 *ed25519_privkeys; + const span_u8* ed25519_privkeys; size_t ed25519_privkeys_len; }; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index e56dadcd..50e4532f 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -48,12 +48,12 @@ enum class ProStatus { enum class DestinationType { Contact, SyncMessage, - /// Both legacy and non-legacy closed groups are to be identified as `ClosedGroup`. A non-legacy - /// group is detected by the (0x03) prefix byte on the given `dest_closed_group_pubkey` - /// specified in Destination. - ClosedGroup, - OpenGroup, - OpenGroupInbox, + /// Both legacy and non-legacy groups are to be identified as `Group`. A non-legacy + /// group is detected by the (0x03) prefix byte on the given `dest_group_pubkey` specified in + /// Destination. + Group, + Community, + CommunityInbox, }; struct Destination { @@ -66,23 +66,23 @@ struct Destination { std::optional pro_sig; // Set to the recipient of the message if it requires one. Ignored otherwise (for example - // ignored in OpenGroup) + // ignored in type => Community) array_uc33 recipient_pubkey; // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; - // When type => OpenGroupInbox: set this pubkey to the server's key - array_uc32 open_group_inbox_server_pubkey; + // When type => CommunityInbox: set this pubkey to the server's key + array_uc32 community_inbox_server_pubkey; - // When type => ClosedGroup: set to the group keys for a 0x03 prefix (e.g. groups v2) - // `closed_group_pubkey` to encrypt the message. Public key of the group for groups v2 messages - array_uc33 closed_group_ed25519_pubkey; + // When type => Group: set to the group public keys for a 0x03 prefix (e.g. groups v2) + // `group_pubkey` to encrypt the message for. + array_uc33 group_ed25519_pubkey; - // When type => ClosedGroup: Set the private key of the group for groups v2 messages. Typically + // When type => Group: Set the private key of the group for groups v2 messages. Typically // the latest encryption key for the group, e.g: `Keys::group_enc_key` or // `groups_keys_group_enc_key` - array_uc32 closed_group_ed25519_privkey; + array_uc32 group_ed25519_privkey; }; enum class EnvelopeType { @@ -196,7 +196,7 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) /// /// This function supports all combinatoric combinations of the destination type and namespace /// including returning plaintext if the message is not meant to be encrypted and or wrapping in the -/// additional websocket wrapper or encrypting the envelope with the closed group keys if necessary +/// additional websocket wrapper or encrypting the envelope with the group keys if necessary /// e.t.c. /// /// Calling this function requires filling out the options in the `Destination` struct with the @@ -204,8 +204,8 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) /// annotation on `Destination` for more information. /// /// This function throws if the API is misused (i.e.: A field was not set, but was required to be -/// set for the given destination and namespace. For example the closed group keys not being set -/// when sending to a group prefixed [0x3] key in a closed group into the group message namespace) +/// set for the given destination and namespace. For example the group keys not being set +/// when sending to a group prefixed [0x3] key in a group into the group message namespace) /// but otherwise returns a struct with values. /// /// Inputs: diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 58083a39..a6db5ee1 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -311,11 +311,11 @@ message GroupUpdateMemberChangeMessage { } message GroupUpdateMemberLeftMessage { - // the pubkey of the member left is included as part of the closed group encryption logic (senderIdentity on desktop) + // the pubkey of the member left is included as part of the group encryption logic (senderIdentity on desktop) } message GroupUpdateMemberLeftNotificationMessage { - // the pubkey of the member left is included as part of the closed group encryption logic (senderIdentity on desktop) + // the pubkey of the member left is included as part of the group encryption logic (senderIdentity on desktop) } message GroupUpdateInviteResponseMessage { diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index a2dee3ef..1931326f 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -22,8 +22,8 @@ #include "session/config/groups/keys.h" #include "session/config/groups/members.hpp" #include "session/multi_encrypt.hpp" -#include "session/xed25519.hpp" #include "session/session_encrypt.hpp" +#include "session/xed25519.hpp" using namespace std::literals; @@ -1242,7 +1242,6 @@ std::pair> Keys::decrypt_message( if (!decrypt_success) // none of the keys worked throw std::runtime_error{"unable to decrypt ciphertext with any current group keys"}; - std::pair> result; result.first = std::move(decrypt.session_id); result.second = std::move(decrypt.plaintext); @@ -1363,8 +1362,7 @@ LIBSESSION_C_API const unsigned char* groups_keys_get_key(const config_group_key return keys[N].data(); } -LIBSESSION_C_API const span_u8 groups_keys_group_enc_key(const config_group_keys* conf) -{ +LIBSESSION_C_API const span_u8 groups_keys_group_enc_key(const config_group_keys* conf) { span_u8 result = {}; try { std::span key = unbox(conf).group_enc_key(); diff --git a/src/config/internal.hpp b/src/config/internal.hpp index 8d8908e2..26d02f18 100644 --- a/src/config/internal.hpp +++ b/src/config/internal.hpp @@ -151,7 +151,7 @@ std::string session_id_to_bytes(std::string_view session_id, std::string_view pr std::array session_id_pk( std::string_view session_id, std::string_view prefix = "05"); -// Validates an open group pubkey; we accept it in hex, base32z, or base64 (padded or unpadded). +// Validates a community pubkey; we accept it in hex, base32z, or base64 (padded or unpadded). // Throws std::invalid_argument if invalid. void check_encoded_pubkey(std::string_view pk); diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index dc234d25..54e8c4c6 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -1,6 +1,8 @@ #include "session/session_encrypt.hpp" #include +#include +#include #include #include #include @@ -14,8 +16,6 @@ #include #include #include -#include -#include #include #include @@ -419,7 +419,8 @@ std::vector encrypt_for_group( // add below, but then also validation that this Ed25519 converts to the Session ID of the // claimed sender of the message inside the encoded message data. dict.append( - "a", std::string_view{reinterpret_cast(user_ed25519_privkey.data()) + 32, 32}); + "a", + std::string_view{reinterpret_cast(user_ed25519_privkey.data()) + 32, 32}); if (!compress) dict.append("d", to_string_view(plaintext)); @@ -430,7 +431,10 @@ std::vector encrypt_for_group( // receive it. std::vector to_sign(plaintext.size() + group_ed25519_pubkey.size()); std::memcpy(to_sign.data(), plaintext.data(), plaintext.size()); - std::memcpy(to_sign.data() + plaintext.size(), group_ed25519_pubkey.data(), group_ed25519_pubkey.size()); + std::memcpy( + to_sign.data() + plaintext.size(), + group_ed25519_pubkey.data(), + group_ed25519_pubkey.size()); std::array signature; crypto_sign_ed25519_detached( @@ -704,15 +708,15 @@ DecryptGroupMessage decrypt_group_message( if (decrypt_ed25519_privkey.size() != 32 && decrypt_ed25519_privkey.size() != 64) throw std::invalid_argument{"Invalid decrypt_ed25519_privkey: expected 32 or 64 bytes"}; decrypt_success = 0 == crypto_aead_xchacha20poly1305_ietf_decrypt( - plain.data(), - nullptr, - nullptr, - ciphertext.data(), - ciphertext.size(), - nullptr, - 0, - nonce.data(), - decrypt_ed25519_privkey.data()); + plain.data(), + nullptr, + nullptr, + ciphertext.data(), + ciphertext.size(), + nullptr, + 0, + nonce.data(), + decrypt_ed25519_privkey.data()); if (decrypt_success) { result.index = index; break; @@ -794,7 +798,10 @@ DecryptGroupMessage decrypt_group_message( // in encrypt_message). std::vector to_verify(raw_data.size() + group_ed25519_pubkey.size()); std::memcpy(to_verify.data(), raw_data.data(), raw_data.size()); - std::memcpy(to_verify.data() + raw_data.size(), group_ed25519_pubkey.data(), group_ed25519_pubkey.size()); + std::memcpy( + to_verify.data() + raw_data.size(), + group_ed25519_pubkey.data(), + group_ed25519_pubkey.size()); if (0 != crypto_sign_ed25519_verify_detached( ed_sig.data(), to_verify.data(), to_verify.size(), ed_pk.data())) throw std::runtime_error{"message signature failed validation"}; @@ -1086,14 +1093,14 @@ LIBSESSION_C_API bool session_encrypt_for_blinded_recipient( const unsigned char* plaintext_in, size_t plaintext_len, const unsigned char* ed25519_privkey, - const unsigned char* open_group_pubkey, + const unsigned char* community_pubkey, const unsigned char* recipient_blinded_id, unsigned char** ciphertext_out, size_t* ciphertext_len) { try { auto ciphertext = session::encrypt_for_blinded_recipient( std::span{ed25519_privkey, 64}, - std::span{open_group_pubkey, 32}, + std::span{community_pubkey, 32}, std::span{recipient_blinded_id, 33}, std::span{plaintext_in, plaintext_len}); @@ -1107,17 +1114,16 @@ LIBSESSION_C_API bool session_encrypt_for_blinded_recipient( } LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( - const unsigned char *user_ed25519_privkey, + const unsigned char* user_ed25519_privkey, size_t user_ed25519_privkey_len, - const unsigned char *group_ed25519_pubkey, + const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char *group_ed25519_privkey, + const unsigned char* group_ed25519_privkey, size_t group_ed25519_privkey_len, - const unsigned char *plaintext, + const unsigned char* plaintext, size_t plaintext_len, bool compress, - size_t padding) -{ + size_t padding) { session_encrypt_group_message result = {}; try { std::vector result_cpp = encrypt_for_group( @@ -1128,10 +1134,10 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( compress, padding); result = { - .success = true, - .ciphertext = span_u8_copy_or_throw(result_cpp.data(), result_cpp.size()), + .success = true, + .ciphertext = span_u8_copy_or_throw(result_cpp.data(), result_cpp.size()), }; - } catch(...) { + } catch (...) { } return result; } @@ -1188,7 +1194,7 @@ LIBSESSION_C_API bool session_decrypt_for_blinded_recipient( const unsigned char* ciphertext_in, size_t ciphertext_len, const unsigned char* ed25519_privkey, - const unsigned char* open_group_pubkey, + const unsigned char* community_pubkey, const unsigned char* sender_id, const unsigned char* recipient_id, char* session_id_out, @@ -1197,7 +1203,7 @@ LIBSESSION_C_API bool session_decrypt_for_blinded_recipient( try { auto result = session::decrypt_from_blinded_recipient( std::span{ed25519_privkey, 64}, - std::span{open_group_pubkey, 32}, + std::span{community_pubkey, 32}, std::span{sender_id, 33}, std::span{recipient_id, 33}, std::span{ciphertext_in, ciphertext_len}); @@ -1214,13 +1220,12 @@ LIBSESSION_C_API bool session_decrypt_for_blinded_recipient( } LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_message( - const span_u8 *decrypt_ed25519_privkey_list, + const span_u8* decrypt_ed25519_privkey_list, size_t decrypt_ed25519_privkey_len, - const unsigned char *group_ed25519_pubkey, + const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char *ciphertext, - size_t ciphertext_len) -{ + const unsigned char* ciphertext, + size_t ciphertext_len) { session_decrypt_group_message_result result = {}; for (size_t index = 0; index < decrypt_ed25519_privkey_len; index++) { std::span key = { @@ -1233,9 +1238,10 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess {group_ed25519_pubkey, group_ed25519_pubkey_len}, {ciphertext, ciphertext_len}); result = { - .success = true, - .index = index, - .plaintext = span_u8_copy_or_throw(result.plaintext.data, result.plaintext.size), + .success = true, + .index = index, + .plaintext = + span_u8_copy_or_throw(result.plaintext.data, result.plaintext.size), }; assert(result_cpp.session_id.size() == sizeof(result.session_id)); std::memcpy(result.session_id, result_cpp.session_id.data(), sizeof(result.session_id)); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index bf7d5e1d..03fee24f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -51,17 +51,17 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( std::span dest_pro_sig, std::span dest_recipient_pubkey, std::chrono::milliseconds dest_sent_timestamp_ms, - std::span dest_open_group_inbox_server_pubkey, - std::span dest_closed_group_pubkey, - std::span dest_closed_group_ed25519_privkey, + std::span dest_community_inbox_server_pubkey, + std::span dest_group_pubkey, + std::span dest_group_ed25519_privkey, config::Namespace space, UseMalloc use_malloc) { assert(dest_pro_sig.empty() || dest_pro_sig.size() == crypto_sign_ed25519_BYTES); assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); - assert(dest_open_group_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); - assert(dest_closed_group_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); - assert(dest_closed_group_ed25519_privkey.size() == 32 || dest_closed_group_ed25519_privkey.size() == 64); + assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + assert(dest_group_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); + assert(dest_group_ed25519_privkey.size() == 32 || dest_group_ed25519_privkey.size() == 64); // All incoming arguments are passed in from typed, fixed-sized arrays so we do not need to // throw if these sizes are wrong. It being wrong would be a development error. @@ -78,7 +78,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( Nil, EnvelopeIsCipherText, // No extra bit-mangling required after enveloping WrapInWSMessage, // Wrap in the protobuf websocket message after enveloping - KeysEncryptMessage, // Encrypt with the closed group keys after ennveloping + KeysEncryptMessage, // Encrypt with the group keys after ennveloping }; struct EncodeContext { @@ -101,9 +101,9 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( // Figure out how to encrypt the message based on the destination and setup the encoding context EncodeContext enc = {}; switch (dest_type) { - case DestinationType::ClosedGroup: { + case DestinationType::Group: { bool has_03_prefix = - dest_closed_group_pubkey[0] == static_cast(SessionIDPrefix::group); + dest_group_pubkey[0] == static_cast(SessionIDPrefix::group); if (has_03_prefix) { if (space == config::Namespace::GroupMessages) { enc.mode = Mode::Envelope; @@ -120,13 +120,13 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.mode = Mode::Plaintext; } } else { - // Legacy closed groups which have a 05 prefixed key + // Legacy groups which have a 05 prefixed key enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; - enc.envelope_src = dest_closed_group_pubkey; + enc.envelope_src = dest_group_pubkey; } } break; @@ -151,11 +151,11 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.after_envelope = AfterEnvelope::EnvelopeIsCipherText; } break; - case DestinationType::OpenGroup: { + case DestinationType::Community: { enc.mode = Mode::Plaintext; } break; - case DestinationType::OpenGroupInbox: { + case DestinationType::CommunityInbox: { enc.mode = Mode::EncryptForBlindedRecipient; } break; } @@ -225,8 +225,8 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( std::string bytes = envelope.SerializeAsString(); std::vector ciphertext = encrypt_for_group( ed25519_privkey, - dest_closed_group_pubkey, - dest_closed_group_ed25519_privkey, + dest_group_pubkey, + dest_group_ed25519_privkey, to_span(bytes), /*compress*/ true, /*padding*/ 256); @@ -262,7 +262,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( result.encrypted = true; std::vector ciphertext = encrypt_for_blinded_recipient( ed25519_privkey, - dest_open_group_inbox_server_pubkey, + dest_community_inbox_server_pubkey, dest_recipient_pubkey, // recipient blinded pubkey plaintext); @@ -290,9 +290,9 @@ EncryptedForDestination encrypt_for_destination( /*dest_pro_sig=*/dest.pro_sig ? *dest.pro_sig : std::span(), /*dest_recipient_pubkey=*/dest.recipient_pubkey, /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, - /*dest_open_group_inbox_server_pubkey=*/dest.open_group_inbox_server_pubkey, - /*dest_closed_group_ed25519_pubkey=*/dest.closed_group_ed25519_pubkey, - /*dest_closed_group_ed25519_privkey=*/dest.closed_group_ed25519_privkey, + /*dest_community_inbox_server_pubkey=*/dest.community_inbox_server_pubkey, + /*dest_group_ed25519_pubkey=*/dest.group_ed25519_pubkey, + /*dest_group_ed25519_privkey=*/dest.group_ed25519_privkey, /*space=*/space, /*use_malloc=*/UseMalloc::No); @@ -421,8 +421,7 @@ DecryptedEnvelope decrypt_envelope( result.sender_ed25519_pubkey.size()); if (crypto_sign_ed25519_pk_to_curve25519( - result.sender_x25519_pubkey.data(), result.sender_ed25519_pubkey.data()) != - 0) + result.sender_x25519_pubkey.data(), result.sender_ed25519_pubkey.data()) != 0) throw std::runtime_error( "Parse content failed, ed25519 public key could not be converted to " "x25519 " @@ -545,9 +544,9 @@ session_protocol_encrypt_for_destination( /*dest_pro_sig=*/dest->has_pro_sig ? dest->pro_sig : std::span(), /*dest_recipient_pubkey=*/dest->recipient_pubkey, /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), - /*dest_open_group_inbox_server_pubkey=*/dest->open_group_inbox_server_pubkey, - /*dest_closed_group_ed25519_pubkey=*/dest->closed_group_ed25519_pubkey, - /*dest_closed_group_ed25519_privkey=*/dest->closed_group_ed25519_privkey, + /*dest_community_inbox_server_pubkey=*/dest->community_inbox_server_pubkey, + /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey, + /*dest_group_ed25519_privkey=*/dest->group_ed25519_privkey, /*space=*/static_cast(space), /*use_malloc=*/UseMalloc::Yes); diff --git a/src/util.cpp b/src/util.cpp index 12b5450e..c05c7bdc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,6 +1,7 @@ +#include + #include #include -#include namespace session { diff --git a/tests/test_config_convo_info_volatile.cpp b/tests/test_config_convo_info_volatile.cpp index 11c55bb3..31e88dc6 100644 --- a/tests/test_config_convo_info_volatile.cpp +++ b/tests/test_config_convo_info_volatile.cpp @@ -70,11 +70,11 @@ TEST_CASE("Conversations", "[config][conversations]") { CHECK(convos.needs_push()); CHECK(convos.needs_dump()); - const auto open_group_pubkey = + const auto community_pubkey = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hexbytes; auto og = convos.get_or_construct_community( - "http://Example.ORG:5678", "SudokuRoom", open_group_pubkey); + "http://Example.ORG:5678", "SudokuRoom", community_pubkey); CHECK(og.base_url() == "http://example.org:5678"); // Note: lower-case CHECK(og.room() == "sudokuroom"); // Note: lower-case CHECK(og.pubkey().size() == 32); @@ -145,7 +145,7 @@ TEST_CASE("Conversations", "[config][conversations]") { REQUIRE(x2); CHECK(x2->base_url() == "http://example.org:5678"); CHECK(x2->room() == "sudokuroom"); - CHECK(x2->pubkey_hex() == to_hex(open_group_pubkey)); + CHECK(x2->pubkey_hex() == to_hex(community_pubkey)); CHECK(x2->unread); auto x3 = convos2.get_group(benders_nightmare_group); @@ -352,7 +352,7 @@ TEST_CASE("Conversations (C API)", "[config][conversations][c]") { CHECK(config_needs_push(conf)); CHECK(config_needs_dump(conf)); - const auto open_group_pubkey = + const auto community_pubkey = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hexbytes; convo_info_volatile_community og; @@ -373,7 +373,7 @@ TEST_CASE("Conversations (C API)", "[config][conversations][c]") { CHECK(conf->last_error == "Invalid community URL: room token contains invalid characters"sv); CHECK(convo_info_volatile_get_or_construct_community( - conf, &og, "http://Example.ORG:5678", "SudokuRoom", open_group_pubkey.data())); + conf, &og, "http://Example.ORG:5678", "SudokuRoom", community_pubkey.data())); CHECK(conf->last_error == nullptr); CHECK(og.base_url == "http://example.org:5678"sv); // Note: lower-case CHECK(og.room == "sudokuroom"sv); // Note: lower-case @@ -427,7 +427,7 @@ TEST_CASE("Conversations (C API)", "[config][conversations][c]") { REQUIRE(convo_info_volatile_get_community(conf2, &og, "http://EXAMPLE.org:5678", "sudokuRoom")); CHECK(og.base_url == "http://example.org:5678"sv); CHECK(og.room == "sudokuroom"sv); - CHECK(oxenc::to_hex(og.pubkey, og.pubkey + 32) == to_hex(open_group_pubkey)); + CHECK(oxenc::to_hex(og.pubkey, og.pubkey + 32) == to_hex(community_pubkey)); auto another_id = "051111111111111111111111111111111111111111111111111111111111111111"; convo_info_volatile_1to1 c2; diff --git a/tests/test_config_user_groups.cpp b/tests/test_config_user_groups.cpp index db94916b..dfb5ce33 100644 --- a/tests/test_config_user_groups.cpp +++ b/tests/test_config_user_groups.cpp @@ -164,7 +164,7 @@ TEST_CASE("User Groups", "[config][groups]") { std::array lg_sk; crypto_sign_ed25519_seed_keypair( lg_pk.data(), lg_sk.data(), reinterpret_cast(lgroup_seed.data())); - // Note: this isn't exactly what Session actually does here for legacy closed groups (rather it + // Note: this isn't exactly what Session actually does here for legacy groups (rather it // uses X25519 keys) but for this test the distinction doesn't matter. c.enc_pubkey.assign(lg_pk.data(), lg_pk.data() + lg_pk.size()); c.enc_seckey.assign(lg_sk.data(), lg_sk.data() + 32); @@ -181,11 +181,11 @@ TEST_CASE("User Groups", "[config][groups]") { CHECK(groups.needs_push()); CHECK(groups.needs_dump()); - const auto open_group_pubkey = + const auto community_pubkey = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hexbytes; auto og = groups.get_or_construct_community( - "http://Example.ORG:5678", "SudokuRoom", open_group_pubkey); + "http://Example.ORG:5678", "SudokuRoom", community_pubkey); CHECK(og.base_url() == "http://example.org:5678"); // Note: lower-case CHECK(og.room() == "SudokuRoom"); // Note: case-preserving CHECK(og.room_norm() == "sudokuroom"); @@ -281,7 +281,7 @@ TEST_CASE("User Groups", "[config][groups]") { CHECK(x2->base_url() == "http://example.org:5678"); CHECK(x2->room() == "SudokuRoom"); // Case preserved from the stored value, not the input value CHECK(x2->room_norm() == "sudokuroom"); - CHECK(x2->pubkey_hex() == to_hex(open_group_pubkey)); + CHECK(x2->pubkey_hex() == to_hex(community_pubkey)); CHECK(x2->priority == 14); CHECK_FALSE(g2.needs_push()); @@ -871,17 +871,17 @@ TEST_CASE("User groups mute_until & joined_at are always seconds", "[config][gro } { - const auto open_group_pubkey = + const auto community_pubkey = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hexbytes; const auto url = "http://example.org:5678"; const auto room = "sudoku_room"; - auto comm = c.get_or_construct_community(url, room, open_group_pubkey); + auto comm = c.get_or_construct_community(url, room, community_pubkey); int64_t joined_at = get_timestamp_ms(); int64_t mute_until = get_timestamp_ms(); comm.joined_at = joined_at; comm.mute_until = mute_until; c.set(comm); - auto comm2 = c.get_or_construct_community(url, room, open_group_pubkey); + auto comm2 = c.get_or_construct_community(url, room, community_pubkey); CHECK(comm2.joined_at == joined_at / 1'000); // joined_at was given in milliseconds CHECK(comm2.mute_until == mute_until / 1'000); // mute_until was given in milliseconds c.erase_community(url, room); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index f9ff4df2..b7f596fb 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -221,15 +221,15 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { SECTION("Check non-encryptable messages produce only plaintext") { auto dest_list = { - DestinationType::OpenGroup, - DestinationType::OpenGroupInbox, + DestinationType::Community, + DestinationType::CommunityInbox, DestinationType::Contact}; for (auto dest_type : dest_list) { - if (dest_type == DestinationType::OpenGroup) - INFO("Trying open groups"); - else if (dest_type == DestinationType::OpenGroupInbox) - INFO("Trying open group inbox"); + if (dest_type == DestinationType::Community) + INFO("Trying community"); + else if (dest_type == DestinationType::CommunityInbox) + INFO("Trying community inbox"); else INFO("Trying contacts to non-default namespace"); @@ -239,7 +239,7 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { config::Namespace space = config::Namespace::Default; if (dest_type == DestinationType::Contact) { space = config::Namespace::Contacts; - } else if (dest_type == DestinationType::OpenGroupInbox) { + } else if (dest_type == DestinationType::CommunityInbox) { auto [blind15_pk, blind15_sk] = session::blind15_key_pair( keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); dest.recipient_pubkey[0] = 0x15; @@ -249,7 +249,7 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { EncryptedForDestination encrypt_result = session::encrypt_for_destination( to_span(protobuf_content_with_pro.plaintext), keys.ed_sk0, dest, space); - if (dest_type == DestinationType::OpenGroupInbox) { + if (dest_type == DestinationType::CommunityInbox) { REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.ciphertext.size()); } else { @@ -355,7 +355,7 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { EncryptedForDestination encrypt_result = {}; { Destination dest = base_dest; - dest.type = DestinationType::ClosedGroup; + dest.type = DestinationType::Group; assert(dest.recipient_pubkey[0] == 0x05); encrypt_result = session::encrypt_for_destination( @@ -418,10 +418,10 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { EncryptedForDestination encrypt_result = {}; { Destination dest = base_dest; - dest.type = DestinationType::ClosedGroup; - dest.closed_group_pubkey[0] = 0x03; - std::memcpy(dest.closed_group_pubkey.data() + 1, group_v2_pk.data(), group_v2_pk.size()); - dest.closed_group_keys = &group_v2_keys; + dest.type = DestinationType::Group; + dest.group_pubkey[0] = 0x03; + std::memcpy(dest.group_pubkey.data() + 1, group_v2_pk.data(), group_v2_pk.size()); + dest.group_keys = &group_v2_keys; encrypt_result = session::encrypt_for_destination( to_span(protobuf_content_with_pro.plaintext), @@ -499,12 +499,11 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { std::span bad_key = keys.ed_sk0; DecryptEnvelopeKey bad_decrypt_keys = {}; decrypt_keys.ed25519_privkeys = {&bad_key, 1}; - REQUIRE_THROWS( - session::decrypt_envelope( - bad_decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts, - pro_backend_ed_pk)); + REQUIRE_THROWS(session::decrypt_envelope( + bad_decrypt_keys, + encrypt_result.ciphertext, + protobuf_content_with_pro.proof.expiry_unix_ts, + pro_backend_ed_pk)); // Try decrypt with multiple keys, 1 bad, 1 good key auto key_list = std::array{bad_key, key}; From 0ea3ee3c34316538bd25749796fd8140102b2e5c Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 18 Aug 2025 21:59:55 +1000 Subject: [PATCH 034/171] Add some missing typedefs on C structs --- include/session/config/pro.h | 8 ++++---- include/session/session_encrypt.h | 4 ++-- include/session/session_protocol.h | 32 +++++++++++++++--------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 581797c3..d745b522 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -10,18 +10,18 @@ extern "C" { #include "../export.h" -struct pro_proof { +typedef struct pro_proof { uint8_t version; uint8_t gen_index_hash[32]; uint8_t rotating_pubkey[32]; uint64_t expiry_unix_ts; uint8_t sig[64]; -}; +} pro_proof; -struct pro_pro_config { +typedef struct pro_pro_config { uint8_t rotating_privkey[64]; pro_proof proof; -}; +} pro_pro_config; LIBSESSION_EXPORT pro_proof pro_proof_init(char const* dump, size_t dump_len); diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index 758ab857..2e61da50 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -68,7 +68,7 @@ LIBSESSION_EXPORT bool session_encrypt_for_blinded_recipient( unsigned char** ciphertext_out, size_t* ciphertext_len); -typedef struct { +typedef struct session_encrypt_group_message { bool success; span_u8 ciphertext; } session_encrypt_group_message; @@ -214,7 +214,7 @@ LIBSESSION_EXPORT bool session_decrypt_for_blinded_recipient( unsigned char** plaintext_out, size_t* plaintext_len); -typedef struct { +typedef struct session_decrypt_group_message_result { bool success; size_t index; // Index of the key that successfully decrypted the message char session_id[66]; // In hex diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 9d504c35..06173f20 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -43,23 +43,23 @@ enum PRO_FEATURES_ { PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR }; -enum PRO_STATUS { // See session::ProStatus +typedef enum PRO_STATUS { // See session::ProStatus PRO_STATUS_NIL, PRO_STATUS_INVALID_PRO_BACKEND_SIG, PRO_STATUS_INVALID_USER_SIG, PRO_STATUS_VALID, PRO_STATUS_EXPIRED, -}; +} PRO_STATUS; -enum DESTINATION_TYPE { // See session::DestinationType +typedef enum DESTINATION_TYPE { // See session::DestinationType DESTINATION_TYPE_CONTACT, DESTINATION_TYPE_SYNC_MESSAGE, DESTINATION_TYPE_GROUP, DESTINATION_TYPE_COMMUNITY, DESTINATION_TYPE_COMMUNITY_INBOX, -}; +} DESTINATION_TYPE; -struct session_protocol_destination { // See session::Destination +typedef struct session_protocol_destination { // See session::Destination DESTINATION_TYPE type; // The pro signature is optional, set this flag to true to make the encryption function take @@ -71,12 +71,12 @@ struct session_protocol_destination { // See session::Destination uint8_t community_inbox_server_pubkey[32]; uint8_t group_ed25519_pubkey[33]; uint8_t group_ed25519_privkey[32]; -}; +} session_protocol_destination; -enum ENVELOPE_TYPE { +typedef enum ENVELOPE_TYPE { ENVELOPE_TYPE_SESSION_MESSAGE, ENVELOPE_TYPE_CLOSED_GROUP_MESSGE, -}; +} ENVELOPE_TYPE; // Indicates which optional fields in the envelope has been populated out of the optional fields in // an envelope after it has been parsed off the wire. @@ -88,7 +88,7 @@ enum ENVELOPE_FLAGS_ { ENVELOPE_FLAGS_PRO_SIG = 1 << 3, }; -struct session_protocol_envelope { +typedef struct session_protocol_envelope { ENVELOPE_FLAGS flags; ENVELOPE_TYPE type; uint64_t timestamp_ms; @@ -96,15 +96,15 @@ struct session_protocol_envelope { uint32_t source_device; uint64_t server_timestamp; uint8_t pro_sig[64]; -}; +} session_protocol_envelope; -struct session_protocol_decrypt_envelope_keys { +typedef struct session_protocol_decrypt_envelope_keys { span_u8 group_ed25519_pubkey; const span_u8* ed25519_privkeys; size_t ed25519_privkeys_len; -}; +} session_protocol_decrypt_envelope_keys; -struct session_protocol_decrypted_envelope { +typedef struct session_protocol_decrypted_envelope { // Indicates if the decryption was successful. If the decryption step failed and threw an // exception, this is false. bool success; @@ -115,15 +115,15 @@ struct session_protocol_decrypted_envelope { PRO_STATUS pro_status; pro_proof pro_proof; PRO_FEATURES pro_features; -}; +} session_protocol_decrypted_envelope; -struct session_protocol_encrypted_for_destination { +typedef struct session_protocol_encrypted_for_destination { // Indicates if the decryption was successful. If the decryption step failed and threw an // exception, this is false. bool success; bool encrypted; span_u8 ciphertext; -}; +} session_protocol_encrypted_for_destination; /// API: session_protocol/session_protocol_get_pro_features_for_msg /// From cd5ec265fc7b4e5f936ec1adb68fb3a0bb92488f Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 18 Aug 2025 22:22:42 +1000 Subject: [PATCH 035/171] Document the free-eing requirement on the C interface for session protocol/encrypt --- include/session/session_encrypt.h | 14 +++++-- include/session/session_protocol.h | 55 ++++++++++++++++++++-------- include/session/session_protocol.hpp | 40 +++++++++++++++++--- 3 files changed, 84 insertions(+), 25 deletions(-) diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index 2e61da50..50d99f50 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -102,7 +102,9 @@ typedef struct session_encrypt_group_message { /// use the default of next-multiple-of-256. /// /// Outputs: -/// - `ciphertext` -- the encrypted, etc. value to send to the swarm +/// - `success` -- True if the encryption was successful, false otherwise +/// - `ciphertext` -- the encrypted, etc. value to send to the swarm. This ciphertext must be freed +/// with the CRT's `free` when the caller is done with the memory. LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( const unsigned char* user_ed25519_privkey, size_t user_ed25519_privkey_len, @@ -218,7 +220,7 @@ typedef struct session_decrypt_group_message_result { bool success; size_t index; // Index of the key that successfully decrypted the message char session_id[66]; // In hex - span_u8 plaintext; + span_u8 plaintext; // Decrypted message on success. Must be freed by calling the CRT's `free` } session_decrypt_group_message_result; /// API: crypto/session_decrypt_group_message @@ -238,8 +240,12 @@ typedef struct session_decrypt_group_message_result { /// by `encrypt_message()`. /// /// Outputs: -/// The struct with the results of decryption. On failure this sets the `success` boolean to false -/// and all fields should be ignored except `success`. +/// - `success` -- True if the decryption was successful, false otherwise +/// - `index` -- Index of the key that successfully decrypted the message if decryption was +/// successful. +/// - `session_id` -- The 66 byte 05 prefixed session ID of the user that sent the message +/// - `plaintext` -- Decrypted message if successful. This plaintext must be freed with the CRT's +/// `free` when the caller is done with the memory. session_decrypt_group_message_result session_decrypt_group_message( const span_u8* decrypt_ed25519_privkey_list, size_t decrypt_ed25519_privkey_len, diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 06173f20..46ff6674 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -118,8 +118,8 @@ typedef struct session_protocol_decrypted_envelope { } session_protocol_decrypted_envelope; typedef struct session_protocol_encrypted_for_destination { - // Indicates if the decryption was successful. If the decryption step failed and threw an - // exception, this is false. + // Indicates if the encryption was successful. If any step failed and threw an exception, this + // is false. bool success; bool encrypted; span_u8 ciphertext; @@ -159,16 +159,20 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR /// - `space` -- the namespace to encrypt the message for /// /// Outputs: -/// - The encryption result for the plaintext. If the destination and namespace combination did not -/// require encryption, no payload is returned in the ciphertext and the user should proceed with -/// the plaintext. This should be validated by checking the `encrypted` flag on the result to -/// determine if the ciphertext or plaintext is to be used. +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// are to be ignored in the result on failure. +/// - `encrypted` -- True if any encryption was performed. If the combination of the namespace and +/// destination does not require encryption, this flag is false. In this case, `ciphertext` will +/// not be assigned. The caller should proceed with the `plaintext` they initially passed in. +/// - `ciphertext` -- Encryption result for the plaintext. If the destination and namespace +/// combination did not require encryption, no payload is returned in the ciphertext and the user +/// should proceed with the plaintext. This should be validated by checking the `encrypted` flag +/// on the result to determine if the ciphertext or plaintext is to be used. /// /// The retured payload is suitable for sending on the wire (i.e: it has been protobuf -/// encoded/wrapped if necessary). -/// -/// The success flag is set if encryption was successful, if the underlying implementation threw -/// an exception then this is caught internally and success is set to false. +/// encoded/wrapped if necessary). The ciphertext must be freed with the CRT's `free` when the +/// caller is done with the memory. LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( const void* plaintext, @@ -209,11 +213,32 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// issuer. Ignored if there's no proof in the message. /// /// Outputs: -/// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata -/// within the envelope if there were any. -/// -/// The success flag is set if encryption was successful, if the underlying implementation threw -/// an exception then this is caught internally and success is set to false. +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// in the result are to be ignored on failure. +/// - `envelope` -- Envelope structure that was decrypted/parsed from the `envelope_plaintext` +/// - `content_plaintext` -- Decrypted contents of the envelope structure. This is the protobuf +/// encoded stream that can be parsed into a protobuf `Content` structure. +/// +/// The plaintext must be freed by the CRT's `free` after the caller is done with the memory. +/// - `sender_ed25519_pubkey` -- The sender's ed25519 public key embedded in the encrypted payload. +/// This is only set for session message envelopes. Groups envelopes only embed the sender's +/// x25519 public key in which case this field is set to the zero public key. +/// - `sender_x25519_pubkey` -- The sender's x25519 public key. It's always set on successful +/// decryption either by extracting the key from the encrypted groups envelope, or, by deriving +/// the x25519 key from the sender's ed25519 key in the case of a session message envelope. +/// - `pro_status` -- The pro status associated with the envelope, if any, that the sender has +/// embedded into the envelope being parsed. This field is set to nil if there was no pro metadata +/// associated with the envelope. +/// +/// This field should be used to determine the presence of pro and whether or not the caller +/// can respect the contents of the pro proof and features. A valid pro proof that can be used +/// effectively after parsing is indicated by this value being set to the Valid enum. +/// - `pro_proof` -- The pro proof in the envelope. This field is set to all zeros if `pro_status` +/// was nil, otherwise it's populated with proof data. +/// - `pro_features` -- Pro features that were activated in this envelope by the sender. This field +/// is only set if `pro_status` is not nil. It should only be enforced if the `pro_status` was +/// the Valid enum. LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const session_protocol_decrypt_envelope_keys* keys, diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 50e4532f..70a82932 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -218,10 +218,16 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) /// - `space` -- the namespace to encrypt the message for /// /// Outputs: -/// - The encryption result for the plaintext. If the destination and namespace combination did not -/// require encryption, no payload is returned in the ciphertext and the user should proceed with -/// the plaintext. This should be validated by checking the `encrypted` flag on the result to -/// determine if the ciphertext or plaintext is to be used. +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// are to be ignored in the result on failure. +/// - `encrypted` -- True if any encryption was performed. If the combination of the namespace and +/// destination does not require encryption, this flag is false. In this case, `ciphertext` will +/// not be assigned. The caller should proceed with the `plaintext` they initially passed in. +/// - `ciphertext` -- Encryption result for the plaintext. If the destination and namespace +/// combination did not require encryption, no payload is returned in the ciphertext and the user +/// should proceed with the plaintext. This should be validated by checking the `encrypted` flag +/// on the result to determine if the ciphertext or plaintext is to be used. /// /// The retured payload is suitable for sending on the wire (i.e: it has been protobuf /// encoded/wrapped if necessary). @@ -270,8 +276,30 @@ EncryptedForDestination encrypt_for_destination( /// issuer /// /// Outputs: -/// - The decrypted envelope. It contains the fields of the envelope and the Session Pro metadata -/// within the envelope if there were any. +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// in the result are to be ignored on failure. +/// - `envelope` -- Envelope structure that was decrypted/parsed from the `envelope_plaintext` +/// - `content_plaintext` -- Decrypted contents of the envelope structure. This is the protobuf +/// encoded stream that can be parsed into a protobuf `Content` structure. +/// - `sender_ed25519_pubkey` -- The sender's ed25519 public key embedded in the encrypted payload. +/// This is only set for session message envelopes. Groups envelopes only embed the sender's +/// x25519 public key in which case this field is set to the zero public key. +/// - `sender_x25519_pubkey` -- The sender's x25519 public key. It's always set on successful +/// decryption either by extracting the key from the encrypted groups envelope, or, by deriving +/// the x25519 key from the sender's ed25519 key in the case of a session message envelope. +/// - `pro_status` -- The pro status associated with the envelope, if any, that the sender has +/// embedded into the envelope being parsed. This field is set to nil if there was no pro metadata +/// associated with the envelope. +/// +/// This field should be used to determine the presence of pro and whether or not the caller +/// can respect the contents of the pro proof and features. A valid pro proof that can be used +/// effectively after parsing is indicated by this value being set to the Valid enum. +/// - `pro_proof` -- The pro proof in the envelope. This field is set to all zeros if `pro_status` +/// was nil, otherwise it's populated with proof data. +/// - `pro_features` -- Pro features that were activated in this envelope by the sender. This field +/// is only set if `pro_status` is not nil. It should only be enforced if the `pro_status` was +/// the Valid enum. DecryptedEnvelope decrypt_envelope( const DecryptEnvelopeKey& keys, std::span envelope_payload, From b15ab040db47a398dec08345dfb716808d6d4207 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 18 Aug 2025 22:30:49 +1000 Subject: [PATCH 036/171] We cannot enforce the presence of a pro signature We still require it to be optional whilst old clients are sending envelopes without the signature attached (real or dummy) --- src/session_protocol.cpp | 133 +++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 61 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 03fee24f..03b5144f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -442,75 +442,86 @@ DecryptedEnvelope decrypt_envelope( // envelope indistinguishable. If the message does not have pro then this signature must still // be set but will be ignored. So in all instances a signature must be attached (real or // dummy). - if (!envelope.has_prosig()) - throw std::runtime_error("Parse envelope failed, message is missing pro signature"); - - // Copy (maybe dummy) pro signature into our result struct - const std::string& pro_sig = envelope.prosig(); - if (pro_sig.size() != crypto_sign_ed25519_BYTES) - throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); - static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); - std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); - - if (content.has_promessage()) { - // Mark the envelope as having a pro signature that the caller can use. - result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; - - // Extract the pro message - const SessionProtos::ProMessage& pro_msg = content.promessage(); - if (!pro_msg.has_proof()) - throw std::runtime_error("Parse decrypted message failed, pro config missing proof"); - if (!pro_msg.has_features()) - throw std::runtime_error("Parse decrypted message failed, pro config missing features"); - - // Parse the proof from protobufs - const SessionProtos::ProProof& proto_proof = pro_msg.proof(); - session::config::ProProof& proof = result.pro_proof; - // clang-format off + // + // TODO: However for backwards compatibility, so old client's sending their envelopes to new + // clients won't have the pro signature set. We have to allow these for now until we + // deprecate the supporting of messages from those clients. For forwards compatibility, the new + // clients will send the message with the pro signature attached. The old clients will ignore + // the new fields. + // + // This should be deprecated in about 1-2yrs from this message. 2025-08-18 doyle + if (envelope.has_prosig()) { + // Copy (maybe dummy) pro signature into our result struct + const std::string& pro_sig = envelope.prosig(); + if (pro_sig.size() != crypto_sign_ed25519_BYTES) + throw std::runtime_error("Parse envelope failed, pro signature has wrong size"); + static_assert(sizeof(result.envelope.pro_sig) == crypto_sign_ed25519_BYTES); + std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); + + if (content.has_promessage()) { + // Mark the envelope as having a pro signature that the caller can use. + result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; + + // Extract the pro message + const SessionProtos::ProMessage& pro_msg = content.promessage(); + if (!pro_msg.has_proof()) + throw std::runtime_error( + "Parse decrypted message failed, pro config missing proof"); + if (!pro_msg.has_features()) + throw std::runtime_error( + "Parse decrypted message failed, pro config missing features"); + + // Parse the proof from protobufs + const SessionProtos::ProProof& proto_proof = pro_msg.proof(); + session::config::ProProof& proof = result.pro_proof; + // clang-format off size_t proof_errors = 0; proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); proof_errors += !proto_proof.has_expiryunixts(); proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); - // clang-format on - if (proof_errors) - throw std::runtime_error("Parse decrypted message failed, pro metadata was malformed"); + // clang-format on + if (proof_errors) + throw std::runtime_error( + "Parse decrypted message failed, pro metadata was malformed"); + + // Verify the sig since we have extracted the rotating public key from the embedded + // proof + int verify_result = crypto_sign_ed25519_verify_detached( + reinterpret_cast(pro_sig.data()), + result.content_plaintext.data(), + result.content_plaintext.size(), + reinterpret_cast(proto_proof.rotatingpublickey().data())); + result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; + + // Fill out the resulting proof structure, we have parsed successfully + result.pro_features = pro_msg.features(); + std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); + + std::memcpy( + proof.gen_index_hash.data(), + proto_proof.genindexhash().data(), + proto_proof.genindexhash().size()); + std::memcpy( + proof.rotating_pubkey.data(), + proto_proof.rotatingpublickey().data(), + proto_proof.rotatingpublickey().size()); + proof.expiry_unix_ts = + std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); + std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); - // Verify the sig since we have extracted the rotating public key from the embedded proof - int verify_result = crypto_sign_ed25519_verify_detached( - reinterpret_cast(pro_sig.data()), - result.content_plaintext.data(), - result.content_plaintext.size(), - reinterpret_cast(proto_proof.rotatingpublickey().data())); - result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; - - // Fill out the resulting proof structure, we have parsed successfully - result.pro_features = pro_msg.features(); - std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); - - std::memcpy( - proof.gen_index_hash.data(), - proto_proof.genindexhash().data(), - proto_proof.genindexhash().size()); - std::memcpy( - proof.rotating_pubkey.data(), - proto_proof.rotatingpublickey().data(), - proto_proof.rotatingpublickey().size()); - proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); - std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); - - if (result.pro_status == ProStatus::Valid) { - // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was - // issued by an authoritative backend) - if (!proof.verify(pro_backend_pubkey)) - result.pro_status = ProStatus::InvalidProBackendSig; - - // Check if the proof has expired if (result.pro_status == ProStatus::Valid) { - if (unix_ts > result.pro_proof.expiry_unix_ts) - result.pro_status = ProStatus::Expired; + // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was + // issued by an authoritative backend) + if (!proof.verify(pro_backend_pubkey)) + result.pro_status = ProStatus::InvalidProBackendSig; + + // Check if the proof has expired + if (result.pro_status == ProStatus::Valid) { + if (unix_ts > result.pro_proof.expiry_unix_ts) + result.pro_status = ProStatus::Expired; + } } } } From a261f96ef5b6814edb9bc59012b44cf50e8a7288 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 19 Aug 2025 19:37:52 +1000 Subject: [PATCH 037/171] Don't use assert in test key-gen which breaks in release mode --- tests/utils.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/utils.hpp b/tests/utils.hpp index d02eb009..e03a93b2 100644 --- a/tests/utils.hpp +++ b/tests/utils.hpp @@ -152,7 +152,8 @@ static inline TestKeys get_deterministic_test_keys() { crypto_sign_ed25519_seed_keypair(result.ed_pk0.data(), result.ed_sk0.data(), result.seed0.data()); // X25519 - assert(0 == crypto_sign_ed25519_pk_to_curve25519(result.curve_pk0.data(), result.ed_pk0.data())); + bool converted = crypto_sign_ed25519_pk_to_curve25519(result.curve_pk0.data(), result.ed_pk0.data()); + assert(converted); // Session PK result.session_pk0[0] = 0x05; @@ -169,7 +170,8 @@ static inline TestKeys get_deterministic_test_keys() { crypto_sign_ed25519_seed_keypair(result.ed_pk1.data(), result.ed_sk1.data(), result.seed1.data()); // X25519 - assert(0 == crypto_sign_ed25519_pk_to_curve25519(result.curve_pk1.data(), result.ed_pk1.data())); + bool converted = crypto_sign_ed25519_pk_to_curve25519(result.curve_pk1.data(), result.ed_pk1.data()); + assert(converted); // Session PK result.session_pk1[0] = 0x05; From d5d10d62d9a7d13361fccabad44c374fcbfc70c3 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 19 Aug 2025 20:22:04 +1000 Subject: [PATCH 038/171] Add error logging to C apis --- include/session/config/pro.h | 3 + include/session/session_encrypt.h | 40 +- include/session/session_protocol.h | 40 +- include/session/session_protocol.hpp | 25 +- include/session/types.h | 4 + src/config/pro.cpp | 10 +- src/session_encrypt.cpp | 26 +- src/session_protocol.cpp | 194 ++++---- tests/test_session_encrypt.cpp | 3 +- tests/test_session_protocol.cpp | 678 ++++++++++++++++++++++++++- tests/utils.hpp | 4 +- 11 files changed, 915 insertions(+), 112 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index d745b522..ae1f1eba 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -9,6 +9,7 @@ extern "C" { #include #include "../export.h" +#include "../types.h" typedef struct pro_proof { uint8_t version; @@ -27,6 +28,8 @@ LIBSESSION_EXPORT pro_proof pro_proof_init(char const* dump, size_t dump_len); LIBSESSION_EXPORT pro_pro_config pro_pro_init(char const* dump, size_t dump_len); +LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); + LIBSESSION_EXPORT bool pro_proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey); LIBSESSION_EXPORT bool pro_pro_verify(pro_pro_config const* pro, uint8_t const* verify_pubkey); diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index 50d99f50..2d60541e 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -71,6 +71,7 @@ LIBSESSION_EXPORT bool session_encrypt_for_blinded_recipient( typedef struct session_encrypt_group_message { bool success; span_u8 ciphertext; + size_t error_len_incl_null_terminator; } session_encrypt_group_message; /// API: crypto/session_encrypt_for_group @@ -100,11 +101,26 @@ typedef struct session_encrypt_group_message { /// - `padding` -- the padding multiple: padding will be added as needed to attain a multiple of /// this value for the final result. 0 or 1 disables padding entirely. Normally omitted to /// use the default of next-multiple-of-256. +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned `success` was false, untouched otherwise. If this is set to `NULL`, then on failure, +/// the returned `error_len_incl_null_terminator` is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that `error` is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// `error` is NULL. This function will fill the buffer up to `error_len - 1` characters with the +/// last character reserved for the null-terminator. /// /// Outputs: /// - `success` -- True if the encryption was successful, false otherwise /// - `ciphertext` -- the encrypted, etc. value to send to the swarm. This ciphertext must be freed /// with the CRT's `free` when the caller is done with the memory. +/// - `error_len_incl_null_terminator` The length of the error message if `success` was false. If +/// the user passes in an non-`NULL` error buffer this is amount of characters written to the +/// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( const unsigned char* user_ed25519_privkey, size_t user_ed25519_privkey_len, @@ -115,7 +131,9 @@ LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( const unsigned char* plaintext, size_t plaintext_len, bool compress, - size_t padding); + size_t padding, + char *error, + size_t error_len); /// API: crypto/session_decrypt_incoming /// @@ -221,6 +239,7 @@ typedef struct session_decrypt_group_message_result { size_t index; // Index of the key that successfully decrypted the message char session_id[66]; // In hex span_u8 plaintext; // Decrypted message on success. Must be freed by calling the CRT's `free` + char error_len_incl_null_terminator; } session_decrypt_group_message_result; /// API: crypto/session_decrypt_group_message @@ -238,6 +257,15 @@ typedef struct session_decrypt_group_message_result { /// - `group_ed25519_pubkey` -- the 32 byte public key of the group /// - `ciphertext` -- an encrypted, encoded, signed, (possibly) compressed message as produced /// by `encrypt_message()`. +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned `success` was false, untouched otherwise. If this is set to `NULL`, then on failure, +/// the returned `error_len_incl_null_terminator` is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that `error` is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// `error` is NULL. This function will fill the buffer up to `error_len - 1` characters with the +/// last character reserved for the null-terminator. /// /// Outputs: /// - `success` -- True if the decryption was successful, false otherwise @@ -246,13 +274,21 @@ typedef struct session_decrypt_group_message_result { /// - `session_id` -- The 66 byte 05 prefixed session ID of the user that sent the message /// - `plaintext` -- Decrypted message if successful. This plaintext must be freed with the CRT's /// `free` when the caller is done with the memory. +/// - `error_len_incl_null_terminator` The length of the error message if `success` was false. If +/// the user passes in an non-`NULL` error buffer this is amount of characters written to the +/// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. session_decrypt_group_message_result session_decrypt_group_message( const span_u8* decrypt_ed25519_privkey_list, size_t decrypt_ed25519_privkey_len, const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, const unsigned char* ciphertext, - size_t ciphertext_len); + size_t ciphertext_len, + char *error, + size_t error_len); /// API: crypto/session_decrypt_ons_response /// diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 46ff6674..52419079 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -115,6 +115,7 @@ typedef struct session_protocol_decrypted_envelope { PRO_STATUS pro_status; pro_proof pro_proof; PRO_FEATURES pro_features; + size_t error_len_incl_null_terminator; } session_protocol_decrypted_envelope; typedef struct session_protocol_encrypted_for_destination { @@ -123,6 +124,7 @@ typedef struct session_protocol_encrypted_for_destination { bool success; bool encrypted; span_u8 ciphertext; + size_t error_len_incl_null_terminator; } session_protocol_encrypted_for_destination; /// API: session_protocol/session_protocol_get_pro_features_for_msg @@ -157,6 +159,15 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR /// - `dest` -- the extra metadata indicating the destination of the message and the necessary data /// to encrypt a message for that destination. /// - `space` -- the namespace to encrypt the message for +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned `success` was false, untouched otherwise. If this is set to `NULL`, then on failure, +/// the returned `error_len_incl_null_terminator` is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that `error` is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// `error` is NULL. This function will fill the buffer up to `error_len - 1` characters with the +/// last character reserved for the null-terminator. /// /// Outputs: /// - `success` -- True if encryption was successful, if the underlying implementation threw @@ -173,6 +184,12 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR /// The retured payload is suitable for sending on the wire (i.e: it has been protobuf /// encoded/wrapped if necessary). The ciphertext must be freed with the CRT's `free` when the /// caller is done with the memory. +/// - `error_len_incl_null_terminator` The length of the error message if `success` was false. If +/// the user passes in an non-`NULL` error buffer this is amount of characters written to the +/// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. LIBSESSION_EXPORT session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( const void* plaintext, @@ -180,7 +197,9 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, - NAMESPACE space); + NAMESPACE space, + char* error, + size_t error_len); /// API: session_protocol/session_protocol_decrypt_envelope /// @@ -211,6 +230,15 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in /// the proof, validating whether or not the attached proof was indeed issued by an authorised /// issuer. Ignored if there's no proof in the message. +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned `success` was false, untouched otherwise. If this is set to `NULL`, then on failure, +/// the returned `error_len_incl_null_terminator` is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that `error` is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// `error` is NULL. This function will fill the buffer up to `error_len - 1` characters with the +/// last character reserved for the null-terminator. /// /// Outputs: /// - `success` -- True if encryption was successful, if the underlying implementation threw @@ -239,6 +267,12 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// - `pro_features` -- Pro features that were activated in this envelope by the sender. This field /// is only set if `pro_status` is not nil. It should only be enforced if the `pro_status` was /// the Valid enum. +/// - `error_len_incl_null_terminator` The length of the error message if `success` was false. If +/// the user passes in an non-`NULL` error buffer this is amount of characters written to the +/// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. LIBSESSION_EXPORT session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const session_protocol_decrypt_envelope_keys* keys, @@ -246,7 +280,9 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( size_t envelope_plaintext_len, uint64_t unix_ts, const void* pro_backend_pubkey, - size_t pro_backend_pubkey_len); + size_t pro_backend_pubkey_len, + char* error, + size_t error_len); #ifdef __cplusplus } diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 70a82932..ed75d12c 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -38,22 +38,27 @@ namespace config::groups { } enum class ProStatus { - Nil, // Proof not set - InvalidProBackendSig, // Proof set; pro proof sig was not produced by the Pro backend key - InvalidUserSig, // Proof set; envelope pro sig was not produced by the Rotating key - Valid, // Proof set, is verified; has not expired - Expired, // Proof set, is verified; has expired + // Proof not set + Nil = PRO_STATUS_NIL, + // Proof set; pro proof sig was not produced by the Pro backend key + InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, + // Proof set; envelope pro sig was not produced by the Rotating key + InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, + // Proof set, is verified; has not expired + Valid = PRO_STATUS_VALID, + // Proof set, is verified; has expired + Expired = PRO_STATUS_EXPIRED, }; enum class DestinationType { - Contact, - SyncMessage, + Contact = DESTINATION_TYPE_CONTACT, + SyncMessage = DESTINATION_TYPE_SYNC_MESSAGE, /// Both legacy and non-legacy groups are to be identified as `Group`. A non-legacy /// group is detected by the (0x03) prefix byte on the given `dest_group_pubkey` specified in /// Destination. - Group, - Community, - CommunityInbox, + Group = DESTINATION_TYPE_GROUP, + Community = DESTINATION_TYPE_COMMUNITY, + CommunityInbox = DESTINATION_TYPE_COMMUNITY_INBOX, }; struct Destination { diff --git a/include/session/types.h b/include/session/types.h index db1db396..e5cfba32 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -13,6 +13,10 @@ struct span_u8 { size_t size; }; +struct bytes32 { + uint8_t data[32]; +}; + /// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this /// function throws a runtime exception. The `data` pointer is span must be freed once the span /// is no longer needed. diff --git a/src/config/pro.cpp b/src/config/pro.cpp index ec2ef9f1..d2cfa4fa 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -56,7 +56,7 @@ bool pro_verify_internal( return false; session::array_uc32 rederived_pk; - [[maybe_unused]] session::cleared_uc32 rederived_sk; + [[maybe_unused]] session::cleared_uc64 rederived_sk; crypto_sign_ed25519_seed_keypair( rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); @@ -156,6 +156,14 @@ static_assert((sizeof((pro_proof*)0)->gen_index_hash) == 32); static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); +LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { + session::array_uc32 hash = proof_hash_internal( + proof->version, proof->gen_index_hash, proof->rotating_pubkey, proof->expiry_unix_ts); + bytes32 result = {}; + std::memcpy(result.data, hash.data(), hash.size()); + return result; +} + LIBSESSION_C_API bool pro_proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey) { auto verify_pubkey_span = std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 54e8c4c6..dd715127 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -552,12 +552,13 @@ std::pair, std::vector> decrypt_incomi auto& [buf, sender_ed_pk] = result; buf.resize(outer_size); - if (0 != crypto_box_seal_open( + int opened = crypto_box_seal_open( buf.data(), ciphertext.data(), ciphertext.size(), x25519_pubkey.data(), - x25519_seckey.data())) + x25519_seckey.data()); + if (opened != 0) throw std::runtime_error{"Decryption failed"}; uc64 sig; @@ -1123,7 +1124,9 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( const unsigned char* plaintext, size_t plaintext_len, bool compress, - size_t padding) { + size_t padding, + char *error, + size_t error_len) { session_encrypt_group_message result = {}; try { std::vector result_cpp = encrypt_for_group( @@ -1137,7 +1140,11 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( .success = true, .ciphertext = span_u8_copy_or_throw(result_cpp.data(), result_cpp.size()), }; - } catch (...) { + } catch (const std::exception& e) { + std::string error_cpp = e.what(); + result.error_len_incl_null_terminator = + std::snprintf(error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + + 1; } return result; } @@ -1225,7 +1232,9 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, const unsigned char* ciphertext, - size_t ciphertext_len) { + size_t ciphertext_len, + char *error, + size_t error_len) { session_decrypt_group_message_result result = {}; for (size_t index = 0; index < decrypt_ed25519_privkey_len; index++) { std::span key = { @@ -1246,7 +1255,12 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess assert(result_cpp.session_id.size() == sizeof(result.session_id)); std::memcpy(result.session_id, result_cpp.session_id.data(), sizeof(result.session_id)); break; - } catch (...) { + } catch (const std::exception& e) { + std::string error_cpp = e.what(); + result.error_len_incl_null_terminator = + std::snprintf( + error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + + 1; } } return result; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 03b5144f..bdeb1023 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -211,14 +211,16 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( req_msg->set_body(envelope.SerializeAsString()); // Write message as ciphertext + [[maybe_unused]] bool serialized = false; if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); - msg.SerializeToArray(result.ciphertext_c.data, result.ciphertext_c.size); + result.ciphertext_c = span_u8_alloc_or_throw(msg.ByteSizeLong()); + serialized = msg.SerializeToArray(result.ciphertext_c.data, result.ciphertext_c.size); } else { result.ciphertext_cpp.resize(msg.ByteSizeLong()); - msg.SerializeToArray( + serialized = msg.SerializeToArray( result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); } + assert(serialized); } break; case AfterEnvelope::KeysEncryptMessage: { @@ -240,15 +242,17 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } break; case AfterEnvelope::EnvelopeIsCipherText: { + [[maybe_unused]] bool serialized = false; if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); - envelope.SerializeToArray( + serialized = envelope.SerializeToArray( result.ciphertext_c.data, result.ciphertext_c.size); } else { result.ciphertext_cpp.resize(envelope.ByteSizeLong()); - envelope.SerializeToArray( + serialized = envelope.SerializeToArray( result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); } + assert(serialized); } break; } @@ -393,18 +397,18 @@ DecryptedEnvelope decrypt_envelope( envelope.content().data(), envelope.content().size()); } else { - std::span content_str = session::to_span(envelope.content()); + const std::string& content = envelope.content(); bool decrypt_success = false; std::vector content_plaintext; std::vector sender_ed25519_pubkey; for (const auto& privkey_it : keys.ed25519_privkeys) { try { std::tie(content_plaintext, sender_ed25519_pubkey) = - session::decrypt_incoming(privkey_it, content_str); + session::decrypt_incoming(privkey_it, to_span(content)); assert(result.sender_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); decrypt_success = true; break; - } catch (const std::exception& e) { + } catch (...) { } } @@ -475,12 +479,12 @@ DecryptedEnvelope decrypt_envelope( const SessionProtos::ProProof& proto_proof = pro_msg.proof(); session::config::ProProof& proof = result.pro_proof; // clang-format off - size_t proof_errors = 0; - proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); - proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); - proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); - proof_errors += !proto_proof.has_expiryunixts(); - proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); + size_t proof_errors = 0; + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); + proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); + proof_errors += !proto_proof.has_expiryunixts(); + proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); // clang-format on if (proof_errors) throw std::runtime_error( @@ -531,20 +535,22 @@ DecryptedEnvelope decrypt_envelope( using namespace session; -LIBSESSION_EXPORT +LIBSESSION_C_API PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) { PRO_FEATURES result = get_pro_features_for_msg(msg_size, flags); return result; } -LIBSESSION_EXPORT session_protocol_encrypted_for_destination +LIBSESSION_C_API session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, - NAMESPACE space) { + NAMESPACE space, + char* error, + size_t error_len) { session_protocol_encrypted_for_destination result = {}; try { EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( @@ -566,20 +572,30 @@ session_protocol_encrypt_for_destination( .encrypted = result_internal.encrypted, .ciphertext = result_internal.ciphertext_c, }; - } catch (...) { + } catch (const std::exception& e) { + std::string error_cpp = e.what(); + result.error_len_incl_null_terminator = std::snprintf( + error, + error_len, + "%.*s", + static_cast(error_cpp.size()), + error_cpp.data()) + + 1; } return result; } -LIBSESSION_EXPORT +LIBSESSION_C_API session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const session_protocol_decrypt_envelope_keys* keys, const void* envelope_plaintext, size_t envelope_plaintext_len, uint64_t unix_ts, const void* pro_backend_pubkey, - size_t pro_backend_pubkey_len) { + size_t pro_backend_pubkey_len, + char* error, + size_t error_len) { session_protocol_decrypted_envelope result = {}; // Setup the pro backend pubkey @@ -606,77 +622,85 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( {static_cast(envelope_plaintext), envelope_plaintext_len}, std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), pro_backend_pubkey_cpp); + result.success = true; break; - } catch (...) { + } catch (const std::exception& e) { + std::string error_cpp = e.what(); + result.error_len_incl_null_terminator = std::snprintf( + error, + error_len, + "%.*s", + static_cast(error_cpp.size()), + error_cpp.data()) + + 1; } } - try { - // Marshall into c type - result = { - .success = false, - .envelope = - { - .flags = result_cpp.envelope.flags, - .type = static_cast(result_cpp.envelope.type), - .timestamp_ms = static_cast( - result_cpp.envelope.timestamp.count()), - .source = {}, - .source_device = result_cpp.envelope.source_device, - .server_timestamp = result_cpp.envelope.server_timestamp, - .pro_sig = {}, - }, - .content_plaintext = span_u8_copy_or_throw( - result_cpp.content_plaintext.data(), result_cpp.content_plaintext.size()), - .sender_ed25519_pubkey = {}, - .sender_x25519_pubkey = {}, - .pro_status = static_cast(result_cpp.pro_status), - .pro_proof = - { - .version = result_cpp.pro_proof.version, - .gen_index_hash = {}, - .rotating_pubkey = {}, - .expiry_unix_ts = static_cast( - result_cpp.pro_proof.expiry_unix_ts.time_since_epoch() - .count()), - .sig = {}, - }, - .pro_features = result_cpp.pro_features}; - - std::memcpy( - result.envelope.source, - result_cpp.envelope.source.data(), - sizeof(result.envelope.source)); - std::memcpy( - result.envelope.pro_sig, - result_cpp.envelope.pro_sig.data(), - sizeof(result.envelope.pro_sig)); - - std::memcpy( - result.sender_ed25519_pubkey, - result_cpp.sender_ed25519_pubkey.data(), - sizeof(result.sender_ed25519_pubkey)); - std::memcpy( - result.sender_x25519_pubkey, - result_cpp.sender_x25519_pubkey.data(), - sizeof(result.sender_x25519_pubkey)); - - std::memcpy( - result.pro_proof.gen_index_hash, - result_cpp.pro_proof.gen_index_hash.data(), - sizeof(result.pro_proof.gen_index_hash)); - std::memcpy( - result.pro_proof.rotating_pubkey, - result_cpp.pro_proof.rotating_pubkey.data(), - sizeof(result.pro_proof.rotating_pubkey)); - std::memcpy( - result.pro_proof.sig, - result_cpp.pro_proof.sig.data(), - sizeof(result.pro_proof.sig)); + if (keys->ed25519_privkeys_len == 0) { + result.error_len_incl_null_terminator = + std::snprintf(error, error_len, "No keys ed25519_privkeys were provided") + 1; + } - result.success = true; - } catch (...) { + // Marshall into c type + try { + result.content_plaintext = span_u8_copy_or_throw( + result_cpp.content_plaintext.data(), result_cpp.content_plaintext.size()); + } catch (const std::exception& e) { + std::string error_cpp = e.what(); + result.success = false; + result.error_len_incl_null_terminator = std::snprintf( + error, + error_len, + "%.*s", + static_cast(error_cpp.size()), + error_cpp.data()) + + 1; } + result.envelope.flags = result_cpp.envelope.flags; + result.envelope.type = static_cast(result_cpp.envelope.type); + result.envelope.timestamp_ms = static_cast(result_cpp.envelope.timestamp.count()); + result.envelope.source_device = result_cpp.envelope.source_device; + result.envelope.server_timestamp = result_cpp.envelope.server_timestamp; + result.pro_status = static_cast(result_cpp.pro_status); + result.pro_proof.version = result_cpp.pro_proof.version; + result.pro_proof.expiry_unix_ts = + static_cast(result_cpp.pro_proof.expiry_unix_ts.time_since_epoch().count()); + result.pro_features = result_cpp.pro_features; + + // Since we support multiple keys, if some of the keys failed but one of them succeeded, we will + // zero out the error buffer to avoid conflating one of the failures with the function actually + // succeeding. + if (result.success) + result.error_len_incl_null_terminator = 0; + + std::memcpy( + result.envelope.source, + result_cpp.envelope.source.data(), + sizeof(result.envelope.source)); + std::memcpy( + result.envelope.pro_sig, + result_cpp.envelope.pro_sig.data(), + sizeof(result.envelope.pro_sig)); + + std::memcpy( + result.sender_ed25519_pubkey, + result_cpp.sender_ed25519_pubkey.data(), + sizeof(result.sender_ed25519_pubkey)); + std::memcpy( + result.sender_x25519_pubkey, + result_cpp.sender_x25519_pubkey.data(), + sizeof(result.sender_x25519_pubkey)); + + std::memcpy( + result.pro_proof.gen_index_hash, + result_cpp.pro_proof.gen_index_hash.data(), + sizeof(result.pro_proof.gen_index_hash)); + std::memcpy( + result.pro_proof.rotating_pubkey, + result_cpp.pro_proof.rotating_pubkey.data(), + sizeof(result.pro_proof.rotating_pubkey)); + std::memcpy( + result.pro_proof.sig, result_cpp.pro_proof.sig.data(), sizeof(result.pro_proof.sig)); return result; } diff --git a/tests/test_session_encrypt.cpp b/tests/test_session_encrypt.cpp index 41efa1ff..70514b11 100644 --- a/tests/test_session_encrypt.cpp +++ b/tests/test_session_encrypt.cpp @@ -103,8 +103,7 @@ TEST_CASE("Session protocol deterministic encryption", "[session-protocol][encry std::vector sid_raw; oxenc::from_hex(sid.begin(), sid.end(), std::back_inserter(sid_raw)); REQUIRE(sid == "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"); - REQUIRE(sid_raw == - "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"_hexbytes); + REQUIRE(sid_raw == "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"_hexbytes); const auto seed2 = "00112233445566778899aabbccddeeff00000000000000000000000000000000"_hexbytes; std::array ed_pk2, curve_pk2; diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index b7f596fb..d87eb66b 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -114,7 +114,6 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { SECTION("Encrypt with and w/o pro sig produce same payload size") { // Same payload size because the encrypt function should put in a dummy signature if one // wasn't specific to make pro and non-pro envelopes indistinguishable. - session::Destination dest = {}; dest.type = DestinationType::Contact; dest.sent_timestamp_ms = timestamp_ms; @@ -498,7 +497,7 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) std::span bad_key = keys.ed_sk0; DecryptEnvelopeKey bad_decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&bad_key, 1}; + bad_decrypt_keys.ed25519_privkeys = {&bad_key, 1}; REQUIRE_THROWS(session::decrypt_envelope( bad_decrypt_keys, encrypt_result.ciphertext, @@ -539,3 +538,678 @@ TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { REQUIRE(decrypt_result.pro_status == ProStatus::InvalidUserSig); } } + +TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { + + // Do tests that require no setup + SECTION("Ensure get pro fetaures detects large message") { + // Try a message below the size threshold + PRO_FEATURES features = session_protocol_get_pro_features_for_msg( + PRO_STANDARD_CHARACTER_LIMIT, + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); + + // Try a message exceeding the size threshold + features = session_protocol_get_pro_features_for_msg( + PRO_STANDARD_CHARACTER_LIMIT + 1, + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | + PRO_FEATURES_ANIMATED_AVATAR)); + + // Try asking for just one extra feature + features = session_protocol_get_pro_features_for_msg(100, PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(features == PRO_FEATURES_PRO_BADGE); + } + + // Tests that require some setup code + using namespace session; + TestKeys keys = get_deterministic_test_keys(); + + // Tuesday, 12 August 2025 03:58:21 UTC + const std::chrono::milliseconds timestamp_ms = std::chrono::seconds(1754971101); + const std::chrono::sys_seconds timestamp_s = std::chrono::sys_seconds( + std::chrono::duration_cast(timestamp_ms)); + const std::string_view data_body = "hello"; + + SECTION("Encrypt with and w/o pro sig produce same payload size") { + // Same payload size because the encrypt function should put in a dummy signature if one + // wasn't specific to make pro and non-pro envelopes indistinguishable. + + session_protocol_destination dest = {}; + dest.type = DESTINATION_TYPE_CONTACT; + dest.sent_timestamp_ms = timestamp_ms.count(); + std::memcpy(dest.recipient_pubkey, keys.session_pk1.data(), sizeof(dest.recipient_pubkey)); + + // Withhold the pro signature + dest.has_pro_sig = false; + char error[256]; + session_protocol_encrypted_for_destination encrypt_without_pro_sig = + session_protocol_encrypt_for_destination( + data_body.data(), + data_body.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + INFO(error); + REQUIRE(encrypt_without_pro_sig.error_len_incl_null_terminator == 0); + + // Set the pro signature + dest.has_pro_sig = true; + session_protocol_encrypted_for_destination encrypt_with_pro_sig = + session_protocol_encrypt_for_destination( + data_body.data(), + data_body.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_with_pro_sig.error_len_incl_null_terminator == 0); + + REQUIRE(encrypt_without_pro_sig.encrypted); + REQUIRE(encrypt_with_pro_sig.encrypted); + + // Should have the same payload size + REQUIRE(encrypt_without_pro_sig.ciphertext.size == encrypt_with_pro_sig.ciphertext.size); + free(encrypt_without_pro_sig.ciphertext.data); + free(encrypt_with_pro_sig.ciphertext.data); + } + + // Setup a dummy "Session Pro Backend" key + // We reuse test key 1 as the "Session Pro" backend key that signs the proofs as it + // doesn't matter what key really, just that we have one available for signing. + const array_uc64& pro_backend_ed_sk = keys.ed_sk1; + const array_uc32& pro_backend_ed_pk = keys.ed_pk1; + char error[256]; + + SECTION("Encrypt/decrypt for contact in default namespace w/o pro attached") { + // Build content without pro attached + std::string plaintext; + { + SessionProtos::Content content = {}; + SessionProtos::DataMessage* data = content.mutable_datamessage(); + data->set_body(std::string(data_body)); + plaintext = content.SerializeAsString(); + REQUIRE(plaintext.size() > data_body.size()); + } + + // Encrypt + session_protocol_encrypted_for_destination encrypt_result = {}; + { + session_protocol_destination dest = {}; + dest.type = DESTINATION_TYPE_CONTACT; + dest.sent_timestamp_ms = timestamp_ms.count(); + REQUIRE(sizeof(dest.recipient_pubkey) == keys.session_pk1.size()); + std::memcpy(dest.recipient_pubkey, keys.session_pk1.data(), keys.session_pk1.size()); + + encrypt_result = session_protocol_encrypt_for_destination( + plaintext.data(), + plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + } + + // Decrypt envelope + span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(),error, sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + free(encrypt_result.ciphertext.data); + + // Verify pro + config::ProProof nil_proof = {}; + array_uc32 nil_hash = nil_proof.hash(); + bytes32 decrypt_result_pro_hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(decrypt_result.pro_status == PRO_STATUS_NIL); // Pro was not attached + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); + REQUIRE(std::memcmp( + decrypt_result_pro_hash.data, + nil_hash.data(), + sizeof(decrypt_result_pro_hash.data)) == 0); + + // Verify it is decryptable + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data, decrypt_result.content_plaintext.size)); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + free(decrypt_result.content_plaintext.data); + } + + // Generate the user's Session Pro rotating key for testing encrypted payloads with Session + // Pro metadata + const auto user_pro_seed = + "0123456789abcdef0123456789abcdeff00baa00000000000000000000000000"_hexbytes; + array_uc32 user_pro_ed_pk; + array_uc64 user_pro_ed_sk; + crypto_sign_ed25519_seed_keypair( + user_pro_ed_pk.data(), user_pro_ed_sk.data(), user_pro_seed.data()); + + // Build protobuf `Content` message, serialise to `plaintext` and get it signed by the user's + // "Session Pro" key into `sig_over_plaintext_with_user_pro_key` + SerialisedProtobufContentWithProForTesting protobuf_content_with_pro = + build_protobuf_content_with_session_pro( + /*data_body*/ data_body, + /*user_rotating_privkey*/ user_pro_ed_sk, + /*pro_backend_privkey*/ pro_backend_ed_sk, + /*pro_expiry_unix_ts*/ timestamp_s, + PRO_FEATURES_NIL); + + // Setup base destination object with the pro signature w/ Session pubkey 1 as the recipient + session_protocol_destination base_dest = {}; + base_dest.sent_timestamp_ms = timestamp_ms.count(); + base_dest.has_pro_sig = true; + std::memcpy( + base_dest.pro_sig, + protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.data(), + sizeof(base_dest.pro_sig)); + + REQUIRE(sizeof(base_dest.recipient_pubkey) == keys.session_pk1.size()); + std::memcpy(base_dest.recipient_pubkey, keys.session_pk1.data(), keys.session_pk1.size()); + + SECTION("Check non-encryptable messages produce only plaintext") { + auto dest_list = { + DESTINATION_TYPE_COMMUNITY, + DESTINATION_TYPE_COMMUNITY_INBOX, + DESTINATION_TYPE_CONTACT}; + + for (auto dest_type : dest_list) { + if (dest_type == DESTINATION_TYPE_COMMUNITY) + INFO("Trying community"); + else if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) + INFO("Trying community inbox"); + else + INFO("Trying contacts to non-default namespace"); + + session_protocol_destination dest = base_dest; + dest.type = dest_type; + + NAMESPACE space = NAMESPACE_DEFAULT; + if (dest_type == DESTINATION_TYPE_CONTACT) { + space = NAMESPACE_CONTACTS; + } else if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { + auto [blind15_pk, blind15_sk] = session::blind15_key_pair( + keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); + dest.recipient_pubkey[0] = 0x15; + std::memcpy(dest.recipient_pubkey + 1, blind15_pk.data(), blind15_pk.size()); + } + + session_protocol_encrypted_for_destination encrypt_result = + session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + space, + error, + sizeof(error)); + + if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.ciphertext.size > 0); + } else { + REQUIRE_FALSE(encrypt_result.encrypted); + REQUIRE(encrypt_result.ciphertext.size == 0); + } + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + free(encrypt_result.ciphertext.data); + } + } + + SECTION("Encrypt/decrypt for contact in default namespace with Pro") { + // Encrypt content + session_protocol_encrypted_for_destination encrypt_result = {}; + { + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_CONTACT; + encrypt_result = session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + } + + // Decrypt envelope + span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + free(encrypt_result.ciphertext.data); + + // Verify pro + REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached + bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(std::memcmp( + hash.data, + protobuf_content_with_pro.pro_proof_hash.data(), + sizeof(hash.data)) == 0); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + + // Verify the content can be parsed w/ protobufs + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data, decrypt_result.content_plaintext.size)); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + free(decrypt_result.content_plaintext.data); + } + + SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { + + std::string large_message; + large_message.resize(PRO_STANDARD_CHARACTER_LIMIT + 1); + + PRO_FEATURES features = + get_pro_features_for_msg(large_message.size(), PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); + + SerialisedProtobufContentWithProForTesting protobuf_content_with_pro_and_features = + build_protobuf_content_with_session_pro( + /*data_body*/ large_message, + /*user_rotating_privkey*/ user_pro_ed_sk, + /*pro_backend_privkey*/ pro_backend_ed_sk, + /*pro_expiry_unix_ts*/ timestamp_s, + features); + + // Encrypt content + session_protocol_encrypted_for_destination encrypt_result = {}; + { + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_CONTACT; + std::memcpy( + dest.pro_sig, + protobuf_content_with_pro_and_features.sig_over_plaintext_with_user_pro_key + .data(), + sizeof(dest.pro_sig)); + + encrypt_result = session_protocol_encrypt_for_destination( + protobuf_content_with_pro_and_features.plaintext.data(), + protobuf_content_with_pro_and_features.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + } + + // Decrypt envelope + span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + free(encrypt_result.ciphertext.data); + + // Verify pro + REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached + bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(std::memcmp( + hash.data, + protobuf_content_with_pro.pro_proof_hash.data(), + sizeof(hash.data)) == 0); + REQUIRE(decrypt_result.pro_features == + (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); + + // Verify the content can be parsed w/ protobufs + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data, decrypt_result.content_plaintext.size)); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == large_message); + free(decrypt_result.content_plaintext.data); + } + + SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with " + "Pro") { + // Encrypt + session_protocol_encrypted_for_destination encrypt_result = {}; + { + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_GROUP; + assert(dest.recipient_pubkey[0] == 0x05); + + encrypt_result = session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + REQUIRE(encrypt_result.success); + REQUIRE(encrypt_result.encrypted); + } + + // Legacy groups wrap in websocket message + WebSocketProtos::WebSocketMessage ws_msg; + REQUIRE(ws_msg.ParseFromArray( + encrypt_result.ciphertext.data, encrypt_result.ciphertext.size)); + REQUIRE(ws_msg.has_request()); + REQUIRE(ws_msg.request().has_body()); + free(encrypt_result.ciphertext.data); + + // Decrypt envelope + span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + ws_msg.request().body().data(), + ws_msg.request().body().size(), + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + REQUIRE(decrypt_result.success); + + // Verify pro + REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached + bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(std::memcmp( + hash.data, + protobuf_content_with_pro.pro_proof_hash.data(), + sizeof(hash.data)) == 0); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + + // Verify the content can be parsed w/ protobufs + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data, decrypt_result.content_plaintext.size)); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + free(decrypt_result.content_plaintext.data); + } + + SECTION("Encrypt/decrypt for groups v2 (w/ encrypted envelope, plaintext content) with Pro") { + // TODO: Finish setting up a fake group + const auto group_v2_seed = + "0123456789abcdef0123456789abcdeff00baadeadb33f000000000000000000"_hexbytes; + array_uc64 group_v2_sk = {}; + array_uc32 group_v2_pk = {}; + crypto_sign_ed25519_seed_keypair( + group_v2_pk.data(), group_v2_sk.data(), group_v2_seed.data()); + + auto group_v2_info = config::groups::Info(group_v2_pk, group_v2_sk, std::nullopt); + auto group_v2_members = config::groups::Members(group_v2_pk, group_v2_sk, std::nullopt); + auto group_v2_keys = config::groups::Keys( + keys.ed_sk0, + group_v2_pk, + group_v2_sk, + std::nullopt, + group_v2_info, + group_v2_members); + + // Encrypt +#if 0 + EncryptedForDestination encrypt_result = {}; + { + Destination dest = base_dest; + dest.type = DestinationType::Group; + dest.group_pubkey[0] = 0x03; + std::memcpy(dest.group_pubkey.data() + 1, group_v2_pk.data(), group_v2_pk.size()); + dest.group_keys = &group_v2_keys; + + encrypt_result = session::encrypt_for_destination( + to_span(protobuf_content_with_pro.plaintext), + keys.ed_sk0, + dest, + config::Namespace::GroupMessages); + REQUIRE(encrypt_result.encrypted); + } + + // Decrypt envelope + DecryptEnvelopeKey decrypt_keys = {}; + decrypt_keys.use_group_keys = true; + decrypt_keys.group_keys = &group_v2_keys; + + // TODO: Finish setting up a group so we can check the decrypted result for now this will + // throw because the keys aren't setup correctly. + CHECK_THROWS(session::decrypt_envelope( + decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk)); +#endif + } + + SECTION("Encrypt/decrypt for sync messages with Pro") { + // Encrypt + session_protocol_encrypted_for_destination encrypt_result = {}; + { + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_SYNC_MESSAGE; + encrypt_result = session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + } + + // Decrypt + span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; + { + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + REQUIRE(decrypt_result.success); + + // Verify pro + REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached + bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(std::memcmp( + hash.data, + protobuf_content_with_pro.pro_proof_hash.data(), + sizeof(hash.data)) == 0); + REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + + // Verify the content can be parsed w/ protobufs + SessionProtos::Content decrypt_content = {}; + REQUIRE(decrypt_content.ParseFromArray( + decrypt_result.content_plaintext.data, decrypt_result.content_plaintext.size)); + REQUIRE(decrypt_content.has_datamessage()); + const SessionProtos::DataMessage& data = decrypt_content.datamessage(); + REQUIRE(data.body() == data_body); + free(decrypt_result.content_plaintext.data); + } + + // Try decrypt with a timestamp past the pro proof expiry date + { + session_protocol_decrypted_envelope decrypt_result = + session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch() + .count() + + 1, + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.pro_status == PRO_STATUS_EXPIRED); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + free(decrypt_result.content_plaintext.data); + } + + // Try decrypt with a bad backend key + { + array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; + bad_pro_backend_ed_pk[0] ^= 1; + session_protocol_decrypted_envelope decrypt_result = + session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch() + .count(), + bad_pro_backend_ed_pk.data(), + bad_pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_PRO_BACKEND_SIG); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + free(decrypt_result.content_plaintext.data); + } + + // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) + span_u8 bad_key = {keys.ed_sk0.data(), keys.ed_sk0.size()}; + { + session_protocol_decrypt_envelope_keys bad_decrypt_keys = {}; + bad_decrypt_keys.ed25519_privkeys = &bad_key; + bad_decrypt_keys.ed25519_privkeys_len = 1; + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &bad_decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + INFO("Checking error from bad envelope decryption: " << std::string_view( + error, decrypt_result.error_len_incl_null_terminator - 1)); + REQUIRE(!decrypt_result.success); + REQUIRE(decrypt_result.error_len_incl_null_terminator > 0); + REQUIRE(decrypt_result.error_len_incl_null_terminator <= sizeof(error)); + free(decrypt_result.content_plaintext.data); + } + + // Try decrypt with multiple keys, 1 bad, 1 good key + { + auto key_list = std::array{bad_key, key}; + session_protocol_decrypt_envelope_keys multi_decrypt_keys = {}; + multi_decrypt_keys.ed25519_privkeys = key_list.data(); + multi_decrypt_keys.ed25519_privkeys_len = key_list.size(); + session_protocol_decrypted_envelope decrypt_result = + session_protocol_decrypt_envelope( + &multi_decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch() + .count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + free(decrypt_result.content_plaintext.data); + } + free(encrypt_result.ciphertext.data); + } + + SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { + session_protocol_encrypted_for_destination encrypt_result = {}; + { + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_SYNC_MESSAGE; + dest.has_pro_sig = true; + dest.pro_sig[0] ^= 1; // Break the sig by flipping a bit + encrypt_result = session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + } + + span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_USER_SIG); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); + free(encrypt_result.ciphertext.data); + free(decrypt_result.content_plaintext.data); + } +} diff --git a/tests/utils.hpp b/tests/utils.hpp index e03a93b2..ce801905 100644 --- a/tests/utils.hpp +++ b/tests/utils.hpp @@ -152,7 +152,7 @@ static inline TestKeys get_deterministic_test_keys() { crypto_sign_ed25519_seed_keypair(result.ed_pk0.data(), result.ed_sk0.data(), result.seed0.data()); // X25519 - bool converted = crypto_sign_ed25519_pk_to_curve25519(result.curve_pk0.data(), result.ed_pk0.data()); + bool converted = crypto_sign_ed25519_pk_to_curve25519(result.curve_pk0.data(), result.ed_pk0.data()) == 0; assert(converted); // Session PK @@ -170,7 +170,7 @@ static inline TestKeys get_deterministic_test_keys() { crypto_sign_ed25519_seed_keypair(result.ed_pk1.data(), result.ed_sk1.data(), result.seed1.data()); // X25519 - bool converted = crypto_sign_ed25519_pk_to_curve25519(result.curve_pk1.data(), result.ed_pk1.data()); + bool converted = crypto_sign_ed25519_pk_to_curve25519(result.curve_pk1.data(), result.ed_pk1.data()) == 0; assert(converted); // Session PK From 5dbaa065abead8c747e20b0ca8eb3171c0aa5171 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 12:12:50 +1000 Subject: [PATCH 039/171] Add TODO on the purpose of PUBKEY in pro_backend --- include/session/pro_backend.hpp | 3 +++ src/pro_backend.cpp | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 442f15ab..9a05d08c 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -5,9 +5,12 @@ namespace session::pro_backend { +/// TODO: Assign the Session Pro backend public key for verifying proofs to allow users of the +/// library to have the pubkey available for verifying proofs. constexpr array_uc32 PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static_assert(sizeof(PUBKEY) == array_uc32{}.size()); struct add_payment_request { std::uint8_t version; diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index a40299a5..f54d5bf8 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -8,8 +8,6 @@ #include namespace session::pro_backend { - -static_assert(PUBKEY.size() == crypto_sign_ed25519_PUBLICKEYBYTES); master_rotating_sigs build_get_proof_sigs( const array_uc64& master_privkey, const array_uc64& rotating_privkey, From a7b701f87ab85f097ded53f5646920c786d47e3b Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 12:17:29 +1000 Subject: [PATCH 040/171] Add note that character limit is UTF16 code units for now --- include/session/session_protocol.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 52419079..8e892b8b 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -15,10 +15,20 @@ extern "C" { #endif enum { - /// Number of characters that a standard message can use. If the message exceeds this then the - /// message must activate the higher character limit feature provided by Session Pro which - /// allows messages up to 10k characters. + /// TODO: This comment needs to be updated to be _codepoints_ once libsession implements the + /// character count for the platforms. Currently they use code units but it should be + /// codepoints. This allows the platforms to use their native text representation up until the + /// API boundary where they will convert to UTF8 to have it managed by libsession. + + /// Maximum number of UTF16 code units that a standard message can use. If the message exceeds + /// this then the message must activate the higher character limit feature provided by Session + /// Pro which allows messages up to 10k characters. PRO_STANDARD_CHARACTER_LIMIT = 2'000, + + /// Maximum number of UTF16 code units that a Session Pro entitled user can send in a message. + /// This is not used in the codebase, but is provided for convenience to centralise protocol + /// definitions for users of the library to consume. + PRO_HIGHER_CHARACTER_LIMIT = 10'000, }; // Bit flags for features that are not currently able to be determined by the state stored in From 9811ecd12026d98865aaee354cb665b42a05d412 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 12:43:40 +1000 Subject: [PATCH 041/171] Remove outdated comment, these encrypt dests just receive plaintext --- src/session_protocol.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index bdeb1023..c62aaec3 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -114,8 +114,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } else if (space == config::Namespace::RevokedRetrievableGroupMessages) { enc.mode = Mode::Plaintext; } else { - // Config messages should be sent directly rather than via this method (just - // return plaintext and no-op). See: + // See: // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L494 enc.mode = Mode::Plaintext; } @@ -137,8 +136,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; enc.after_envelope = AfterEnvelope::EnvelopeIsCipherText; } else { - // Config messages should be sent directly rather than via this method (return just - // the plaintext and no-op) See: + // See: // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L498 enc.mode = Mode::Plaintext; } From 182d02a9fda7769a46a1f097f285f49349cb0641 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 12:49:04 +1000 Subject: [PATCH 042/171] Remove the CPP session protocol tests, keep C API The C-API is a wrapper over the C-interface so it thunks into the C++ implementation anyway so it tests both the C and C++ api for us with a very few exceptions. But for the most part, testing the C API kills two birds with one stone and reduces the test maintenance overhead of having to manage 2 test suites in parallel for the same API. --- tests/test_session_protocol.cpp | 460 -------------------------------- 1 file changed, 460 deletions(-) diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index d87eb66b..18127983 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -79,466 +79,6 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se return result; } -TEST_CASE("Session protocol helpers", "[session-protocol][helpers]") { - - // Do tests that require no setup - SECTION("Ensure get pro fetaures detects large message") { - // Try a message below the size threshold - PRO_FEATURES features = get_pro_features_for_msg( - PRO_STANDARD_CHARACTER_LIMIT, - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); - - // Try a message exceeding the size threshold - features = get_pro_features_for_msg( - PRO_STANDARD_CHARACTER_LIMIT + 1, - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | - PRO_FEATURES_ANIMATED_AVATAR)); - - // Try asking for just one extra feature - features = get_pro_features_for_msg(100, PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(features == PRO_FEATURES_PRO_BADGE); - } - - // Tests that require some setup code - using namespace session; - TestKeys keys = get_deterministic_test_keys(); - - // Tuesday, 12 August 2025 03:58:21 UTC - const std::chrono::milliseconds timestamp_ms = std::chrono::seconds(1754971101); - const std::chrono::sys_seconds timestamp_s = std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)); - const std::string_view data_body = "hello"; - - SECTION("Encrypt with and w/o pro sig produce same payload size") { - // Same payload size because the encrypt function should put in a dummy signature if one - // wasn't specific to make pro and non-pro envelopes indistinguishable. - session::Destination dest = {}; - dest.type = DestinationType::Contact; - dest.sent_timestamp_ms = timestamp_ms; - dest.recipient_pubkey = keys.session_pk1; - - // Withhold the pro signature - dest.pro_sig = std::nullopt; - EncryptedForDestination encrypt_without_pro_sig = encrypt_for_destination( - to_span(data_body), keys.ed_sk0, dest, config::Namespace::Default); - - // Set the pro signature - dest.pro_sig.emplace(); - EncryptedForDestination encrypt_with_pro_sig = encrypt_for_destination( - to_span(data_body), keys.ed_sk0, dest, config::Namespace::Default); - - REQUIRE(encrypt_without_pro_sig.encrypted); - REQUIRE(encrypt_with_pro_sig.encrypted); - - // Should have the same payload size - REQUIRE(encrypt_without_pro_sig.ciphertext.size() == - encrypt_with_pro_sig.ciphertext.size()); - } - - // Setup a dummy "Session Pro Backend" key - // We reuse test key 1 as the "Session Pro" backend key that signs the proofs as it - // doesn't matter what key really, just that we have one available for signing. - const array_uc64& pro_backend_ed_sk = keys.ed_sk1; - const array_uc32& pro_backend_ed_pk = keys.ed_pk1; - - SECTION("Encrypt/decrypt for contact in default namespace w/o pro attached") { - // Build content without pro attached - std::string plaintext; - { - SessionProtos::Content content = {}; - SessionProtos::DataMessage* data = content.mutable_datamessage(); - data->set_body(std::string(data_body)); - plaintext = content.SerializeAsString(); - REQUIRE(plaintext.size() > data_body.size()); - } - - // Encrypt - EncryptedForDestination encrypt_result = {}; - { - session::Destination dest = {}; - dest.type = DestinationType::Contact; - dest.sent_timestamp_ms = timestamp_ms; - REQUIRE(dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy( - dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); - - encrypt_result = session::encrypt_for_destination( - to_span(plaintext), keys.ed_sk0, dest, config::Namespace::Default); - REQUIRE(encrypt_result.encrypted); - } - - // Decrypt envelope - std::span key = keys.ed_sk1; - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&key, 1}; - DecryptedEnvelope decrypt_result = session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); - - // Verify pro - config::ProProof nil_proof = {}; - REQUIRE(decrypt_result.pro_status == ProStatus::Nil); // Pro was not attached - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); - REQUIRE(decrypt_result.pro_proof.hash() == nil_proof.hash()); - - // Verify it is decryptable - SessionProtos::Content decrypt_content = {}; - REQUIRE(decrypt_content.ParseFromArray( - decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); - REQUIRE(decrypt_content.has_datamessage()); - const SessionProtos::DataMessage& data = decrypt_content.datamessage(); - REQUIRE(data.body() == data_body); - } - - // Generate the user's Session Pro rotating key for testing encrypted payloads with Session - // Pro metadata - const auto user_pro_seed = - "0123456789abcdef0123456789abcdeff00baa00000000000000000000000000"_hexbytes; - array_uc32 user_pro_ed_pk; - array_uc64 user_pro_ed_sk; - crypto_sign_ed25519_seed_keypair( - user_pro_ed_pk.data(), user_pro_ed_sk.data(), user_pro_seed.data()); - - // Build protobuf `Content` message, serialise to `plaintext` and get it signed by the user's - // "Session Pro" key into `sig_over_plaintext_with_user_pro_key` - SerialisedProtobufContentWithProForTesting protobuf_content_with_pro = - build_protobuf_content_with_session_pro( - /*data_body*/ data_body, - /*user_rotating_privkey*/ user_pro_ed_sk, - /*pro_backend_privkey*/ pro_backend_ed_sk, - /*pro_expiry_unix_ts*/ timestamp_s, - PRO_FEATURES_NIL); - - // Setup base destination object with the pro signature w/ Session pubkey 1 as the recipient - session::Destination base_dest = {}; - base_dest.sent_timestamp_ms = timestamp_ms; - base_dest.pro_sig = protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key; - REQUIRE(base_dest.recipient_pubkey.size() == keys.session_pk1.size()); - std::memcpy( - base_dest.recipient_pubkey.data(), keys.session_pk1.data(), keys.session_pk1.size()); - - SECTION("Check non-encryptable messages produce only plaintext") { - auto dest_list = { - DestinationType::Community, - DestinationType::CommunityInbox, - DestinationType::Contact}; - - for (auto dest_type : dest_list) { - if (dest_type == DestinationType::Community) - INFO("Trying community"); - else if (dest_type == DestinationType::CommunityInbox) - INFO("Trying community inbox"); - else - INFO("Trying contacts to non-default namespace"); - - session::Destination dest = base_dest; - dest.type = dest_type; - - config::Namespace space = config::Namespace::Default; - if (dest_type == DestinationType::Contact) { - space = config::Namespace::Contacts; - } else if (dest_type == DestinationType::CommunityInbox) { - auto [blind15_pk, blind15_sk] = session::blind15_key_pair( - keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); - dest.recipient_pubkey[0] = 0x15; - std::memcpy(dest.recipient_pubkey.data() + 1, blind15_pk.data(), blind15_pk.size()); - } - - EncryptedForDestination encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), keys.ed_sk0, dest, space); - - if (dest_type == DestinationType::CommunityInbox) { - REQUIRE(encrypt_result.encrypted); - REQUIRE(encrypt_result.ciphertext.size()); - } else { - REQUIRE_FALSE(encrypt_result.encrypted); - REQUIRE(encrypt_result.ciphertext.empty()); - } - } - } - - SECTION("Encrypt/decrypt for contact in default namespace with Pro") { - // Encrypt content - EncryptedForDestination encrypt_result = {}; - { - session::Destination dest = base_dest; - dest.type = DestinationType::Contact; - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), - keys.ed_sk0, - dest, - config::Namespace::Default); - REQUIRE(encrypt_result.encrypted); - } - - // Decrypt envelope - std::span key = keys.ed_sk1; - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&key, 1}; - DecryptedEnvelope decrypt_result = session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); - - // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == protobuf_content_with_pro.pro_proof_hash); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - - // Verify the content can be parsed w/ protobufs - SessionProtos::Content decrypt_content = {}; - REQUIRE(decrypt_content.ParseFromArray( - decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); - REQUIRE(decrypt_content.has_datamessage()); - const SessionProtos::DataMessage& data = decrypt_content.datamessage(); - REQUIRE(data.body() == data_body); - } - - SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { - - std::string large_message; - large_message.resize(PRO_STANDARD_CHARACTER_LIMIT + 1); - - PRO_FEATURES features = - get_pro_features_for_msg(large_message.size(), PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); - - SerialisedProtobufContentWithProForTesting protobuf_content_with_pro_and_features = - build_protobuf_content_with_session_pro( - /*data_body*/ large_message, - /*user_rotating_privkey*/ user_pro_ed_sk, - /*pro_backend_privkey*/ pro_backend_ed_sk, - /*pro_expiry_unix_ts*/ timestamp_s, - features); - - // Encrypt content - EncryptedForDestination encrypt_result = {}; - { - session::Destination dest = base_dest; - dest.type = DestinationType::Contact; - dest.pro_sig = - protobuf_content_with_pro_and_features.sig_over_plaintext_with_user_pro_key; - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro_and_features.plaintext), - keys.ed_sk0, - dest, - config::Namespace::Default); - REQUIRE(encrypt_result.encrypted); - } - - // Decrypt envelope - std::span key = keys.ed_sk1; - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&key, 1}; - DecryptedEnvelope decrypt_result = session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); - - // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == - protobuf_content_with_pro_and_features.pro_proof_hash); - REQUIRE(decrypt_result.pro_features == - (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); - - // Verify the content can be parsed w/ protobufs - SessionProtos::Content decrypt_content = {}; - REQUIRE(decrypt_content.ParseFromArray( - decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); - REQUIRE(decrypt_content.has_datamessage()); - const SessionProtos::DataMessage& data = decrypt_content.datamessage(); - REQUIRE(data.body() == large_message); - } - - SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with " - "Pro") { - // Encrypt - EncryptedForDestination encrypt_result = {}; - { - Destination dest = base_dest; - dest.type = DestinationType::Group; - assert(dest.recipient_pubkey[0] == 0x05); - - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), - keys.ed_sk0, - dest, - config::Namespace::Default); - REQUIRE(encrypt_result.encrypted); - } - - // Legacy groups wrap in websocket message - WebSocketProtos::WebSocketMessage ws_msg; - REQUIRE(ws_msg.ParseFromArray( - encrypt_result.ciphertext.data(), encrypt_result.ciphertext.size())); - REQUIRE(ws_msg.has_request()); - REQUIRE(ws_msg.request().has_body()); - - // Decrypt envelope - std::span key = keys.ed_sk1; - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&key, 1}; - DecryptedEnvelope decrypt_result = session::decrypt_envelope( - decrypt_keys, to_span(ws_msg.request().body()), timestamp_s, pro_backend_ed_pk); - - // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == protobuf_content_with_pro.pro_proof_hash); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - - // Verify the content can be parsed w/ protobufs - SessionProtos::Content decrypt_content = {}; - REQUIRE(decrypt_content.ParseFromArray( - decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); - REQUIRE(decrypt_content.has_datamessage()); - const SessionProtos::DataMessage& data = decrypt_content.datamessage(); - REQUIRE(data.body() == data_body); - } - - SECTION("Encrypt/decrypt for groups v2 (w/ encrypted envelope, plaintext content) with Pro") { - // TODO: Finish setting up a fake group - const auto group_v2_seed = - "0123456789abcdef0123456789abcdeff00baadeadb33f000000000000000000"_hexbytes; - array_uc64 group_v2_sk = {}; - array_uc32 group_v2_pk = {}; - crypto_sign_ed25519_seed_keypair( - group_v2_pk.data(), group_v2_sk.data(), group_v2_seed.data()); - - auto group_v2_info = config::groups::Info(group_v2_pk, group_v2_sk, std::nullopt); - auto group_v2_members = config::groups::Members(group_v2_pk, group_v2_sk, std::nullopt); - auto group_v2_keys = config::groups::Keys( - keys.ed_sk0, - group_v2_pk, - group_v2_sk, - std::nullopt, - group_v2_info, - group_v2_members); - - // Encrypt -#if 0 - EncryptedForDestination encrypt_result = {}; - { - Destination dest = base_dest; - dest.type = DestinationType::Group; - dest.group_pubkey[0] = 0x03; - std::memcpy(dest.group_pubkey.data() + 1, group_v2_pk.data(), group_v2_pk.size()); - dest.group_keys = &group_v2_keys; - - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), - keys.ed_sk0, - dest, - config::Namespace::GroupMessages); - REQUIRE(encrypt_result.encrypted); - } - - // Decrypt envelope - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = true; - decrypt_keys.group_keys = &group_v2_keys; - - // TODO: Finish setting up a group so we can check the decrypted result for now this will - // throw because the keys aren't setup correctly. - CHECK_THROWS(session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk)); -#endif - } - - SECTION("Encrypt/decrypt for sync messages with Pro") { - // Encrypt - EncryptedForDestination encrypt_result = {}; - { - session::Destination dest = base_dest; - dest.type = DestinationType::SyncMessage; - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), - keys.ed_sk0, - dest, - config::Namespace::Default); - REQUIRE(encrypt_result.encrypted); - } - - // Decrypt envelope - std::span key = keys.ed_sk1; - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&key, 1}; - DecryptedEnvelope decrypt_result = session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); - - // Verify pro - REQUIRE(decrypt_result.pro_status == ProStatus::Valid); // Pro was attached - REQUIRE(decrypt_result.pro_proof.hash() == protobuf_content_with_pro.pro_proof_hash); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - - // Verify the content can be parsed w/ protobufs - SessionProtos::Content decrypt_content = {}; - REQUIRE(decrypt_content.ParseFromArray( - decrypt_result.content_plaintext.data(), decrypt_result.content_plaintext.size())); - REQUIRE(decrypt_content.has_datamessage()); - const SessionProtos::DataMessage& data = decrypt_content.datamessage(); - REQUIRE(data.body() == data_body); - - // Try decrypt with a timestamp past the pro proof expiry date - DecryptedEnvelope decrypt_result_again = session::decrypt_envelope( - decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts + std::chrono::seconds(1), - pro_backend_ed_pk); - REQUIRE(decrypt_result_again.pro_status == ProStatus::Expired); - - // Try decrypt with a bad backend key - array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; - bad_pro_backend_ed_pk[0] ^= 1; - decrypt_result_again = session::decrypt_envelope( - decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts, - bad_pro_backend_ed_pk); - REQUIRE(decrypt_result_again.pro_status == ProStatus::InvalidProBackendSig); - - // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) - std::span bad_key = keys.ed_sk0; - DecryptEnvelopeKey bad_decrypt_keys = {}; - bad_decrypt_keys.ed25519_privkeys = {&bad_key, 1}; - REQUIRE_THROWS(session::decrypt_envelope( - bad_decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts, - pro_backend_ed_pk)); - - // Try decrypt with multiple keys, 1 bad, 1 good key - auto key_list = std::array{bad_key, key}; - DecryptEnvelopeKey multi_decrypt_keys = {}; - multi_decrypt_keys.ed25519_privkeys = key_list; - decrypt_result_again = session::decrypt_envelope( - multi_decrypt_keys, - encrypt_result.ciphertext, - protobuf_content_with_pro.proof.expiry_unix_ts, - pro_backend_ed_pk); - REQUIRE(decrypt_result_again.pro_status == ProStatus::Valid); - } - - SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { - EncryptedForDestination encrypt_result = {}; - { - session::Destination dest = base_dest; - dest.type = DestinationType::SyncMessage; - (*dest.pro_sig)[0] ^= 1; // Break the sig by flipping a bit - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), - keys.ed_sk0, - dest, - config::Namespace::Default); - REQUIRE(encrypt_result.encrypted); - } - - std::span key = keys.ed_sk1; - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = {&key, 1}; - DecryptedEnvelope decrypt_result = session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk); - REQUIRE(decrypt_result.pro_status == ProStatus::InvalidUserSig); - } -} - TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Do tests that require no setup From e8cf5f830f70e112e8c4651c01d21a15761a5bdf Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 15:11:18 +1000 Subject: [PATCH 043/171] Fix groups message not encrypting correctly --- src/session_protocol.cpp | 16 +++++--- tests/test_session_protocol.cpp | 72 ++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index c62aaec3..847040d9 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -52,7 +52,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( std::span dest_recipient_pubkey, std::chrono::milliseconds dest_sent_timestamp_ms, std::span dest_community_inbox_server_pubkey, - std::span dest_group_pubkey, + std::span dest_group_ed25519_pubkey, std::span dest_group_ed25519_privkey, config::Namespace space, UseMalloc use_malloc) { @@ -60,7 +60,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( assert(dest_pro_sig.empty() || dest_pro_sig.size() == crypto_sign_ed25519_BYTES); assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); - assert(dest_group_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); + assert(dest_group_ed25519_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_privkey.size() == 32 || dest_group_ed25519_privkey.size() == 64); // All incoming arguments are passed in from typed, fixed-sized arrays so we do not need to @@ -103,7 +103,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( switch (dest_type) { case DestinationType::Group: { bool has_03_prefix = - dest_group_pubkey[0] == static_cast(SessionIDPrefix::group); + dest_group_ed25519_pubkey[0] == static_cast(SessionIDPrefix::group); if (has_03_prefix) { if (space == config::Namespace::GroupMessages) { enc.mode = Mode::Envelope; @@ -125,7 +125,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; - enc.envelope_src = dest_group_pubkey; + enc.envelope_src = dest_group_ed25519_pubkey; } } break; @@ -223,9 +223,12 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( case AfterEnvelope::KeysEncryptMessage: { std::string bytes = envelope.SerializeAsString(); + if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) + dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); + std::vector ciphertext = encrypt_for_group( ed25519_privkey, - dest_group_pubkey, + dest_group_ed25519_pubkey, dest_group_ed25519_privkey, to_span(bytes), /*compress*/ true, @@ -330,7 +333,8 @@ DecryptedEnvelope decrypt_envelope( decrypt.session_id.size())}; // Update the plaintext to use the decrypted envelope - envelope_plaintext = std::move(decrypt.plaintext); + envelope_plaintext_from_group_keys = std::move(decrypt.plaintext); + envelope_plaintext = envelope_plaintext_from_group_keys; // Copy keys out assert(decrypt.session_id.starts_with("05")); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 18127983..39d1525d 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -528,44 +528,58 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { crypto_sign_ed25519_seed_keypair( group_v2_pk.data(), group_v2_sk.data(), group_v2_seed.data()); - auto group_v2_info = config::groups::Info(group_v2_pk, group_v2_sk, std::nullopt); - auto group_v2_members = config::groups::Members(group_v2_pk, group_v2_sk, std::nullopt); - auto group_v2_keys = config::groups::Keys( - keys.ed_sk0, - group_v2_pk, - group_v2_sk, - std::nullopt, - group_v2_info, - group_v2_members); - // Encrypt -#if 0 - EncryptedForDestination encrypt_result = {}; + session_protocol_encrypted_for_destination encrypt_result = {}; { - Destination dest = base_dest; - dest.type = DestinationType::Group; - dest.group_pubkey[0] = 0x03; - std::memcpy(dest.group_pubkey.data() + 1, group_v2_pk.data(), group_v2_pk.size()); - dest.group_keys = &group_v2_keys; - - encrypt_result = session::encrypt_for_destination( - to_span(protobuf_content_with_pro.plaintext), - keys.ed_sk0, - dest, - config::Namespace::GroupMessages); + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_GROUP; + dest.group_ed25519_pubkey[0] = 0x03; + std::memcpy(dest.group_ed25519_pubkey + 1, group_v2_pk.data(), group_v2_pk.size()); + std::memcpy( + dest.group_ed25519_privkey, + group_v2_sk.data(), + sizeof(dest.group_ed25519_privkey)); + + encrypt_result = session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_GROUP_MESSAGES, + error, + sizeof(error)); + INFO("Encrypt for group error: " << error); + REQUIRE(encrypt_result.success); REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); } // Decrypt envelope - DecryptEnvelopeKey decrypt_keys = {}; - decrypt_keys.use_group_keys = true; - decrypt_keys.group_keys = &group_v2_keys; + span_u8 key = {group_v2_sk.data(), group_v2_sk.size()}; + session_protocol_decrypt_envelope_keys decrypt_keys = {}; + decrypt_keys.group_ed25519_pubkey = {group_v2_pk.data(), group_v2_pk.size()}; + decrypt_keys.ed25519_privkeys = &key; + decrypt_keys.ed25519_privkeys_len = 1; // TODO: Finish setting up a group so we can check the decrypted result for now this will // throw because the keys aren't setup correctly. - CHECK_THROWS(session::decrypt_envelope( - decrypt_keys, encrypt_result.ciphertext, timestamp_s, pro_backend_ed_pk)); -#endif + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + timestamp_s.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + INFO("Decrypt for group error: " << error); + REQUIRE(decrypt_result.success); + REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); + REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + + free(encrypt_result.ciphertext.data); + free(decrypt_result.content_plaintext.data); } SECTION("Encrypt/decrypt for sync messages with Pro") { From 71372f6f0da8be4e1d9a8a215a0ac9f67dfd5bff Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 15:40:04 +1000 Subject: [PATCH 044/171] Remove envelope type, it is inferred from the namespace All the payloads in the returned envelope are decrypted so we shouldn't care too much about the type at that point. The caller can immediately start working with the contents. --- include/session/session_protocol.h | 6 ------ include/session/session_protocol.hpp | 6 ------ src/session_protocol.cpp | 20 ++++++-------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 8e892b8b..d5566e93 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -83,11 +83,6 @@ typedef struct session_protocol_destination { // See session::Destination uint8_t group_ed25519_privkey[32]; } session_protocol_destination; -typedef enum ENVELOPE_TYPE { - ENVELOPE_TYPE_SESSION_MESSAGE, - ENVELOPE_TYPE_CLOSED_GROUP_MESSGE, -} ENVELOPE_TYPE; - // Indicates which optional fields in the envelope has been populated out of the optional fields in // an envelope after it has been parsed off the wire. typedef uint32_t ENVELOPE_FLAGS; @@ -100,7 +95,6 @@ enum ENVELOPE_FLAGS_ { typedef struct session_protocol_envelope { ENVELOPE_FLAGS flags; - ENVELOPE_TYPE type; uint64_t timestamp_ms; uint8_t source[33]; uint32_t source_device; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index ed75d12c..78fdaf86 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -90,14 +90,8 @@ struct Destination { array_uc32 group_ed25519_privkey; }; -enum class EnvelopeType { - SessionMessage = ENVELOPE_TYPE_SESSION_MESSAGE, - ClosedGroupMessage = ENVELOPE_TYPE_CLOSED_GROUP_MESSGE, -}; - struct Envelope { ENVELOPE_FLAGS flags; - EnvelopeType type; std::chrono::milliseconds timestamp; // Optional fields. These fields are set if the appropriate flag has been set in `flags` diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 847040d9..e56a3db9 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -347,19 +347,12 @@ DecryptedEnvelope decrypt_envelope( if (!envelope.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) throw std::runtime_error{"Parse envelope from plaintext failed"}; - // Parse type (unconditionallty) - if (!envelope.has_type()) - throw std::runtime_error("Parse envelope failed, missing type"); - - switch (envelope.type()) { - case SessionProtos::Envelope_Type_SESSION_MESSAGE: - result.envelope.type = EnvelopeType::SessionMessage; - break; - - case SessionProtos::Envelope_Type_CLOSED_GROUP_MESSAGE: - result.envelope.type = EnvelopeType::ClosedGroupMessage; - break; - } + // TODO: We do not parse the envelop type anymore, we infer the type from + // the namespace. Deciding whether or not we decrypt the envelope vs the content depends on + // whether or not the group keys were passed in so we don't care about the type anymore. + // + // When the type is removed, we can remove this TODO. This is just a reminder as to why we skip + // over that field but it's still in the schema and still being set on the sending side. // Parse source (optional) if (envelope.has_source()) { @@ -660,7 +653,6 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( } result.envelope.flags = result_cpp.envelope.flags; - result.envelope.type = static_cast(result_cpp.envelope.type); result.envelope.timestamp_ms = static_cast(result_cpp.envelope.timestamp.count()); result.envelope.source_device = result_cpp.envelope.source_device; result.envelope.server_timestamp = result_cpp.envelope.server_timestamp; From 6db93b550ab4b91c94872c8074552d02d3c904ec Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 15:57:56 +1000 Subject: [PATCH 045/171] Encapsulate the freeing of session protocol encrypt/decrypt funcs --- include/session/session_protocol.h | 33 +++++++++++++++++++++-- src/session_protocol.cpp | 16 ++++++++++++ tests/test_session_protocol.cpp | 42 +++++++++++++++--------------- 3 files changed, 68 insertions(+), 23 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index d5566e93..da9bf495 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -155,6 +155,9 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR /// /// See: session_protocol/encrypt_for_destination for more information /// +/// The encryption result must be freed with `session_protocol_encrypt_for_destination_free` when +/// the caller is done with the result. +/// /// Inputs: /// - `plaintext` -- the protobuf serialised payload containing the protobuf encoded stream, /// `Content`. It must not be already be encrypted. @@ -186,8 +189,7 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR /// on the result to determine if the ciphertext or plaintext is to be used. /// /// The retured payload is suitable for sending on the wire (i.e: it has been protobuf -/// encoded/wrapped if necessary). The ciphertext must be freed with the CRT's `free` when the -/// caller is done with the memory. +/// encoded/wrapped if necessary). /// - `error_len_incl_null_terminator` The length of the error message if `success` was false. If /// the user passes in an non-`NULL` error buffer this is amount of characters written to the /// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters @@ -205,6 +207,18 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat char* error, size_t error_len); +/// API: session_protocol/session_protocol_encrypt_for_destination_free +/// +/// Free the encryption result for a destination produced by +/// `session_protocol_encrypt_for_destination`. It is safe to pass a `NULL` or any result returned +/// by the encrypt function irrespective of if the function succeeded or failed. +/// +/// Inputs: +/// - `encrypt` -- Encryption result to free. This object is zeroed out on free and should no longer +/// be used after it is freed. +LIBSESSION_EXPORT void session_protocol_encrypt_for_destination_free( + session_protocol_encrypted_for_destination* encrypt); + /// API: session_protocol/session_protocol_decrypt_envelope /// /// Given an envelope payload (i.e.: protobuf encoded stream of `Envelope` or encrypted `Envelope` @@ -217,6 +231,9 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// /// See: session_protocol/decrypt_envelope for more information /// +/// The encryption result must be freed with `session_protocol_decrypt_envelope_free` when the +/// caller is done with the result. +/// /// Inputs: /// - `keys` -- the keys to decrypt either the envelope or the envelope contents. Groups v2 /// envelopes where the envelope is encrypted must set the group key. Envelopes with an encrypted @@ -288,6 +305,18 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( char* error, size_t error_len); +/// API: session_protocol/session_protocol_decrypt_envelope_free +/// +/// Free the decryption result produced by `session_protocol_decrypt_envelope`. It is safe to pass a +/// `NULL` or any result returned by the decrypt function irrespective of if the function succeeded +/// or failed. +/// +/// Inputs: +/// - `envelope` -- Decryption result to free. This object is zeroed out on free and should no longer +/// be used after it is freed. +LIBSESSION_EXPORT void session_protocol_decrypt_envelope_free( + session_protocol_decrypted_envelope* envelope); + #ifdef __cplusplus } #endif diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index e56a3db9..4297c0a3 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -581,6 +581,14 @@ session_protocol_encrypt_for_destination( return result; } +LIBSESSION_C_API void session_protocol_encrypt_for_destination_free( + session_protocol_encrypted_for_destination* encrypt) { + if (encrypt) { + free(encrypt->ciphertext.data); + *encrypt = {}; + } +} + LIBSESSION_C_API session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const session_protocol_decrypt_envelope_keys* keys, @@ -698,3 +706,11 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( result.pro_proof.sig, result_cpp.pro_proof.sig.data(), sizeof(result.pro_proof.sig)); return result; } + +LIBSESSION_C_API +void session_protocol_decrypt_envelope_free(session_protocol_decrypted_envelope* envelope) { + if (envelope) { + free(envelope->content_plaintext.data); + *envelope = {}; + } +} diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 39d1525d..dc004cfa 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -155,8 +155,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Should have the same payload size REQUIRE(encrypt_without_pro_sig.ciphertext.size == encrypt_with_pro_sig.ciphertext.size); - free(encrypt_without_pro_sig.ciphertext.data); - free(encrypt_with_pro_sig.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_without_pro_sig); + session_protocol_encrypt_for_destination_free(&encrypt_with_pro_sig); } // Setup a dummy "Session Pro Backend" key @@ -213,7 +213,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { pro_backend_ed_pk.size(),error, sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(encrypt_result.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); // Verify pro config::ProProof nil_proof = {}; @@ -233,7 +233,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } // Generate the user's Session Pro rotating key for testing encrypted payloads with Session @@ -313,7 +313,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(encrypt_result.ciphertext.size == 0); } REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - free(encrypt_result.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); } } @@ -352,7 +352,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(encrypt_result.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); // Verify pro REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached @@ -370,7 +370,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { @@ -430,7 +430,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(encrypt_result.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); // Verify pro REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached @@ -449,7 +449,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == large_message); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with " @@ -481,7 +481,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { encrypt_result.ciphertext.data, encrypt_result.ciphertext.size)); REQUIRE(ws_msg.has_request()); REQUIRE(ws_msg.request().has_body()); - free(encrypt_result.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; @@ -516,7 +516,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for groups v2 (w/ encrypted envelope, plaintext content) with Pro") { @@ -578,8 +578,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(encrypt_result.ciphertext.data); - free(decrypt_result.content_plaintext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_decrypt_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for sync messages with Pro") { @@ -635,7 +635,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } // Try decrypt with a timestamp past the pro proof expiry date @@ -655,7 +655,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_EXPIRED); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } // Try decrypt with a bad backend key @@ -676,7 +676,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_PRO_BACKEND_SIG); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) @@ -699,7 +699,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(!decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator > 0); REQUIRE(decrypt_result.error_len_incl_null_terminator <= sizeof(error)); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } // Try decrypt with multiple keys, 1 bad, 1 good key @@ -722,9 +722,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - free(decrypt_result.content_plaintext.data); + session_protocol_decrypt_envelope_free(&decrypt_result); } - free(encrypt_result.ciphertext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); } SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { @@ -763,7 +763,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_USER_SIG); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - free(encrypt_result.ciphertext.data); - free(decrypt_result.content_plaintext.data); + session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_decrypt_envelope_free(&decrypt_result); } } From df1e02176416ba4e3c4a0e401356cced08a3aa6b Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 16:14:55 +1000 Subject: [PATCH 046/171] Prohibit the creation of legacy groups messages, no longer supported --- src/session_protocol.cpp | 97 ++++++++++----------------------- tests/test_session_protocol.cpp | 81 ++++++--------------------- 2 files changed, 46 insertions(+), 132 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 4297c0a3..0c502e8b 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -73,14 +73,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( EncryptForBlindedRecipient, }; - // The step to partake after enveloping the content payload - enum class AfterEnvelope { - Nil, - EnvelopeIsCipherText, // No extra bit-mangling required after enveloping - WrapInWSMessage, // Wrap in the protobuf websocket message after enveloping - KeysEncryptMessage, // Encrypt with the group keys after ennveloping - }; - struct EncodeContext { Mode mode; // Parameters for BuildMode => Envelope @@ -95,7 +87,8 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( // Type of message to mark the enevelope as std::optional envelope_type; - AfterEnvelope after_envelope; + + bool after_envelope_keys_encrypt_message; // Encrypt with group keys }; // Figure out how to encrypt the message based on the destination and setup the encoding context @@ -108,7 +101,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( if (space == config::Namespace::GroupMessages) { enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = false; - enc.after_envelope = AfterEnvelope::KeysEncryptMessage; + enc.after_envelope_keys_encrypt_message = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; } else if (space == config::Namespace::RevokedRetrievableGroupMessages) { @@ -120,12 +113,9 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } } else { // Legacy groups which have a 05 prefixed key - enc.mode = Mode::Envelope; - enc.before_envelope_encrypt_for_recipient_deterministic = true; - enc.envelope_type = - SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; - enc.after_envelope = AfterEnvelope::WrapInWSMessage; - enc.envelope_src = dest_group_ed25519_pubkey; + throw std::runtime_error{ + "Unsupported configuration, encrypting for a legacy group (0x05 prefix) is " + "no longer supported"}; } } break; @@ -134,7 +124,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; - enc.after_envelope = AfterEnvelope::EnvelopeIsCipherText; + enc.after_envelope_keys_encrypt_message = false; } else { // See: // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L498 @@ -146,7 +136,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; - enc.after_envelope = AfterEnvelope::EnvelopeIsCipherText; + enc.after_envelope_keys_encrypt_message = false; } break; case DestinationType::Community: { @@ -193,56 +183,26 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } result.encrypted = true; - switch (enc.after_envelope) { - case AfterEnvelope::Nil: - assert(false && "Dev error, after envelope action was not set"); - break; - - case AfterEnvelope::WrapInWSMessage: { - // Setup message - WebSocketProtos::WebSocketMessage msg = {}; - msg.set_type( - WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); - - // Make request - WebSocketProtos::WebSocketRequestMessage* req_msg = msg.mutable_request(); - req_msg->set_body(envelope.SerializeAsString()); - - // Write message as ciphertext - [[maybe_unused]] bool serialized = false; - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_alloc_or_throw(msg.ByteSizeLong()); - serialized = msg.SerializeToArray(result.ciphertext_c.data, result.ciphertext_c.size); - } else { - result.ciphertext_cpp.resize(msg.ByteSizeLong()); - serialized = msg.SerializeToArray( - result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); - } - assert(serialized); - } break; - - case AfterEnvelope::KeysEncryptMessage: { - std::string bytes = envelope.SerializeAsString(); - if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) - dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); - - std::vector ciphertext = encrypt_for_group( - ed25519_privkey, - dest_group_ed25519_pubkey, - dest_group_ed25519_privkey, - to_span(bytes), - /*compress*/ true, - /*padding*/ 256); - - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = - span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); - } else { - result.ciphertext_cpp = std::move(ciphertext); - } - } break; - - case AfterEnvelope::EnvelopeIsCipherText: { + if (enc.after_envelope_keys_encrypt_message) { + std::string bytes = envelope.SerializeAsString(); + if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) + dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); + + std::vector ciphertext = encrypt_for_group( + ed25519_privkey, + dest_group_ed25519_pubkey, + dest_group_ed25519_privkey, + to_span(bytes), + /*compress*/ true, + /*padding*/ 256); + + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = + span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + } else { + result.ciphertext_cpp = std::move(ciphertext); + } + } else { [[maybe_unused]] bool serialized = false; if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); @@ -254,7 +214,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); } assert(serialized); - } break; } } break; diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index dc004cfa..2921f85f 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -452,71 +452,26 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_decrypt_envelope_free(&decrypt_result); } - SECTION("Encrypt/decrypt for legacy groups (w/ encrypted envelope, plaintext content) with " - "Pro") { - // Encrypt - session_protocol_encrypted_for_destination encrypt_result = {}; - { - session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_GROUP; - assert(dest.recipient_pubkey[0] == 0x05); + SECTION("Encrypt/decrypt for legacy groups is rejected") { + session_protocol_destination dest = base_dest; + dest.type = DESTINATION_TYPE_GROUP; + assert(dest.recipient_pubkey[0] == 0x05); - encrypt_result = session_protocol_encrypt_for_destination( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, - error, - sizeof(error)); - REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - REQUIRE(encrypt_result.success); - REQUIRE(encrypt_result.encrypted); - } - - // Legacy groups wrap in websocket message - WebSocketProtos::WebSocketMessage ws_msg; - REQUIRE(ws_msg.ParseFromArray( - encrypt_result.ciphertext.data, encrypt_result.ciphertext.size)); - REQUIRE(ws_msg.has_request()); - REQUIRE(ws_msg.request().has_body()); + session_protocol_encrypted_for_destination encrypt_result = + session_protocol_encrypt_for_destination( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + &dest, + NAMESPACE_DEFAULT, + error, + sizeof(error)); + REQUIRE(encrypt_result.error_len_incl_null_terminator > 0); + REQUIRE(encrypt_result.error_len_incl_null_terminator <= sizeof(error)); + REQUIRE(!encrypt_result.success); + REQUIRE(!encrypt_result.encrypted); session_protocol_encrypt_for_destination_free(&encrypt_result); - - // Decrypt envelope - span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( - &decrypt_keys, - ws_msg.request().body().data(), - ws_msg.request().body().size(), - timestamp_s.time_since_epoch().count(), - pro_backend_ed_pk.data(), - pro_backend_ed_pk.size(), - error, - sizeof(error)); - REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - REQUIRE(decrypt_result.success); - - // Verify pro - REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached - bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); - REQUIRE(std::memcmp( - hash.data, - protobuf_content_with_pro.pro_proof_hash.data(), - sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested - - // Verify the content can be parsed w/ protobufs - SessionProtos::Content decrypt_content = {}; - REQUIRE(decrypt_content.ParseFromArray( - decrypt_result.content_plaintext.data, decrypt_result.content_plaintext.size)); - REQUIRE(decrypt_content.has_datamessage()); - const SessionProtos::DataMessage& data = decrypt_content.datamessage(); - REQUIRE(data.body() == data_body); - session_protocol_decrypt_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for groups v2 (w/ encrypted envelope, plaintext content) with Pro") { From 8c877c842fd30c225277bc4911bc775187f4ea26 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 20 Aug 2025 17:32:32 +1000 Subject: [PATCH 047/171] Fix linting --- include/session/session_encrypt.h | 4 +- include/session/session_protocol.h | 3 +- src/session_encrypt.cpp | 14 +++--- src/session_protocol.cpp | 24 +++++----- tests/test_session_encrypt.cpp | 3 +- tests/test_session_protocol.cpp | 75 ++++++++++++++---------------- 6 files changed, 60 insertions(+), 63 deletions(-) diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index 2d60541e..5e062905 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -132,7 +132,7 @@ LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( size_t plaintext_len, bool compress, size_t padding, - char *error, + char* error, size_t error_len); /// API: crypto/session_decrypt_incoming @@ -287,7 +287,7 @@ session_decrypt_group_message_result session_decrypt_group_message( size_t group_ed25519_pubkey_len, const unsigned char* ciphertext, size_t ciphertext_len, - char *error, + char* error, size_t error_len); /// API: crypto/session_decrypt_ons_response diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index da9bf495..dc4ff135 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -312,7 +312,8 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( /// or failed. /// /// Inputs: -/// - `envelope` -- Decryption result to free. This object is zeroed out on free and should no longer +/// - `envelope` -- Decryption result to free. This object is zeroed out on free and should no +/// longer /// be used after it is freed. LIBSESSION_EXPORT void session_protocol_decrypt_envelope_free( session_protocol_decrypted_envelope* envelope); diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index dd715127..6a622d01 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -553,11 +553,11 @@ std::pair, std::vector> decrypt_incomi buf.resize(outer_size); int opened = crypto_box_seal_open( - buf.data(), - ciphertext.data(), - ciphertext.size(), - x25519_pubkey.data(), - x25519_seckey.data()); + buf.data(), + ciphertext.data(), + ciphertext.size(), + x25519_pubkey.data(), + x25519_seckey.data()); if (opened != 0) throw std::runtime_error{"Decryption failed"}; @@ -1125,7 +1125,7 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( size_t plaintext_len, bool compress, size_t padding, - char *error, + char* error, size_t error_len) { session_encrypt_group_message result = {}; try { @@ -1233,7 +1233,7 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess size_t group_ed25519_pubkey_len, const unsigned char* ciphertext, size_t ciphertext_len, - char *error, + char* error, size_t error_len) { session_decrypt_group_message_result result = {}; for (size_t index = 0; index < decrypt_ed25519_privkey_len; index++) { diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 0c502e8b..6bd1e745 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -88,7 +88,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( // Type of message to mark the enevelope as std::optional envelope_type; - bool after_envelope_keys_encrypt_message; // Encrypt with group keys + bool after_envelope_keys_encrypt_message; // Encrypt with group keys }; // Figure out how to encrypt the message based on the destination and setup the encoding context @@ -203,17 +203,17 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( result.ciphertext_cpp = std::move(ciphertext); } } else { - [[maybe_unused]] bool serialized = false; - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); - serialized = envelope.SerializeToArray( - result.ciphertext_c.data, result.ciphertext_c.size); - } else { - result.ciphertext_cpp.resize(envelope.ByteSizeLong()); - serialized = envelope.SerializeToArray( - result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); - } - assert(serialized); + [[maybe_unused]] bool serialized = false; + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); + serialized = envelope.SerializeToArray( + result.ciphertext_c.data, result.ciphertext_c.size); + } else { + result.ciphertext_cpp.resize(envelope.ByteSizeLong()); + serialized = envelope.SerializeToArray( + result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); + } + assert(serialized); } } break; diff --git a/tests/test_session_encrypt.cpp b/tests/test_session_encrypt.cpp index 70514b11..41efa1ff 100644 --- a/tests/test_session_encrypt.cpp +++ b/tests/test_session_encrypt.cpp @@ -103,7 +103,8 @@ TEST_CASE("Session protocol deterministic encryption", "[session-protocol][encry std::vector sid_raw; oxenc::from_hex(sid.begin(), sid.end(), std::back_inserter(sid_raw)); REQUIRE(sid == "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"); - REQUIRE(sid_raw == "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"_hexbytes); + REQUIRE(sid_raw == + "05d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"_hexbytes); const auto seed2 = "00112233445566778899aabbccddeeff00000000000000000000000000000000"_hexbytes; std::array ed_pk2, curve_pk2; diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 2921f85f..866d3209 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -210,7 +210,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { encrypt_result.ciphertext.size, timestamp_s.time_since_epoch().count(), pro_backend_ed_pk.data(), - pro_backend_ed_pk.size(),error, sizeof(error)); + pro_backend_ed_pk.size(), + error, + sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_encrypt_for_destination_free(&encrypt_result); @@ -222,9 +224,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.pro_status == PRO_STATUS_NIL); // Pro was not attached REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); REQUIRE(std::memcmp( - decrypt_result_pro_hash.data, - nil_hash.data(), - sizeof(decrypt_result_pro_hash.data)) == 0); + decrypt_result_pro_hash.data, + nil_hash.data(), + sizeof(decrypt_result_pro_hash.data)) == 0); // Verify it is decryptable SessionProtos::Content decrypt_content = {}; @@ -487,8 +489,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encrypted_for_destination encrypt_result = {}; { session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_GROUP; - dest.group_ed25519_pubkey[0] = 0x03; + dest.type = DESTINATION_TYPE_GROUP; + dest.group_ed25519_pubkey[0] = 0x03; std::memcpy(dest.group_ed25519_pubkey + 1, group_v2_pk.data(), group_v2_pk.size()); std::memcpy( dest.group_ed25519_privkey, @@ -595,18 +597,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Try decrypt with a timestamp past the pro proof expiry date { - session_protocol_decrypted_envelope decrypt_result = - session_protocol_decrypt_envelope( - &decrypt_keys, - encrypt_result.ciphertext.data, - encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch() - .count() + - 1, - pro_backend_ed_pk.data(), - pro_backend_ed_pk.size(), - error, - sizeof(error)); + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count() + 1, + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_EXPIRED); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); @@ -617,17 +616,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { { array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; bad_pro_backend_ed_pk[0] ^= 1; - session_protocol_decrypted_envelope decrypt_result = - session_protocol_decrypt_envelope( - &decrypt_keys, - encrypt_result.ciphertext.data, - encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch() - .count(), - bad_pro_backend_ed_pk.data(), - bad_pro_backend_ed_pk.size(), - error, - sizeof(error)); + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count(), + bad_pro_backend_ed_pk.data(), + bad_pro_backend_ed_pk.size(), + error, + sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_PRO_BACKEND_SIG); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); @@ -663,17 +660,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_decrypt_envelope_keys multi_decrypt_keys = {}; multi_decrypt_keys.ed25519_privkeys = key_list.data(); multi_decrypt_keys.ed25519_privkeys_len = key_list.size(); - session_protocol_decrypted_envelope decrypt_result = - session_protocol_decrypt_envelope( - &multi_decrypt_keys, - encrypt_result.ciphertext.data, - encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch() - .count(), - pro_backend_ed_pk.data(), - pro_backend_ed_pk.size(), - error, - sizeof(error)); + session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + &multi_decrypt_keys, + encrypt_result.ciphertext.data, + encrypt_result.ciphertext.size, + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); From 1a501110612131470402eb1aee6905e4577f480c Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 21 Aug 2025 11:59:45 +1000 Subject: [PATCH 048/171] Remove the need for ProStatus::Nil by using std::optional --- include/session/session_protocol.hpp | 35 ++++++++----------- src/session_protocol.cpp | 51 +++++++++++++++------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 78fdaf86..2527ea33 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -38,16 +38,12 @@ namespace config::groups { } enum class ProStatus { - // Proof not set - Nil = PRO_STATUS_NIL, - // Proof set; pro proof sig was not produced by the Pro backend key + // Pro proof sig was not signed by the Pro backend key InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, - // Proof set; envelope pro sig was not produced by the Rotating key + // Pro sig in the envelope was not signed by the Rotating key InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, - // Proof set, is verified; has not expired - Valid = PRO_STATUS_VALID, - // Proof set, is verified; has expired - Expired = PRO_STATUS_EXPIRED, + Valid = PRO_STATUS_VALID, // Proof is verified; has not expired + Expired = PRO_STATUS_EXPIRED, // Proof is verified; has expired }; enum class DestinationType { @@ -105,6 +101,14 @@ struct Envelope { array_uc64 pro_sig; }; +struct DecryptedPro { + ProStatus status; // Validity of the proof embedded in the envelope + // Session Pro proof that was embedded in the envelope, this is always populated irrespective of + // the status but the validity of the contents should be verified by checking `status` + config::ProProof proof; + PRO_FEATURES features; // Bit flag features that were used in the embedded message +}; + struct DecryptedEnvelope { // The envelope parsed from the plaintext Envelope envelope; @@ -121,18 +125,9 @@ struct DecryptedEnvelope { // a Groups v2 envelope or it's re-derived from the Ed25519 pubkey. array_uc32 sender_x25519_pubkey; - // Status flag for validity of the Session Pro proof embedded in the envelope if it has one. - // The status is set to `Nil` if there is no Session Pro proof in the message. Otherwise it's - // set to one of the other values to which the remaining pro fields will be populated with data - // parsed from the envelope. - ProStatus pro_status; - - // The embedded Session Pro proof, only set if the status was not `Nil`. - config::ProProof pro_proof; - - // Session Pro bit flag features that were used in the embedded message, only set if the status - // was not `Nil`. - PRO_FEATURES pro_features; + // Set if the envelope included a pro payload. The caller must check the status to determine if + // the embedded pro data/proof was valid, invalid or whether or not the proof has expired. + std::optional pro; }; struct DecryptEnvelopeKey { diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 6bd1e745..805c503c 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -419,6 +419,7 @@ DecryptedEnvelope decrypt_envelope( if (content.has_promessage()) { // Mark the envelope as having a pro signature that the caller can use. result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; + DecryptedPro& pro = result.pro.emplace(); // Extract the pro message const SessionProtos::ProMessage& pro_msg = content.promessage(); @@ -431,7 +432,7 @@ DecryptedEnvelope decrypt_envelope( // Parse the proof from protobufs const SessionProtos::ProProof& proto_proof = pro_msg.proof(); - session::config::ProProof& proof = result.pro_proof; + session::config::ProProof& proof = pro.proof; // clang-format off size_t proof_errors = 0; proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); @@ -451,10 +452,10 @@ DecryptedEnvelope decrypt_envelope( result.content_plaintext.data(), result.content_plaintext.size(), reinterpret_cast(proto_proof.rotatingpublickey().data())); - result.pro_status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; + pro.status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; // Fill out the resulting proof structure, we have parsed successfully - result.pro_features = pro_msg.features(); + pro.features = pro_msg.features(); std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); std::memcpy( @@ -469,16 +470,16 @@ DecryptedEnvelope decrypt_envelope( std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); - if (result.pro_status == ProStatus::Valid) { + if (pro.status == ProStatus::Valid) { // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was // issued by an authoritative backend) if (!proof.verify(pro_backend_pubkey)) - result.pro_status = ProStatus::InvalidProBackendSig; + pro.status = ProStatus::InvalidProBackendSig; // Check if the proof has expired - if (result.pro_status == ProStatus::Valid) { - if (unix_ts > result.pro_proof.expiry_unix_ts) - result.pro_status = ProStatus::Expired; + if (pro.status == ProStatus::Valid) { + if (unix_ts > pro.proof.expiry_unix_ts) + pro.status = ProStatus::Expired; } } } @@ -623,11 +624,25 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( result.envelope.timestamp_ms = static_cast(result_cpp.envelope.timestamp.count()); result.envelope.source_device = result_cpp.envelope.source_device; result.envelope.server_timestamp = result_cpp.envelope.server_timestamp; - result.pro_status = static_cast(result_cpp.pro_status); - result.pro_proof.version = result_cpp.pro_proof.version; - result.pro_proof.expiry_unix_ts = - static_cast(result_cpp.pro_proof.expiry_unix_ts.time_since_epoch().count()); - result.pro_features = result_cpp.pro_features; + + if (result_cpp.pro) { + const DecryptedPro& pro = *result_cpp.pro; + result.pro_status = static_cast(pro.status); + result.pro_proof.version = pro.proof.version; + result.pro_proof.expiry_unix_ts = + static_cast(pro.proof.expiry_unix_ts.time_since_epoch().count()); + result.pro_features = pro.features; + + std::memcpy( + result.pro_proof.gen_index_hash, + pro.proof.gen_index_hash.data(), + sizeof(result.pro_proof.gen_index_hash)); + std::memcpy( + result.pro_proof.rotating_pubkey, + pro.proof.rotating_pubkey.data(), + sizeof(result.pro_proof.rotating_pubkey)); + std::memcpy(result.pro_proof.sig, pro.proof.sig.data(), sizeof(pro.proof.sig)); + } // Since we support multiple keys, if some of the keys failed but one of them succeeded, we will // zero out the error buffer to avoid conflating one of the failures with the function actually @@ -653,16 +668,6 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( result_cpp.sender_x25519_pubkey.data(), sizeof(result.sender_x25519_pubkey)); - std::memcpy( - result.pro_proof.gen_index_hash, - result_cpp.pro_proof.gen_index_hash.data(), - sizeof(result.pro_proof.gen_index_hash)); - std::memcpy( - result.pro_proof.rotating_pubkey, - result_cpp.pro_proof.rotating_pubkey.data(), - sizeof(result.pro_proof.rotating_pubkey)); - std::memcpy( - result.pro_proof.sig, result_cpp.pro_proof.sig.data(), sizeof(result.pro_proof.sig)); return result; } From 01545b7079fcc018a0b096455986b82f784ba52f Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 21 Aug 2025 14:05:50 +1000 Subject: [PATCH 049/171] Add docs to pro config --- include/session/config/pro.h | 48 +++++++++++++++++++++++++++++++----- src/config/pro.cpp | 14 ++++++----- src/config/user_profile.cpp | 4 +-- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index ae1f1eba..fd2da318 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -24,15 +24,51 @@ typedef struct pro_pro_config { pro_proof proof; } pro_pro_config; -LIBSESSION_EXPORT pro_proof pro_proof_init(char const* dump, size_t dump_len); - -LIBSESSION_EXPORT pro_pro_config pro_pro_init(char const* dump, size_t dump_len); - +/// API: pro/pro_proof_hash +/// +/// Generate the 32 byte hash that is to be signed by the rotating key or Session Pro Backend key to +/// embed in the envelope or proof respectively which other clients use to authenticate the validity +/// of a proof. +/// +/// Inputs: +/// - `proof` -- Proof to calculate the hash from +/// +/// Outputs: +/// - `bytes32` -- The 32 byte hash calculated from the proof LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); -LIBSESSION_EXPORT bool pro_proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey); +/// API: pro/pro_proof_verify +/// +/// Verify the proof was signed by the `verify_pubkey` +/// +/// 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_proof_verify( + pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len); -LIBSESSION_EXPORT bool pro_pro_verify(pro_pro_config const* pro, uint8_t const* verify_pubkey); +/// API: pro/pro_verify +/// +/// 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_pro_verify( + pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len); #ifdef __cplusplus } // extern "C" diff --git a/src/config/pro.cpp b/src/config/pro.cpp index d2cfa4fa..30c76ef9 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -164,9 +164,11 @@ LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { return result; } -LIBSESSION_C_API bool pro_proof_verify(pro_proof const* proof, uint8_t const* verify_pubkey) { - auto verify_pubkey_span = - std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); +LIBSESSION_C_API bool pro_proof_verify( + pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { + if (verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) + return false; + auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); auto gen_index_hash = std::span(proof->gen_index_hash, sizeof proof->gen_index_hash); auto rotating_pubkey = @@ -179,9 +181,9 @@ LIBSESSION_C_API bool pro_proof_verify(pro_proof const* proof, uint8_t const* ve return result; } -LIBSESSION_C_API bool pro_pro_verify(pro_pro_config const* pro, uint8_t const* verify_pubkey) { - auto verify_pubkey_span = - std::span(verify_pubkey, crypto_sign_ed25519_PUBLICKEYBYTES); +LIBSESSION_C_API bool pro_pro_verify( + pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { + auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); auto rotating_privkey = std::span(pro->rotating_privkey, sizeof pro->rotating_privkey); auto gen_index_hash = std::span( diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 86669b8b..ba36a51b 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -278,7 +278,7 @@ LIBSESSION_C_API int64_t user_profile_get_profile_updated(config_object* conf) { return unbox(conf)->get_profile_updated().time_since_epoch().count(); } -LIBSESSION_C_API bool user_profile_get_pro_data(const config_object* conf, pro_pro_config* pro) { +LIBSESSION_C_API bool user_profile_get_pro_config(const config_object* conf, pro_pro_config* pro) { if (auto val = unbox(conf)->get_pro_config(); val) { static_assert(sizeof pro->proof.gen_index_hash == sizeof(val->proof.gen_index_hash)); static_assert(sizeof pro->proof.rotating_pubkey == sizeof(val->proof.rotating_pubkey)); @@ -299,7 +299,7 @@ LIBSESSION_C_API bool user_profile_get_pro_data(const config_object* conf, pro_p return false; } -LIBSESSION_C_API void user_profile_set_pro_data(config_object* conf, const pro_pro_config* pro) { +LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro_pro_config* pro) { ProConfig val = {}; val.proof.version = pro->proof.version; std::memcpy( From c03d138df8a2e40f3af5aac7281fab990c5cfb96 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 21 Aug 2025 16:00:26 +1000 Subject: [PATCH 050/171] Add helper functions for getting PRO_STATUS from proof standalone from decryption --- include/session/config/pro.h | 94 ++++++++++++++- include/session/config/pro.hpp | 83 ++++++++++++- include/session/session_protocol.h | 8 -- include/session/session_protocol.hpp | 11 +- src/config/pro.cpp | 167 +++++++++++++++++++++------ src/session_protocol.cpp | 47 ++++---- tests/test_config_pro.cpp | 116 ++++++++++++++----- 7 files changed, 407 insertions(+), 119 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index fd2da318..df2b155c 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -11,6 +11,19 @@ extern "C" { #include "../export.h" #include "../types.h" +typedef enum PRO_STATUS { // See session::ProStatus + PRO_STATUS_NIL, + PRO_STATUS_INVALID_PRO_BACKEND_SIG, + PRO_STATUS_INVALID_USER_SIG, + PRO_STATUS_VALID, + PRO_STATUS_EXPIRED, +} PRO_STATUS; + +typedef struct pro_signed_message { + span_u8 sig; + span_u8 msg; +} pro_signed_message; + typedef struct pro_proof { uint8_t version; uint8_t gen_index_hash[32]; @@ -19,7 +32,7 @@ typedef struct pro_proof { uint8_t sig[64]; } pro_proof; -typedef struct pro_pro_config { +typedef struct pro_config { uint8_t rotating_privkey[64]; pro_proof proof; } pro_pro_config; @@ -37,7 +50,7 @@ typedef struct pro_pro_config { /// - `bytes32` -- The 32 byte hash calculated from the proof LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); -/// API: pro/pro_proof_verify +/// API: pro/pro_proof_verify_signature /// /// Verify the proof was signed by the `verify_pubkey` /// @@ -49,10 +62,79 @@ LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); /// 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_proof_verify( +/// - `bool` -- True if verified, false otherwise +LIBSESSION_EXPORT bool pro_proof_verify_signature( pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len); +/// API: pro/pro_proof_verify_message +/// +/// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature +/// passed in. This function throws if an signature is passed in that isn't 64 bytes. +/// +/// Inputs: +/// - `proof` -- Proof to verify +/// - `sig` -- Signature to verify with the `rotating_pubkey`. The signature should have +/// originally been signed over `msg` passed in. +/// - `sig_len` -- Length of the signature, should be 64 bytes +/// - `msg` -- Message that the signature signed over with. It will be verified using the +/// embedded `rotating_pubkey`. +/// - `msg_len` -- Length of the message +/// +/// Outputs: +/// - `bool` -- True if verified, false otherwise (bad signature, or, invalid arguments). +LIBSESSION_EXPORT bool pro_proof_verify_message( + pro_proof const* proof, + uint8_t const* sig, + size_t sig_len, + uint8_t const* msg, + size_t msg_len); + +/// API: pro/pro_proof_is_active +/// +/// Check if the Pro proof is currently entitled to Pro given the `unix_ts` with respect to the +/// proof's `expiry_unix_ts` +/// +/// Inputs: +/// - `proof` -- Proof to verify +/// - `unix_ts_s` -- The unix timestamp in seconds to check the proof expiry time against +/// +/// Outputs: +/// - `bool` -- True if expired, false otherwise +LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s); + +/// API: pro/pro_proof_status +/// +/// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has +/// not expired via `unix_ts_s` and optionally verify that the `signed_msg` was signed by the +/// `rotating_pubkey` embedded in the proof. +/// +/// Internally this function calls `pro_proof_verify_signature`, `pro_proof_verify_message` and +/// optionally `pro_proof_is_active` in sequence. This function fails if an invalidly sized public +/// key or signature are passed in. They must be 32 and 64 bytes respectively, the appropriate +/// invalid status will be returned. +/// +/// Inputs: +/// - `proof` -- Proof to verify +/// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if +/// they are the original signatory of the proof. +/// - `verify_pubkey_len` -- Length of the `verify_pubkey` should be 32 bytes +/// they are the original signatory of the proof. +/// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` +/// to determine if the proof has expired or not +/// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if +/// the embedded `rotating_pubkey` in the proof signed the given message. +/// +/// Outputs: +/// - `status` - The derived status given the components of the message. If `signed_msg` is +/// not set then this function can never return `PRO_STATUS_INVALID_USER_SIG` from the set of +/// possible enum values. Otherwise this funtion can return all possible values. +LIBSESSION_EXPORT PRO_STATUS pro_proof_status( + pro_proof const* proof, + const uint8_t* verify_pubkey, + size_t verify_pubkey_len, + uint64_t unix_ts_s, + const pro_signed_message* signed_msg); + /// API: pro/pro_verify /// /// Verify the proof was signed by the `verify_pubkey` and that the `rotating_privkey` in the `pro` @@ -67,8 +149,8 @@ LIBSESSION_EXPORT bool pro_proof_verify( /// /// Outputs: /// - `bytes32` -- The 32 byte hash calculated from the proof -LIBSESSION_EXPORT bool pro_pro_verify( - pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len); +LIBSESSION_EXPORT bool pro_config_verify_signature( + pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len); #ifdef __cplusplus } // extern "C" diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index a2b35f31..011abc77 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -11,6 +13,20 @@ namespace session::config { enum ProProofVersion { ProProofVersion_v0 }; +enum class ProStatus { + // Pro proof sig was not signed by the Pro backend key + InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, + // Pro sig in the envelope was not signed by the Rotating key + InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, + Valid = PRO_STATUS_VALID, // Proof is verified; has not expired + Expired = PRO_STATUS_EXPIRED, // Proof is verified; has expired +}; + +struct ProSignedMessage { + std::span sig; + std::span msg; +}; + /// keys used currently or in the past (so that we don't reuse): /// /// @ - version @@ -39,21 +55,76 @@ class ProProof { /// clients. array_uc64 sig; - /// API: pro/Proof::verify + /// API: pro/Proof::verify_signature /// /// Verify that the proof's contents was not tampered with by hashing the proof and checking /// that the hash was signed by the secret key of the given Ed25519 public key. /// /// For Session Pro intents and purposes, we expect proofs to be signed by the Session Pro - /// Backend public key. + /// Backend public key. This function throws if an incorrectly sized key is passed in. /// /// Inputs: - /// - `verify_pubkey` -- Ed25519 public key of the corresponding secret key to check if they are - /// the original signatory of the proof. + /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if + /// they are the original signatory of the proof. /// /// Outputs: /// - `bool` - True if the given key was the signatory of the proof, false otherwise - bool verify(const array_uc32& verify_pubkey) const; + bool verify_signature(const std::span& verify_pubkey) const; + + /// API: pro/Proof::verify_message + /// + /// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature + /// passed in. This function throws if an signature is passed in that isn't 64 bytes. + /// + /// Inputs: + /// - `sig` -- Signature to verify with the `rotating_pubkey`. The signature should have + /// originally been signed over `msg` passed in. + /// - `msg` -- Message that the signature signed over with. It will be verified using the + /// embedded `rotating_pubkey`. + /// + /// Outputs: + /// - `bool` - True if the message was signed by the embedded `rotating_pubkey` false otherwise. + bool verify_message(std::span sig, const std::span msg) const; + + /// API: pro/Proof::is_active + /// + /// Check if Pro proof is currently entitled to Pro given the `unix_ts` with respect to the + /// proof's `expiry_unix_ts` + /// + /// Inputs: + /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` + /// to determine if the proof has expired or not + /// + /// Outputs: + /// - `bool` - True if proof is active (i.e. has not expired), false otherwise. + bool is_active(std::chrono::sys_seconds unix_ts) const; + + /// API: pro/Proof::status + /// + /// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has + /// not expired via `unix_ts` and optionally verify that the `signed_msg` was signed by the + /// `rotating_pubkey` embedded in the proof. + /// + /// Internally this function calls `verify_signature`, `verify_message` and optionally + /// `is_active` in sequence. This function throws if an invalidly sized public key or signature + /// are passed in. They must be 32 and 64 bytes respectively. + /// + /// Inputs: + /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if + /// they are the original signatory of the proof. + /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` + /// to determine if the proof has expired or not + /// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if + /// the embedded `rotating_pubkey` in the proof signed the given message. + /// + /// Outputs: + /// - `ProStatus` - The derived status given the components of the message. If `signed_msg` is + /// not set then this function can never return `ProStatus::InvalidUserSig` from the set of + /// possible enum values. Otherwise this funtion can return all possible values. + ProStatus status( + std::span verify_pubkey, + std::chrono::sys_seconds unix_ts, + const std::optional& signed_msg); /// API: pro/Proof::hash /// @@ -89,7 +160,7 @@ class ProConfig { /// Outputs: /// - `bool` - True if the proof was verified and the proof's rotating public key corresponds to /// the public component of the `rotating_privkey`. - bool verify(const array_uc32& verify_pubkey) const; + bool verify_signature(const array_uc32& verify_pubkey) const; bool load(const dict& root); }; diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index dc4ff135..90300122 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -53,14 +53,6 @@ enum PRO_FEATURES_ { PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR }; -typedef enum PRO_STATUS { // See session::ProStatus - PRO_STATUS_NIL, - PRO_STATUS_INVALID_PRO_BACKEND_SIG, - PRO_STATUS_INVALID_USER_SIG, - PRO_STATUS_VALID, - PRO_STATUS_EXPIRED, -} PRO_STATUS; - typedef enum DESTINATION_TYPE { // See session::DestinationType DESTINATION_TYPE_CONTACT, DESTINATION_TYPE_SYNC_MESSAGE, diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 2527ea33..b38ab116 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -37,15 +37,6 @@ namespace config::groups { class Keys; } -enum class ProStatus { - // Pro proof sig was not signed by the Pro backend key - InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, - // Pro sig in the envelope was not signed by the Rotating key - InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, - Valid = PRO_STATUS_VALID, // Proof is verified; has not expired - Expired = PRO_STATUS_EXPIRED, // Proof is verified; has expired -}; - enum class DestinationType { Contact = DESTINATION_TYPE_CONTACT, SyncMessage = DESTINATION_TYPE_SYNC_MESSAGE, @@ -102,7 +93,7 @@ struct Envelope { }; struct DecryptedPro { - ProStatus status; // Validity of the proof embedded in the envelope + config::ProStatus status; // Validity of the proof embedded in the envelope // Session Pro proof that was embedded in the envelope, this is always populated irrespective of // the status but the validity of the contents should be verified by checking `status` config::ProProof proof; diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 30c76ef9..281a5c2a 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -26,7 +26,7 @@ session::array_uc32 proof_hash_internal( return result; } -bool proof_verify_internal( +bool proof_verify_signature_internal( std::span hash, std::span sig, std::span verify_pubkey) { @@ -35,13 +35,14 @@ bool proof_verify_internal( assert(hash.size() == 32); assert(sig.size() == crypto_sign_ed25519_BYTES); assert(verify_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + int verify_result = crypto_sign_ed25519_verify_detached( sig.data(), hash.data(), hash.size(), verify_pubkey.data()); bool result = verify_result == 0; return result; } -bool pro_verify_internal( +bool config_verify_signature_internal( std::span rotating_privkey, std::span verify_pubkey, std::uint8_t version, @@ -52,7 +53,7 @@ bool pro_verify_internal( session::array_uc32 hash = proof_hash_internal(version, gen_index_hash, rotating_pubkey, expiry_unix_ts); - if (!proof_verify_internal(hash, sig, verify_pubkey)) + if (!proof_verify_signature_internal(hash, sig, verify_pubkey)) return false; session::array_uc32 rederived_pk; @@ -67,6 +68,28 @@ bool pro_verify_internal( return result; } +bool proof_verify_message_internal( + std::span rotating_pubkey, + std::span sig, + std::span msg) { + // C++ throws on bad size, C uses a fixed sized array + assert(rotating_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + if (sig.size() != crypto_sign_ed25519_BYTES) + return false; + + int verify_result = crypto_sign_ed25519_verify_detached( + reinterpret_cast(sig.data()), + msg.data(), + msg.size(), + reinterpret_cast(rotating_pubkey.data())); + bool result = verify_result == 0; + return result; +} + +bool proof_is_active_internal(uint64_t expiry_unix_ts, uint64_t unix_ts_s) { + bool result = unix_ts_s <= expiry_unix_ts; + return result; +} } // namespace namespace session::config { @@ -76,9 +99,50 @@ static_assert(sizeof(((ProProof*)0)->gen_index_hash) == 32); static_assert(sizeof(((ProProof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); static_assert(sizeof(((ProProof*)0)->sig) == crypto_sign_ed25519_BYTES); -bool ProProof::verify(const array_uc32& verify_pubkey) const { +bool ProProof::verify_signature(const std::span& verify_pubkey) const { + if (verify_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) + throw std::invalid_argument{fmt::format( + "Invalid verify_pubkey: Must be 32 byte Ed25519 public key (was: {})", + verify_pubkey.size())}; + array_uc32 hash_to_sign = hash(); - bool result = proof_verify_internal(hash_to_sign, sig, verify_pubkey); + bool result = proof_verify_signature_internal(hash_to_sign, sig, verify_pubkey); + return result; +} + +bool ProProof::verify_message(std::span sig, std::span msg) const { + if (sig.size() != crypto_sign_ed25519_BYTES) + throw std::invalid_argument{fmt::format( + "Invalid signed_msg: Signature must be 64 bytes (was: {})", sig.size())}; + bool result = proof_verify_message_internal(rotating_pubkey, sig, msg); + return result; +} + +bool ProProof::is_active(std::chrono::sys_seconds unix_ts) const { + bool result = proof_is_active_internal( + expiry_unix_ts.time_since_epoch().count(), unix_ts.time_since_epoch().count()); + return result; +} + +ProStatus ProProof::status( + std::span verify_pubkey, + std::chrono::sys_seconds unix_ts, + const std::optional& signed_msg) { + ProStatus result = ProStatus::Valid; + // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was + // issued by an authoritative backend) + if (!verify_signature(verify_pubkey)) + result = ProStatus::InvalidProBackendSig; + + // Check if the message was signed if the user passed one in to verify against + if (result == ProStatus::Valid && signed_msg) { + if (!verify_message(signed_msg->sig, signed_msg->msg)) + result = ProStatus::InvalidUserSig; + } + + // Check if the proof has expired + if (result == ProStatus::Valid && !is_active(unix_ts)) + result = ProStatus::Expired; return result; } @@ -113,9 +177,9 @@ bool ProProof::load(const dict& root) { return true; } -bool ProConfig::verify(const array_uc32& verify_pubkey) const { +bool ProConfig::verify_signature(const array_uc32& verify_pubkey) const { uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); - bool result = pro_verify_internal( + bool result = config_verify_signature_internal( rotating_privkey, verify_pubkey, proof.version, @@ -157,48 +221,83 @@ static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PU static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { - session::array_uc32 hash = proof_hash_internal( - proof->version, proof->gen_index_hash, proof->rotating_pubkey, proof->expiry_unix_ts); bytes32 result = {}; - std::memcpy(result.data, hash.data(), hash.size()); + if (proof) { + session::array_uc32 hash = proof_hash_internal( + proof->version, + proof->gen_index_hash, + proof->rotating_pubkey, + proof->expiry_unix_ts); + std::memcpy(result.data, hash.data(), hash.size()); + } return result; } -LIBSESSION_C_API bool pro_proof_verify( +LIBSESSION_C_API bool pro_proof_verify_signature( pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { - if (verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) + if (!proof || verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) return false; auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); - auto gen_index_hash = - std::span(proof->gen_index_hash, sizeof proof->gen_index_hash); - auto rotating_pubkey = - std::span(proof->rotating_pubkey, sizeof proof->rotating_pubkey); - auto sig = std::span(proof->sig, sizeof proof->sig); - session::array_uc32 hash = proof_hash_internal( - proof->version, gen_index_hash, rotating_pubkey, proof->expiry_unix_ts); - bool result = proof_verify_internal(hash, sig, verify_pubkey_span); + proof->version, proof->gen_index_hash, proof->rotating_pubkey, proof->expiry_unix_ts); + bool result = proof_verify_signature_internal(hash, proof->sig, verify_pubkey_span); + return result; +} + +LIBSESSION_C_API bool pro_proof_verify_message( + pro_proof const* proof, + uint8_t const* sig, + size_t sig_len, + uint8_t const* msg, + size_t msg_len) { + std::span sig_span = {sig, sig_len}; + std::span msg_span = {msg, msg_len}; + bool result = proof_verify_message_internal(proof->rotating_pubkey, sig_span, msg_span); return result; } -LIBSESSION_C_API bool pro_pro_verify( +LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) { + bool result = proof && proof_is_active_internal(proof->expiry_unix_ts, unix_ts_s); + return result; +} + +LIBSESSION_C_API PRO_STATUS pro_proof_status( + pro_proof const* proof, + const uint8_t* verify_pubkey, + size_t verify_pubkey_len, + uint64_t unix_ts_s, + const pro_signed_message* signed_msg) { + PRO_STATUS result = PRO_STATUS_VALID; + if (!pro_proof_verify_signature(proof, verify_pubkey, verify_pubkey_len)) + result = PRO_STATUS_INVALID_PRO_BACKEND_SIG; + + // Check if the message was signed if the user passed one in to verify against + if (result == PRO_STATUS_VALID && signed_msg) { + if (!pro_proof_verify_message( + proof, + signed_msg->sig.data, + signed_msg->sig.size, + signed_msg->msg.data, + signed_msg->msg.size)) + result = PRO_STATUS_INVALID_USER_SIG; + } + + // Check if the proof has expired + if (result == PRO_STATUS_VALID && !pro_proof_is_active(proof, unix_ts_s)) + result = PRO_STATUS_EXPIRED; + return result; +} + +LIBSESSION_C_API bool pro_config_verify_signature( pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); - auto rotating_privkey = - std::span(pro->rotating_privkey, sizeof pro->rotating_privkey); - auto gen_index_hash = std::span( - pro->proof.gen_index_hash, sizeof pro->proof.gen_index_hash); - auto rotating_pubkey = std::span( - pro->proof.rotating_pubkey, sizeof pro->proof.rotating_pubkey); - auto sig = std::span(pro->proof.sig, sizeof pro->proof.sig); - - bool result = pro_verify_internal( - rotating_privkey, + bool result = config_verify_signature_internal( + pro->rotating_privkey, verify_pubkey_span, pro->proof.version, - gen_index_hash, - rotating_pubkey, + pro->proof.gen_index_hash, + pro->proof.rotating_pubkey, pro->proof.expiry_unix_ts, - sig); + pro->proof.sig); return result; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 805c503c..aaefed27 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -445,15 +445,6 @@ DecryptedEnvelope decrypt_envelope( throw std::runtime_error( "Parse decrypted message failed, pro metadata was malformed"); - // Verify the sig since we have extracted the rotating public key from the embedded - // proof - int verify_result = crypto_sign_ed25519_verify_detached( - reinterpret_cast(pro_sig.data()), - result.content_plaintext.data(), - result.content_plaintext.size(), - reinterpret_cast(proto_proof.rotatingpublickey().data())); - pro.status = verify_result == 0 ? ProStatus::Valid : ProStatus::InvalidUserSig; - // Fill out the resulting proof structure, we have parsed successfully pro.features = pro_msg.features(); std::memcpy(result.envelope.pro_sig.data(), pro_sig.data(), pro_sig.size()); @@ -470,18 +461,12 @@ DecryptedEnvelope decrypt_envelope( std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); - if (pro.status == ProStatus::Valid) { - // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was - // issued by an authoritative backend) - if (!proof.verify(pro_backend_pubkey)) - pro.status = ProStatus::InvalidProBackendSig; - - // Check if the proof has expired - if (pro.status == ProStatus::Valid) { - if (unix_ts > pro.proof.expiry_unix_ts) - pro.status = ProStatus::Expired; - } - } + // Evaluate the pro status given the extracted components (was it signed, is it expired, + // was the message signed validly?) + config::ProSignedMessage signed_msg = {}; + signed_msg.sig = to_span(pro_sig); + signed_msg.msg = result.content_plaintext; + pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); } } return result; @@ -563,9 +548,19 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( // Setup the pro backend pubkey array_uc32 pro_backend_pubkey_cpp = {}; - if (pro_backend_pubkey_len != sizeof(pro_backend_pubkey_cpp)) - return result; - std::memcpy(pro_backend_pubkey_cpp.data(), pro_backend_pubkey, pro_backend_pubkey_len); + if (pro_backend_pubkey) { + if (pro_backend_pubkey_len != sizeof(pro_backend_pubkey_cpp)) { + result.error_len_incl_null_terminator = std::snprintf( + error, + error_len, + "Invalid pro_backend_pubkey: Key was " + "set but was not 32 bytes, was: %zu", + pro_backend_pubkey_len) + + 1; + return result; + } + std::memcpy(pro_backend_pubkey_cpp.data(), pro_backend_pubkey, pro_backend_pubkey_len); + } // Setup decryption keys and decrypt DecryptEnvelopeKey keys_cpp = {}; @@ -645,8 +640,8 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( } // Since we support multiple keys, if some of the keys failed but one of them succeeded, we will - // zero out the error buffer to avoid conflating one of the failures with the function actually - // succeeding. + // zero out the error buffer to avoid conflating one of the failures when the function actually + // succeeded. if (result.success) result.error_len_incl_null_terminator = 0; diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 8ef9e38a..9937c659 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -8,7 +9,7 @@ using namespace oxenc::literals; TEST_CASE("Pro", "[config][pro]") { // Setup keys - std::array rotating_pk, signing_pk; + std::array rotating_pk, signing_pk; session::cleared_uc64 rotating_sk, signing_sk; { crypto_sign_ed25519_keypair(rotating_pk.data(), rotating_sk.data()); @@ -16,43 +17,100 @@ TEST_CASE("Pro", "[config][pro]") { } // Setup the Pro data structure - session::config::ProConfig pro = {}; + session::config::ProConfig pro_cpp = {}; + pro_config pro = {}; { - pro.rotating_privkey = rotating_sk; - pro.proof.version = 0; - pro.proof.rotating_pubkey = rotating_pk; - pro.proof.expiry_unix_ts = std::chrono::sys_seconds(1s); - + // CPP + pro_cpp.rotating_privkey = rotating_sk; + pro_cpp.proof.version = 0; + pro_cpp.proof.rotating_pubkey = rotating_pk; + pro_cpp.proof.expiry_unix_ts = std::chrono::sys_seconds(1s); constexpr auto gen_index_hash = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hex_u; - static_assert(pro.proof.gen_index_hash.max_size() == gen_index_hash.size()); - std::memcpy(pro.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); + static_assert(pro_cpp.proof.gen_index_hash.max_size() == gen_index_hash.size()); + std::memcpy( + pro_cpp.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); + + // C + std::memcpy(pro.rotating_privkey, rotating_sk.data(), rotating_sk.size()); + pro.proof.version = pro_cpp.proof.version; + std::memcpy(pro.proof.rotating_pubkey, rotating_pk.data(), rotating_pk.size()); + pro.proof.expiry_unix_ts = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro.proof.gen_index_hash, gen_index_hash.data(), gen_index_hash.size()); } - // Do the signing + // Generate and write the hashes that are signed by the faux pro backend into the proof { - static_assert(crypto_sign_ed25519_BYTES == pro.proof.sig.max_size()); - std::array hash_to_sign = pro.proof.hash(); + // Generate the hashes + static_assert(crypto_sign_ed25519_BYTES == pro_cpp.proof.sig.max_size()); + std::array hash_to_sign_cpp = pro_cpp.proof.hash(); + bytes32 hash_to_sign = pro_proof_hash(&pro.proof); + + static_assert(hash_to_sign_cpp.size() == sizeof(hash_to_sign)); + CHECK(std::memcmp(hash_to_sign_cpp.data(), hash_to_sign.data, hash_to_sign_cpp.size()) == + 0); + + // Write the signature into the proof int sig_result = crypto_sign_ed25519_detached( - pro.proof.sig.data(), + pro_cpp.proof.sig.data(), nullptr, - hash_to_sign.data(), - hash_to_sign.size(), + hash_to_sign_cpp.data(), + hash_to_sign_cpp.size(), + signing_sk.data()); + CHECK(sig_result == 0); + + sig_result = crypto_sign_ed25519_detached( + pro.proof.sig, + nullptr, + hash_to_sign.data, + sizeof(hash_to_sign.data), signing_sk.data()); CHECK(sig_result == 0); } - // Verify the proof + // Verify the signature in the proof was signed by the faux pro backend key "signing_sk" { - CHECK_FALSE(pro.verify(rotating_pk)); - CHECK(pro.verify(signing_pk)); + CHECK_FALSE(pro_cpp.verify_signature(rotating_pk)); + CHECK(pro_cpp.verify_signature(signing_pk)); + + CHECK_FALSE(pro_config_verify_signature(&pro, rotating_pk.data(), rotating_pk.size())); + CHECK(pro_config_verify_signature(&pro, signing_pk.data(), signing_pk.size())); + } + + // Verify expiry + { + CHECK(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts)); + CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1s)); + + CHECK(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts)); + CHECK_FALSE(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts + 1)); + } + + // Verify it can verify messages signed with the rotating public key + { + std::string_view body = "hello world"; + std::array sig = {}; + int sign_result = crypto_sign_ed25519_detached( + sig.data(), + nullptr, + reinterpret_cast(body.data()), + body.size(), + rotating_sk.data()); + CHECK(sign_result == 0); + CHECK(pro_cpp.proof.verify_message(sig, session::to_span(body))); + CHECK(pro_proof_verify_message( + &pro.proof, + sig.data(), + sig.size(), + reinterpret_cast(body.data()), + body.size())); } // Try loading the proof from dict session::config::dict good_dict; { // clang-format off - const session::config::ProProof& proof = pro.proof; + const session::config::ProProof& proof = pro_cpp.proof; good_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ @@ -67,23 +125,23 @@ TEST_CASE("Pro", "[config][pro]") { session::config::ProConfig loaded_pro = {}; CHECK(loaded_pro.load(good_dict)); - CHECK(loaded_pro.rotating_privkey == pro.rotating_privkey); - CHECK(loaded_pro.proof.version == pro.proof.version); - CHECK(loaded_pro.proof.gen_index_hash == pro.proof.gen_index_hash); - CHECK(loaded_pro.proof.rotating_pubkey == pro.proof.rotating_pubkey); - CHECK(loaded_pro.proof.expiry_unix_ts == pro.proof.expiry_unix_ts); - CHECK(loaded_pro.proof.sig == pro.proof.sig); - CHECK(loaded_pro.verify(signing_pk)); + CHECK(loaded_pro.rotating_privkey == pro_cpp.rotating_privkey); + CHECK(loaded_pro.proof.version == pro_cpp.proof.version); + CHECK(loaded_pro.proof.gen_index_hash == pro_cpp.proof.gen_index_hash); + CHECK(loaded_pro.proof.rotating_pubkey == pro_cpp.proof.rotating_pubkey); + CHECK(loaded_pro.proof.expiry_unix_ts == pro_cpp.proof.expiry_unix_ts); + CHECK(loaded_pro.proof.sig == pro_cpp.proof.sig); + CHECK(loaded_pro.verify_signature(signing_pk)); } // Try loading a proof with a bad signature in it from dict { session::config::dict bad_dict = good_dict; - std::array broken_sig = pro.proof.sig; + std::array broken_sig = pro_cpp.proof.sig; broken_sig[0] = ~broken_sig[0]; // Break the sig // clang-format off - const session::config::ProProof& proof = pro.proof; + const session::config::ProProof& proof = pro_cpp.proof; bad_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ @@ -98,6 +156,6 @@ TEST_CASE("Pro", "[config][pro]") { session::config::ProConfig loaded_pro = {}; CHECK(loaded_pro.load(bad_dict)); - CHECK_FALSE(loaded_pro.verify(signing_pk)); + CHECK_FALSE(loaded_pro.verify_signature(signing_pk)); } } From cac29fb9e1e08ce2a084dfca5d639f692007f8aa Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 25 Aug 2025 10:26:28 +1000 Subject: [PATCH 051/171] Re-add missing wrapping of 1o1 messages Was mistakenly removed, upon review of iOS code 1o1s are wrapped in an envelope. --- include/session/session_protocol.h | 6 +- include/session/session_protocol.hpp | 6 +- src/session_protocol.cpp | 142 +++++++++++++++++++-------- 3 files changed, 107 insertions(+), 47 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 90300122..07e56014 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -213,9 +213,9 @@ LIBSESSION_EXPORT void session_protocol_encrypt_for_destination_free( /// API: session_protocol/session_protocol_decrypt_envelope /// -/// Given an envelope payload (i.e.: protobuf encoded stream of `Envelope` or encrypted `Envelope` -/// using a Groups v2 key) parse (or decrypt) the envelope and return the envelope content decrypted -/// if necessary. +/// Given an envelope payload (i.e.: protobuf encoded stream of `WebsocketRequestMessage` which +/// wraps an `Envelope` for 1o1 messages/sync messages, or `Envelope` encrypted using a Groups v2 +/// key) parse (or decrypt) the envelope and return the envelope content decrypted if necessary. /// /// A groups v2 envelope will get decrypted with the group keys. A non-groups v2 envelope will get /// decrypted with the specified Ed25519 private key in the `keys` object. Only one of these keys diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index b38ab116..7c2016a9 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -224,9 +224,9 @@ EncryptedForDestination encrypt_for_destination( /// API: session_protocol/decrypt_envelope /// -/// Given an envelope payload (i.e.: protobuf encoded stream of `Envelope` or encrypted `Envelope` -/// using a Groups v2 key) parse (or decrypt) the envelope and return the envelope content decrypted -/// if necessary. +/// Given an envelope payload (i.e.: protobuf encoded stream of `WebsocketRequestMessage` which +/// wraps an `Envelope` for 1o1 messages/sync messages, or `Envelope` encrypted using a Groups v2 +/// key) parse (or decrypt) the envelope and return the envelope content decrypted if necessary. /// /// A groups v2 envelope will get decrypted with the group keys. A non-groups v2 envelope will get /// decrypted with the specified Ed25519 private key in the `keys` object. Only one of these keys diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index aaefed27..05197349 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -73,6 +73,14 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( EncryptForBlindedRecipient, }; + // The step to partake after enveloping the content payload + enum class AfterEnvelope { + Nil, + EnvelopeIsCipherText, // No extra bit-mangling required after enveloping + WrapInWSMessage, // Wrap in the protobuf websocket message after enveloping + KeysEncryptMessage, // Encrypt with the group keys after ennveloping + }; + struct EncodeContext { Mode mode; // Parameters for BuildMode => Envelope @@ -88,7 +96,8 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( // Type of message to mark the enevelope as std::optional envelope_type; - bool after_envelope_keys_encrypt_message; // Encrypt with group keys + // Action to take after generating the envelope (e.g.: further encryption/wrapping) + AfterEnvelope after_envelope; }; // Figure out how to encrypt the message based on the destination and setup the encoding context @@ -101,7 +110,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( if (space == config::Namespace::GroupMessages) { enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = false; - enc.after_envelope_keys_encrypt_message = true; + enc.after_envelope = AfterEnvelope::KeysEncryptMessage; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; } else if (space == config::Namespace::RevokedRetrievableGroupMessages) { @@ -124,7 +133,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; - enc.after_envelope_keys_encrypt_message = false; + enc.after_envelope = AfterEnvelope::WrapInWSMessage; } else { // See: // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L498 @@ -136,7 +145,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; - enc.after_envelope_keys_encrypt_message = false; + enc.after_envelope = AfterEnvelope::WrapInWSMessage; } break; case DestinationType::Community: { @@ -183,37 +192,69 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } result.encrypted = true; - if (enc.after_envelope_keys_encrypt_message) { - std::string bytes = envelope.SerializeAsString(); - if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) - dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); - - std::vector ciphertext = encrypt_for_group( - ed25519_privkey, - dest_group_ed25519_pubkey, - dest_group_ed25519_privkey, - to_span(bytes), - /*compress*/ true, - /*padding*/ 256); - - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = - span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); - } else { - result.ciphertext_cpp = std::move(ciphertext); - } - } else { - [[maybe_unused]] bool serialized = false; - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); - serialized = envelope.SerializeToArray( - result.ciphertext_c.data, result.ciphertext_c.size); - } else { - result.ciphertext_cpp.resize(envelope.ByteSizeLong()); - serialized = envelope.SerializeToArray( - result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); - } - assert(serialized); + switch (enc.after_envelope) { + case AfterEnvelope::Nil: + assert(false && "Dev error, after envelope action was not set"); + break; + + case AfterEnvelope::KeysEncryptMessage: { + std::string bytes = envelope.SerializeAsString(); + if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) + dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); + + std::vector ciphertext = encrypt_for_group( + ed25519_privkey, + dest_group_ed25519_pubkey, + dest_group_ed25519_privkey, + to_span(bytes), + /*compress*/ true, + /*padding*/ 256); + + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = + span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + } else { + result.ciphertext_cpp = std::move(ciphertext); + } + } break; + + case AfterEnvelope::WrapInWSMessage: { + // Setup message + WebSocketProtos::WebSocketMessage msg = {}; + msg.set_type( + WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); + + // Make request + WebSocketProtos::WebSocketRequestMessage* req_msg = msg.mutable_request(); + req_msg->set_body(envelope.SerializeAsString()); + + // Write message as ciphertext + [[maybe_unused]] bool serialized = false; + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_alloc_or_throw(msg.ByteSizeLong()); + serialized = msg.SerializeToArray( + result.ciphertext_c.data, result.ciphertext_c.size); + } else { + result.ciphertext_cpp.resize(msg.ByteSizeLong()); + serialized = msg.SerializeToArray( + result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); + } + assert(serialized); + } break; + + case AfterEnvelope::EnvelopeIsCipherText: { + [[maybe_unused]] bool serialized = false; + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); + serialized = envelope.SerializeToArray( + result.ciphertext_c.data, result.ciphertext_c.size); + } else { + result.ciphertext_cpp.resize(envelope.ByteSizeLong()); + serialized = envelope.SerializeToArray( + result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); + } + assert(serialized); + } break; } } break; @@ -278,8 +319,9 @@ DecryptedEnvelope decrypt_envelope( // The caller is indicating that the envelope_payload is encrypted, if the group keys are // provided. We will decrypt the payload to get the plaintext. In all other cases, the envelope - // is assumed to be unencrypted and can be used verbatim. - std::vector envelope_plaintext_from_group_keys; + // is assumed to be websocket wrapped + std::vector envelope_from_decrypted_groups; + std::string envelope_from_websocket_message; if (keys.group_ed25519_pubkey) { // Decrypt using the keys DecryptGroupMessage decrypt = decrypt_group_message( @@ -292,8 +334,8 @@ DecryptedEnvelope decrypt_envelope( decrypt.session_id.size())}; // Update the plaintext to use the decrypted envelope - envelope_plaintext_from_group_keys = std::move(decrypt.plaintext); - envelope_plaintext = envelope_plaintext_from_group_keys; + envelope_from_decrypted_groups = std::move(decrypt.plaintext); + envelope_plaintext = envelope_from_decrypted_groups; // Copy keys out assert(decrypt.session_id.starts_with("05")); @@ -301,6 +343,25 @@ DecryptedEnvelope decrypt_envelope( decrypt.session_id.begin() + 2, decrypt.session_id.end() - 2, result.sender_x25519_pubkey.begin()); + } else { + // Assumed to be a 1o1/sync message which is wrapped in a websocket message + WebSocketProtos::WebSocketMessage ws_msg; + if (!ws_msg.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) + throw std::runtime_error{fmt::format( + "Parse websocket wrapped envelope from payload failed: {}", + envelope_plaintext.size())}; + + if (!ws_msg.has_request()) + throw std::runtime_error{"Parse websocket wrapped envelope failed, missing request"}; + + if (!ws_msg.request().has_body()) + throw std::runtime_error{ + "Parse websocket wrapped envelope failed, missing request body"}; + + WebSocketProtos::WebSocketRequestMessage* request = ws_msg.mutable_request(); + std::string* body = request->mutable_body(); + envelope_from_websocket_message = std::move(*body); + envelope_plaintext = to_span(envelope_from_websocket_message); } if (!envelope.ParseFromArray(envelope_plaintext.data(), envelope_plaintext.size())) @@ -381,8 +442,7 @@ DecryptedEnvelope decrypt_envelope( if (crypto_sign_ed25519_pk_to_curve25519( result.sender_x25519_pubkey.data(), result.sender_ed25519_pubkey.data()) != 0) throw std::runtime_error( - "Parse content failed, ed25519 public key could not be converted to " - "x25519 " + "Parse content failed, ed25519 public key could not be converted to x25519 " "key."); } From ca00f8ed18f95fc9dff067cb42ec5f9f628bde31 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 25 Aug 2025 15:21:56 +1000 Subject: [PATCH 052/171] Mitigate snprintf error prone return value --- include/session/types.h | 18 ++++++++++++++++++ src/session_encrypt.cpp | 5 +++-- src/session_protocol.cpp | 12 +++++++----- src/types.cpp | 14 ++++++++++++++ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/include/session/types.h b/include/session/types.h index e5cfba32..a5eb1c44 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -27,6 +27,24 @@ span_u8 span_u8_alloc_or_throw(size_t size); /// is no longer needed. span_u8 span_u8_copy_or_throw(const void* data, size_t size); +/// A wrapper around snprintf that fixes a common bug in the value the printing function returns +/// when a buffer is passed in. Irrespective of whether a buffer is passed in, snprintf is defined +/// to return: +/// +/// number of characters (not including the terminating null character) which would have been +/// written to buffer if bufsz was ignored +/// +/// This means if the user passes in a buffer to small, the return value is always the amount of +/// bytes required. This means the user always has to calculate the number of bytes written as: +/// +/// size_t bytes_written = min(snprintf(buffer, size, ...), size); +/// +/// This is error prone. This function does the `min(...)` for you so that this function +/// _always_ calculates the actual number of bytes written (not including the null-terminator). If a +/// NULL is passed in then this function returns the number of bytes actually needed to write the +/// entire string (as per normal snprintf behaviour). +int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, ...); + #ifdef __cplusplus } #endif diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 6a622d01..feb28a99 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -1143,7 +1143,8 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( } catch (const std::exception& e) { std::string error_cpp = e.what(); result.error_len_incl_null_terminator = - std::snprintf(error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + + snprintf_bytes_written_clamped( + error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + 1; } return result; @@ -1258,7 +1259,7 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess } catch (const std::exception& e) { std::string error_cpp = e.what(); result.error_len_incl_null_terminator = - std::snprintf( + snprintf_bytes_written_clamped( error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + 1; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 05197349..753b4def 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -574,7 +574,7 @@ session_protocol_encrypt_for_destination( }; } catch (const std::exception& e) { std::string error_cpp = e.what(); - result.error_len_incl_null_terminator = std::snprintf( + result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( error, error_len, "%.*s", @@ -610,7 +610,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( array_uc32 pro_backend_pubkey_cpp = {}; if (pro_backend_pubkey) { if (pro_backend_pubkey_len != sizeof(pro_backend_pubkey_cpp)) { - result.error_len_incl_null_terminator = std::snprintf( + result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( error, error_len, "Invalid pro_backend_pubkey: Key was " @@ -644,7 +644,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( break; } catch (const std::exception& e) { std::string error_cpp = e.what(); - result.error_len_incl_null_terminator = std::snprintf( + result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( error, error_len, "%.*s", @@ -656,7 +656,9 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( if (keys->ed25519_privkeys_len == 0) { result.error_len_incl_null_terminator = - std::snprintf(error, error_len, "No keys ed25519_privkeys were provided") + 1; + snprintf_bytes_written_clamped( + error, error_len, "No keys ed25519_privkeys were provided") + + 1; } // Marshall into c type @@ -666,7 +668,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( } catch (const std::exception& e) { std::string error_cpp = e.what(); result.success = false; - result.error_len_incl_null_terminator = std::snprintf( + result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( error, error_len, "%.*s", diff --git a/src/types.cpp b/src/types.cpp index 5285f954..bca3c989 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1,6 +1,8 @@ #include #include +#include + span_u8 span_u8_alloc_or_throw(size_t size) { span_u8 result = {}; result.size = size; @@ -16,3 +18,15 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size) { std::memcpy(result.data, data, result.size); return result; } + +int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, ...) { + va_list args; + va_start(args, fmt); + int bytes_required_not_incl_null = vsnprintf(buffer, size, fmt, args); + va_end(args); + + int result = bytes_required_not_incl_null; + if (buffer) + result = std::min(static_cast(size), result); + return result; +} From 30986c24cc0cf815401a3476bcc610eedb605166 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 25 Aug 2025 16:57:33 +1000 Subject: [PATCH 053/171] Address some outdated doc comments --- include/session/session_protocol.h | 8 ++------ include/session/session_protocol.hpp | 11 +++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 07e56014..96dcd4d4 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -128,8 +128,8 @@ typedef struct session_protocol_encrypted_for_destination { /// Determine the Pro features that are used in a given conversation message. /// /// Inputs: -/// - `msg_size` -- the size of the message in bytes to determine if the message requires access to -/// the higher character limit available in Session Pro +/// - `msg_size` -- the size of the message in UTF16 code units to determine if the message requires +/// access to the higher character limit available in Session Pro /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// @@ -217,10 +217,6 @@ LIBSESSION_EXPORT void session_protocol_encrypt_for_destination_free( /// wraps an `Envelope` for 1o1 messages/sync messages, or `Envelope` encrypted using a Groups v2 /// key) parse (or decrypt) the envelope and return the envelope content decrypted if necessary. /// -/// A groups v2 envelope will get decrypted with the group keys. A non-groups v2 envelope will get -/// decrypted with the specified Ed25519 private key in the `keys` object. Only one of these keys -/// need to be set depending on the type of envelope payload passed into the function. -/// /// See: session_protocol/decrypt_envelope for more information /// /// The encryption result must be freed with `session_protocol_decrypt_envelope_free` when the diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 7c2016a9..5c1e5441 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -163,8 +163,8 @@ struct EncryptedForDestination { /// Determine the Pro features that are used in a given conversation message. /// /// Inputs: -/// - `msg_size` -- the size of the message in bytes to determine if the message requires access to -/// the higher character limit available in Session Pro +/// - `msg_size` -- the size of the message in UTF16 code units to determine if the message requires +/// access to the higher character limit available in Session Pro /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// @@ -232,10 +232,9 @@ EncryptedForDestination encrypt_for_destination( /// decrypted with the specified Ed25519 private key in the `keys` object. Only one of these keys /// need to be set depending on the type of envelope payload passed into the function. /// -/// If the message does not use Session Pro features, the pro status will be set to nil and all -/// other pro fields are to be ignored. If the pro status is non-nil then the pro fields will be -/// populated with data about the Session Pro proof embedded in the envelope including the features -/// used and if the proof was valid/expired e.t.c. +/// If the message does not use Session Pro features, the `pro` object will be set to nil. Otherwise +/// the pro fields will be populated with data about the Session Pro proof embedded in the envelope +/// including the features used and if the proof was valid/expired e.t.c. /// /// This function will throw if parsing failed such as a required field is missing, the field is /// smaller or larger than expected, decryption failed, or an invariant failed. Notably this From 42cd44ffff45d38b6db41ed2f81d4cff5abecbae Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 11:43:30 +1000 Subject: [PATCH 054/171] Use bytes32/64/33 in session protocol, add wrapper encrypt for {1o1,group,comms} functions --- include/session/session_protocol.h | 61 ++++++-- include/session/session_protocol.hpp | 33 ++++- include/session/types.h | 8 ++ src/config/groups/keys.cpp | 4 +- src/session_protocol.cpp | 172 +++++++++++++++++++++-- src/types.cpp | 4 +- tests/test_session_protocol.cpp | 200 +++++++++++++-------------- 7 files changed, 347 insertions(+), 135 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 96dcd4d4..1213a0e3 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -64,15 +64,14 @@ typedef enum DESTINATION_TYPE { // See session::DestinationType typedef struct session_protocol_destination { // See session::Destination DESTINATION_TYPE type; - // The pro signature is optional, set this flag to true to make the encryption function take - // into account the signature or otherwise the signature is ignored. - bool has_pro_sig; - uint8_t pro_sig[64]; - uint8_t recipient_pubkey[33]; + // The pro signature is optional, set the pointer to a 64 byte pro signature + // to include it into the encrypted message, ignored otherwise + const bytes64 *pro_sig; + bytes33 recipient_pubkey; uint64_t sent_timestamp_ms; - uint8_t community_inbox_server_pubkey[32]; - uint8_t group_ed25519_pubkey[33]; - uint8_t group_ed25519_privkey[32]; + bytes32 community_inbox_server_pubkey; + bytes33 group_ed25519_pubkey; + bytes32 group_ed25519_privkey; } session_protocol_destination; // Indicates which optional fields in the envelope has been populated out of the optional fields in @@ -88,10 +87,10 @@ enum ENVELOPE_FLAGS_ { typedef struct session_protocol_envelope { ENVELOPE_FLAGS flags; uint64_t timestamp_ms; - uint8_t source[33]; + bytes33 source; uint32_t source_device; uint64_t server_timestamp; - uint8_t pro_sig[64]; + bytes64 pro_sig; } session_protocol_envelope; typedef struct session_protocol_decrypt_envelope_keys { @@ -106,8 +105,8 @@ typedef struct session_protocol_decrypted_envelope { bool success; session_protocol_envelope envelope; span_u8 content_plaintext; - uint8_t sender_ed25519_pubkey[32]; - uint8_t sender_x25519_pubkey[32]; + bytes32 sender_ed25519_pubkey; + bytes32 sender_x25519_pubkey; PRO_STATUS pro_status; pro_proof pro_proof; PRO_FEATURES pro_features; @@ -139,6 +138,44 @@ typedef struct session_protocol_encrypted_for_destination { LIBSESSION_EXPORT PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); +LIBSESSION_EXPORT +session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_1o1( + const void* plaintext, + size_t plaintext_len, + const void* ed25519_privkey, + size_t ed25519_privkey_len, + uint64_t sent_timestamp_ms, + const bytes33* recipient_pubkey, + const bytes64* pro_sig, + char* error, + size_t error_len); + +LIBSESSION_EXPORT +session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_community_inbox( + const void* plaintext, + size_t plaintext_len, + const void* ed25519_privkey, + size_t ed25519_privkey_len, + uint64_t sent_timestamp_ms, + const bytes33* recipient_pubkey, + const bytes32* community_pubkey, + const bytes64* pro_sig, + char* error, + size_t error_len); + +LIBSESSION_EXPORT +session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_group( + const void* plaintext, + size_t plaintext_len, + const void* ed25519_privkey, + size_t ed25519_privkey_len, + uint64_t sent_timestamp_ms, + const bytes33* group_ed25519_pubkey, + const bytes32* group_ed25519_privkey, + const bytes64* pro_sig, + char* error, + size_t error_len); + /// API: session_protocol/session_protocol_encrypt_for_destination /// /// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 5c1e5441..8133ad2e 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -57,12 +57,12 @@ struct Destination { // this signature. std::optional pro_sig; - // Set to the recipient of the message if it requires one. Ignored otherwise (for example - // ignored in type => Community) - array_uc33 recipient_pubkey; - // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; + // + // When type => (CommunityInbox || SyncMessage || Contact): set to the recipient's Session + // public key + array_uc33 recipient_pubkey; // When type => CommunityInbox: set this pubkey to the server's key array_uc32 community_inbox_server_pubkey; @@ -74,7 +74,7 @@ struct Destination { // When type => Group: Set the private key of the group for groups v2 messages. Typically // the latest encryption key for the group, e.g: `Keys::group_enc_key` or // `groups_keys_group_enc_key` - array_uc32 group_ed25519_privkey; + cleared_uc32 group_ed25519_privkey; }; struct Envelope { @@ -173,6 +173,29 @@ struct EncryptedForDestination { /// `Content` PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); +EncryptedForDestination encrypt_and_wrap_for_1o1( + std::span plaintext, + std::span ed25519_privkey, + std::chrono::milliseconds sent_timestamp, + const array_uc33& recipient_pubkey, + const std::optional& pro_sig); + +EncryptedForDestination encrypt_and_wrap_for_community_inbox( + std::span plaintext, + std::span ed25519_privkey, + std::chrono::milliseconds sent_timestamp, + const array_uc33& recipient_pubkey, + const array_uc32& community_pubkey, + const std::optional& pro_sig); + +EncryptedForDestination encrypt_and_wrap_for_group( + std::span plaintext, + std::span ed25519_privkey, + std::chrono::milliseconds sent_timestamp, + const array_uc33& group_ed25519_pubkey, + const cleared_uc32& group_ed25519_privkey, + const std::optional& pro_sig); + /// API: session_protocol/encrypt_for_destination /// /// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of diff --git a/include/session/types.h b/include/session/types.h index a5eb1c44..47026c2d 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -17,6 +17,14 @@ struct bytes32 { uint8_t data[32]; }; +struct bytes33 { + uint8_t data[33]; +}; + +struct bytes64 { + uint8_t data[64]; +}; + /// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this /// function throws a runtime exception. The `data` pointer is span must be freed once the span /// is no longer needed. diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index 1931326f..a09c8d88 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -1240,7 +1240,9 @@ std::pair> Keys::decrypt_message( } if (!decrypt_success) // none of the keys worked - throw std::runtime_error{"unable to decrypt ciphertext with any current group keys"}; + throw std::runtime_error{fmt::format( + "unable to decrypt ciphertext with any current group keys; tried {}", + keys_.size() + (pending_key() ? 1 : 0))}; std::pair> result; result.first = std::move(decrypt.session_id); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 753b4def..eb8d048c 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -34,6 +34,58 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES extra) return result; } +EncryptedForDestination encrypt_and_wrap_for_1o1( + std::span plaintext, + std::span ed25519_privkey, + std::chrono::milliseconds sent_timestamp, + const array_uc33& recipient_pubkey, + const std::optional& pro_sig) +{ + Destination dest = {}; + dest.type = DestinationType::Contact; + dest.pro_sig = pro_sig; + dest.sent_timestamp_ms = sent_timestamp; + dest.recipient_pubkey = recipient_pubkey; + EncryptedForDestination result = encrypt_for_destination(plaintext, ed25519_privkey, dest, config::Namespace::Default); + return result; +} + +EncryptedForDestination encrypt_and_wrap_for_community_inbox( + std::span plaintext, + std::span ed25519_privkey, + std::chrono::milliseconds sent_timestamp, + const array_uc33& recipient_pubkey, + const array_uc32& community_pubkey, + const std::optional& pro_sig) +{ + Destination dest = {}; + dest.type = DestinationType::CommunityInbox; + dest.pro_sig = pro_sig; + dest.sent_timestamp_ms = sent_timestamp; + dest.recipient_pubkey = recipient_pubkey; + dest.community_inbox_server_pubkey = community_pubkey; + EncryptedForDestination result = encrypt_for_destination(plaintext, ed25519_privkey, dest, config::Namespace::Default); + return result; +} + +EncryptedForDestination encrypt_and_wrap_for_group( + std::span plaintext, + std::span ed25519_privkey, + std::chrono::milliseconds sent_timestamp, + const array_uc33& group_ed25519_pubkey, + const cleared_uc32& group_ed25519_privkey, + const std::optional& pro_sig) +{ + Destination dest = {}; + dest.type = DestinationType::Group; + dest.pro_sig = pro_sig; + dest.sent_timestamp_ms = sent_timestamp; + dest.group_ed25519_pubkey = group_ed25519_pubkey; + dest.group_ed25519_privkey = group_ed25519_privkey; + EncryptedForDestination result = encrypt_for_destination(plaintext, ed25519_privkey, dest, config::Namespace::GroupMessages); + return result; +} + // Interop between the C and CPP API. The C api will request malloc which writes to `ciphertext_c`. // This pointer is taken verbatim and avoids requiring a copy from the CPP vector. The CPP api will // steal the contents from `ciphertext_cpp`. @@ -541,6 +593,100 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR return result; } +LIBSESSION_C_API +session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_1o1( + const void* plaintext, + size_t plaintext_len, + const void* ed25519_privkey, + size_t ed25519_privkey_len, + uint64_t sent_timestamp_ms, + const bytes33* recipient_pubkey, + const bytes64* pro_sig, + char* error, + size_t error_len) { + + session_protocol_destination dest = {}; + dest.type = DESTINATION_TYPE_CONTACT; + dest.pro_sig = pro_sig; + dest.recipient_pubkey = *recipient_pubkey; + dest.sent_timestamp_ms = sent_timestamp_ms; + + session_protocol_encrypted_for_destination result = session_protocol_encrypt_for_destination( + plaintext, + plaintext_len, + ed25519_privkey, + ed25519_privkey_len, + &dest, + NAMESPACE_DEFAULT, + error, + error_len); + return result; +} + +LIBSESSION_C_API +session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_community_inbox( + const void* plaintext, + size_t plaintext_len, + const void* ed25519_privkey, + size_t ed25519_privkey_len, + uint64_t sent_timestamp_ms, + const bytes33* recipient_pubkey, + const bytes32* community_pubkey, + const bytes64* pro_sig, + char* error, + size_t error_len) { + + session_protocol_destination dest = {}; + dest.type = DESTINATION_TYPE_COMMUNITY_INBOX; + dest.pro_sig = pro_sig; + dest.sent_timestamp_ms = sent_timestamp_ms; + dest.recipient_pubkey = *recipient_pubkey; + dest.community_inbox_server_pubkey = *community_pubkey; + + session_protocol_encrypted_for_destination result = session_protocol_encrypt_for_destination( + plaintext, + plaintext_len, + ed25519_privkey, + ed25519_privkey_len, + &dest, + NAMESPACE_DEFAULT, + error, + error_len); + return result; +} + +LIBSESSION_C_API +session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_group( + const void* plaintext, + size_t plaintext_len, + const void* ed25519_privkey, + size_t ed25519_privkey_len, + uint64_t sent_timestamp_ms, + const bytes33* group_ed25519_pubkey, + const bytes32* group_ed25519_privkey, + const bytes64* pro_sig, + char* error, + size_t error_len) { + + session_protocol_destination dest = {}; + dest.type = DESTINATION_TYPE_GROUP; + dest.pro_sig = pro_sig; + dest.group_ed25519_pubkey = *group_ed25519_pubkey; + dest.group_ed25519_privkey = *group_ed25519_privkey; + dest.sent_timestamp_ms = sent_timestamp_ms; + + session_protocol_encrypted_for_destination result = session_protocol_encrypt_for_destination( + plaintext, + plaintext_len, + ed25519_privkey, + ed25519_privkey_len, + &dest, + NAMESPACE_GROUP_MESSAGES, + error, + error_len); + return result; +} + LIBSESSION_C_API session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( const void* plaintext, @@ -558,12 +704,12 @@ session_protocol_encrypt_for_destination( /*ed25519_privkey=*/ {static_cast(ed25519_privkey), ed25519_privkey_len}, /*dest_type=*/static_cast(dest->type), - /*dest_pro_sig=*/dest->has_pro_sig ? dest->pro_sig : std::span(), - /*dest_recipient_pubkey=*/dest->recipient_pubkey, + /*dest_pro_sig=*/dest->pro_sig ? dest->pro_sig->data : std::span(), + /*dest_recipient_pubkey=*/dest->recipient_pubkey.data, /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), - /*dest_community_inbox_server_pubkey=*/dest->community_inbox_server_pubkey, - /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey, - /*dest_group_ed25519_privkey=*/dest->group_ed25519_privkey, + /*dest_community_inbox_server_pubkey=*/dest->community_inbox_server_pubkey.data, + /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey.data, + /*dest_group_ed25519_privkey=*/dest->group_ed25519_privkey.data, /*space=*/static_cast(space), /*use_malloc=*/UseMalloc::Yes); @@ -708,22 +854,22 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( result.error_len_incl_null_terminator = 0; std::memcpy( - result.envelope.source, + result.envelope.source.data, result_cpp.envelope.source.data(), - sizeof(result.envelope.source)); + sizeof(result.envelope.source.data)); std::memcpy( - result.envelope.pro_sig, + result.envelope.pro_sig.data, result_cpp.envelope.pro_sig.data(), - sizeof(result.envelope.pro_sig)); + sizeof(result.envelope.pro_sig.data)); std::memcpy( - result.sender_ed25519_pubkey, + result.sender_ed25519_pubkey.data, result_cpp.sender_ed25519_pubkey.data(), - sizeof(result.sender_ed25519_pubkey)); + sizeof(result.sender_ed25519_pubkey.data)); std::memcpy( - result.sender_x25519_pubkey, + result.sender_x25519_pubkey.data, result_cpp.sender_x25519_pubkey.data(), - sizeof(result.sender_x25519_pubkey)); + sizeof(result.sender_x25519_pubkey.data)); return result; } diff --git a/src/types.cpp b/src/types.cpp index bca3c989..c8dc8c23 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -26,7 +26,7 @@ int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, . va_end(args); int result = bytes_required_not_incl_null; - if (buffer) - result = std::min(static_cast(size), result); + if (buffer && size && bytes_required_not_incl_null >= (size - 1)) + result = size - 1; return result; } diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 866d3209..b8ca16af 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -22,6 +22,8 @@ struct SerialisedProtobufContentWithProForTesting { std::string plaintext; array_uc64 sig_over_plaintext_with_user_pro_key; array_uc32 pro_proof_hash; + bytes64 sig_over_plaintext_with_user_pro_key_c; + bytes32 pro_proof_hash_c; }; static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_session_pro( @@ -76,6 +78,15 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se result.plaintext.size(), user_rotating_privkey.data()); + // Setup the C versions for convenience + std::memcpy( + result.sig_over_plaintext_with_user_pro_key_c.data, + result.sig_over_plaintext_with_user_pro_key.data(), + sizeof(result.sig_over_plaintext_with_user_pro_key_c.data)); + std::memcpy( + result.pro_proof_hash_c.data, + result.pro_proof_hash.data(), + sizeof(result.pro_proof_hash_c.data)); return result; } @@ -114,38 +125,36 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt with and w/o pro sig produce same payload size") { // Same payload size because the encrypt function should put in a dummy signature if one // wasn't specific to make pro and non-pro envelopes indistinguishable. - - session_protocol_destination dest = {}; - dest.type = DESTINATION_TYPE_CONTACT; - dest.sent_timestamp_ms = timestamp_ms.count(); - std::memcpy(dest.recipient_pubkey, keys.session_pk1.data(), sizeof(dest.recipient_pubkey)); + bytes33 recipient_pubkey = {}; + std::memcpy(recipient_pubkey.data, keys.session_pk1.data(), sizeof(recipient_pubkey.data)); // Withhold the pro signature - dest.has_pro_sig = false; char error[256]; session_protocol_encrypted_for_destination encrypt_without_pro_sig = - session_protocol_encrypt_for_destination( + session_protocol_encrypt_and_wrap_for_1o1( data_body.data(), data_body.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, + timestamp_ms.count(), + &recipient_pubkey, + nullptr, error, sizeof(error)); INFO(error); REQUIRE(encrypt_without_pro_sig.error_len_incl_null_terminator == 0); // Set the pro signature - dest.has_pro_sig = true; + bytes64 pro_sig = {}; session_protocol_encrypted_for_destination encrypt_with_pro_sig = - session_protocol_encrypt_for_destination( + session_protocol_encrypt_and_wrap_for_1o1( data_body.data(), data_body.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, + timestamp_ms.count(), + &recipient_pubkey, + &pro_sig, error, sizeof(error)); REQUIRE(encrypt_with_pro_sig.error_len_incl_null_terminator == 0); @@ -180,19 +189,18 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Encrypt session_protocol_encrypted_for_destination encrypt_result = {}; { - session_protocol_destination dest = {}; - dest.type = DESTINATION_TYPE_CONTACT; - dest.sent_timestamp_ms = timestamp_ms.count(); - REQUIRE(sizeof(dest.recipient_pubkey) == keys.session_pk1.size()); - std::memcpy(dest.recipient_pubkey, keys.session_pk1.data(), keys.session_pk1.size()); + bytes64* pro_sig = nullptr; + bytes33 recipient_pubkey = {}; + std::memcpy(recipient_pubkey.data, keys.session_pk1.data(), keys.session_pk1.size()); - encrypt_result = session_protocol_encrypt_for_destination( + encrypt_result = session_protocol_encrypt_and_wrap_for_1o1( plaintext.data(), plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, + timestamp_ms.count(), + &recipient_pubkey, + pro_sig, error, sizeof(error)); REQUIRE(encrypt_result.encrypted); @@ -258,16 +266,18 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { PRO_FEATURES_NIL); // Setup base destination object with the pro signature w/ Session pubkey 1 as the recipient - session_protocol_destination base_dest = {}; - base_dest.sent_timestamp_ms = timestamp_ms.count(); - base_dest.has_pro_sig = true; + bytes64 base_pro_sig = {}; std::memcpy( - base_dest.pro_sig, + base_pro_sig.data, protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.data(), - sizeof(base_dest.pro_sig)); + sizeof(base_pro_sig.data)); - REQUIRE(sizeof(base_dest.recipient_pubkey) == keys.session_pk1.size()); - std::memcpy(base_dest.recipient_pubkey, keys.session_pk1.data(), keys.session_pk1.size()); + session_protocol_destination base_dest = {}; + base_dest.sent_timestamp_ms = timestamp_ms.count(); + base_dest.pro_sig = &base_pro_sig; + + REQUIRE(sizeof(base_dest.recipient_pubkey.data) == keys.session_pk1.size()); + std::memcpy(base_dest.recipient_pubkey.data, keys.session_pk1.data(), keys.session_pk1.size()); SECTION("Check non-encryptable messages produce only plaintext") { auto dest_list = { @@ -292,8 +302,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { } else if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { auto [blind15_pk, blind15_sk] = session::blind15_key_pair( keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); - dest.recipient_pubkey[0] = 0x15; - std::memcpy(dest.recipient_pubkey + 1, blind15_pk.data(), blind15_pk.size()); + dest.recipient_pubkey.data[0] = 0x15; + std::memcpy(dest.recipient_pubkey.data + 1, blind15_pk.data(), blind15_pk.size()); } session_protocol_encrypted_for_destination encrypt_result = @@ -321,22 +331,19 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for contact in default namespace with Pro") { // Encrypt content - session_protocol_encrypted_for_destination encrypt_result = {}; - { - session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_CONTACT; - encrypt_result = session_protocol_encrypt_for_destination( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, - error, - sizeof(error)); - REQUIRE(encrypt_result.encrypted); - REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - } + session_protocol_encrypted_for_destination encrypt_result = + session_protocol_encrypt_and_wrap_for_1o1( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + base_dest.pro_sig, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; @@ -393,28 +400,20 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { features); // Encrypt content - session_protocol_encrypted_for_destination encrypt_result = {}; - { - session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_CONTACT; - std::memcpy( - dest.pro_sig, - protobuf_content_with_pro_and_features.sig_over_plaintext_with_user_pro_key - .data(), - sizeof(dest.pro_sig)); - - encrypt_result = session_protocol_encrypt_for_destination( - protobuf_content_with_pro_and_features.plaintext.data(), - protobuf_content_with_pro_and_features.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, - error, - sizeof(error)); - REQUIRE(encrypt_result.encrypted); - REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - } + session_protocol_encrypted_for_destination encrypt_result = + session_protocol_encrypt_and_wrap_for_1o1( + protobuf_content_with_pro_and_features.plaintext.data(), + protobuf_content_with_pro_and_features.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + &protobuf_content_with_pro_and_features + .sig_over_plaintext_with_user_pro_key_c, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; @@ -457,7 +456,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for legacy groups is rejected") { session_protocol_destination dest = base_dest; dest.type = DESTINATION_TYPE_GROUP; - assert(dest.recipient_pubkey[0] == 0x05); + assert(dest.recipient_pubkey.data[0] == 0x05); session_protocol_encrypted_for_destination encrypt_result = session_protocol_encrypt_for_destination( @@ -488,22 +487,22 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Encrypt session_protocol_encrypted_for_destination encrypt_result = {}; { - session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_GROUP; - dest.group_ed25519_pubkey[0] = 0x03; - std::memcpy(dest.group_ed25519_pubkey + 1, group_v2_pk.data(), group_v2_pk.size()); + bytes33 group_v2_session_pk = {}; + bytes32 group_v2_session_sk = {}; + group_v2_session_pk.data[0] = 0x03; + std::memcpy(group_v2_session_pk.data + 1, group_v2_pk.data(), group_v2_pk.size()); std::memcpy( - dest.group_ed25519_privkey, - group_v2_sk.data(), - sizeof(dest.group_ed25519_privkey)); + group_v2_session_sk.data, group_v2_sk.data(), sizeof(group_v2_session_sk.data)); - encrypt_result = session_protocol_encrypt_for_destination( + encrypt_result = session_protocol_encrypt_and_wrap_for_group( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - &dest, - NAMESPACE_GROUP_MESSAGES, + base_dest.sent_timestamp_ms, + &group_v2_session_pk, + &group_v2_session_sk, + base_dest.pro_sig, error, sizeof(error)); INFO("Encrypt for group error: " << error); @@ -541,22 +540,19 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for sync messages with Pro") { // Encrypt - session_protocol_encrypted_for_destination encrypt_result = {}; - { - session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_SYNC_MESSAGE; - encrypt_result = session_protocol_encrypt_for_destination( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, - error, - sizeof(error)); - REQUIRE(encrypt_result.encrypted); - REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - } + session_protocol_encrypted_for_destination encrypt_result = + session_protocol_encrypt_and_wrap_for_1o1( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + base_dest.pro_sig, + error, + sizeof(error)); + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; @@ -680,17 +676,17 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { session_protocol_encrypted_for_destination encrypt_result = {}; { - session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_SYNC_MESSAGE; - dest.has_pro_sig = true; - dest.pro_sig[0] ^= 1; // Break the sig by flipping a bit - encrypt_result = session_protocol_encrypt_for_destination( + bytes64 pro_sig = base_pro_sig; + pro_sig.data[0] ^= 1; // Break the sig by flipping a bit + + encrypt_result = session_protocol_encrypt_and_wrap_for_1o1( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - &dest, - NAMESPACE_DEFAULT, + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + &pro_sig, error, sizeof(error)); REQUIRE(encrypt_result.encrypted); From 10aebde287b61ae62b96c5933009b09f70282bf4 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 11:52:55 +1000 Subject: [PATCH 055/171] Remove destinations that don't encrypt With the new helper functions encrypt_and_wrap_for_{1o1,group,community} its clearer that this API only really should be called in these 3 circumstances. Making it a kitchen sink black boxes the whole process but seems to give people options (destinations) that are meaningless as they don't do anything but we imply they might. I think it's better to get rid of it and simplify the calling interface. --- include/session/session_protocol.h | 4 +--- include/session/session_protocol.hpp | 4 +--- src/session_protocol.cpp | 23 +++-------------------- tests/test_group_keys.cpp | 2 +- tests/test_session_protocol.cpp | 20 +++++--------------- 5 files changed, 11 insertions(+), 42 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 1213a0e3..af82dd9e 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -54,10 +54,8 @@ enum PRO_FEATURES_ { }; typedef enum DESTINATION_TYPE { // See session::DestinationType - DESTINATION_TYPE_CONTACT, - DESTINATION_TYPE_SYNC_MESSAGE, + DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE, DESTINATION_TYPE_GROUP, - DESTINATION_TYPE_COMMUNITY, DESTINATION_TYPE_COMMUNITY_INBOX, } DESTINATION_TYPE; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 8133ad2e..a05c077b 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -38,13 +38,11 @@ namespace config::groups { } enum class DestinationType { - Contact = DESTINATION_TYPE_CONTACT, - SyncMessage = DESTINATION_TYPE_SYNC_MESSAGE, + ContactOrSyncMessage = DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE, /// Both legacy and non-legacy groups are to be identified as `Group`. A non-legacy /// group is detected by the (0x03) prefix byte on the given `dest_group_pubkey` specified in /// Destination. Group = DESTINATION_TYPE_GROUP, - Community = DESTINATION_TYPE_COMMUNITY, CommunityInbox = DESTINATION_TYPE_COMMUNITY_INBOX, }; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index eb8d048c..0f8096c1 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -42,7 +42,7 @@ EncryptedForDestination encrypt_and_wrap_for_1o1( const std::optional& pro_sig) { Destination dest = {}; - dest.type = DestinationType::Contact; + dest.type = DestinationType::ContactOrSyncMessage; dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; @@ -180,30 +180,13 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } } break; - case DestinationType::Contact: { - if (space == config::Namespace::Default) { - enc.mode = Mode::Envelope; - enc.before_envelope_encrypt_for_recipient_deterministic = true; - enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; - enc.after_envelope = AfterEnvelope::WrapInWSMessage; - } else { - // See: - // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L498 - enc.mode = Mode::Plaintext; - } - } break; - - case DestinationType::SyncMessage: { + case DestinationType::ContactOrSyncMessage: { enc.mode = Mode::Envelope; enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; } break; - case DestinationType::Community: { - enc.mode = Mode::Plaintext; - } break; - case DestinationType::CommunityInbox: { enc.mode = Mode::EncryptForBlindedRecipient; } break; @@ -606,7 +589,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for size_t error_len) { session_protocol_destination dest = {}; - dest.type = DESTINATION_TYPE_CONTACT; + dest.type = DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE; dest.pro_sig = pro_sig; dest.recipient_pubkey = *recipient_pubkey; dest.sent_timestamp_ms = sent_timestamp_ms; diff --git a/tests/test_group_keys.cpp b/tests/test_group_keys.cpp index 33d5dea4..b10d9ae2 100644 --- a/tests/test_group_keys.cpp +++ b/tests/test_group_keys.cpp @@ -444,7 +444,7 @@ TEST_CASE("Group Keys - C++ API", "[config][groups][keys][cpp]") { bad_compressed.back() ^= 0b100; CHECK_THROWS_WITH( members.back().keys.decrypt_message(bad_compressed), - "unable to decrypt ciphertext with any current group keys"); + "unable to decrypt ciphertext with any current group keys; tried 4"); // Duplicate members[1] from dumps auto& m1b = members.emplace_back( diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index b8ca16af..1d80e9d3 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -281,14 +281,11 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Check non-encryptable messages produce only plaintext") { auto dest_list = { - DESTINATION_TYPE_COMMUNITY, DESTINATION_TYPE_COMMUNITY_INBOX, - DESTINATION_TYPE_CONTACT}; + DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE}; for (auto dest_type : dest_list) { - if (dest_type == DESTINATION_TYPE_COMMUNITY) - INFO("Trying community"); - else if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) + if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) INFO("Trying community inbox"); else INFO("Trying contacts to non-default namespace"); @@ -297,9 +294,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { dest.type = dest_type; NAMESPACE space = NAMESPACE_DEFAULT; - if (dest_type == DESTINATION_TYPE_CONTACT) { - space = NAMESPACE_CONTACTS; - } else if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { + if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { auto [blind15_pk, blind15_sk] = session::blind15_key_pair( keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); dest.recipient_pubkey.data[0] = 0x15; @@ -317,13 +312,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); - if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { - REQUIRE(encrypt_result.encrypted); - REQUIRE(encrypt_result.ciphertext.size > 0); - } else { - REQUIRE_FALSE(encrypt_result.encrypted); - REQUIRE(encrypt_result.ciphertext.size == 0); - } + REQUIRE(encrypt_result.encrypted); + REQUIRE(encrypt_result.ciphertext.size > 0); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); session_protocol_encrypt_for_destination_free(&encrypt_result); } From 475206230f68ebf3635a7e5bb8f0392e183d3ad1 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 12:34:30 +1000 Subject: [PATCH 056/171] Remove namespace from encrypt for destination We assume that you are encrypting for the destination AND into the correct namespace. Encrypting for 1o1 as a caller has the intent that you want to "talk" to someone and in all cases this would have to be encrypted which is the most obvious outcome of what you would expect to get if you asked libsession to do it. The namespace complicated things unnecessarily by making it appear as if there's an alternative way to encrypt if you were targetting different namespace. Technically this is true, if you target another namesspace/mailbox there are different conventions on how an application should consume data from that mailbox but that is not related to the task of encrypting for a conversation (1o1, group, community, sync message). --- include/session/session_protocol.h | 164 ++++++++++++++++++++++++--- include/session/session_protocol.hpp | 130 ++++++++++++++------- src/session_protocol.cpp | 71 ++++-------- tests/test_session_protocol.cpp | 34 ++---- 4 files changed, 266 insertions(+), 133 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index af82dd9e..204bb31f 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -1,6 +1,5 @@ #include -#include "config/namespaces.h" #include "config/pro.h" #include "export.h" #include "types.h" @@ -64,7 +63,7 @@ typedef struct session_protocol_destination { // See session::Destination // The pro signature is optional, set the pointer to a 64 byte pro signature // to include it into the encrypted message, ignored otherwise - const bytes64 *pro_sig; + const bytes64* pro_sig; bytes33 recipient_pubkey; uint64_t sent_timestamp_ms; bytes32 community_inbox_server_pubkey; @@ -115,7 +114,6 @@ typedef struct session_protocol_encrypted_for_destination { // Indicates if the encryption was successful. If any step failed and threw an exception, this // is false. bool success; - bool encrypted; span_u8 ciphertext; size_t error_len_incl_null_terminator; } session_protocol_encrypted_for_destination; @@ -136,8 +134,52 @@ typedef struct session_protocol_encrypted_for_destination { LIBSESSION_EXPORT PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); +/// API: session_protocol_encrypt_for_1o1 +/// +/// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session +/// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for +/// transmission to a single recipient. +/// +/// See: session_protocol/encrypt_for_1o1 for more information +/// +/// The encryption result must be freed with session_protocol_encrypt_for_destination_free when +/// the caller is done with the result. +/// +/// Inputs: +/// - `plaintext` -- The protobuf serialized payload containing the Content to be encrypted +/// - `plaintext_len` -- The length of the plaintext buffer in bytes. +/// - `ed25519_privkey` -- The sender's libsodium-style secret key (64 bytes). Can also be passed as +/// a 32-byte seed. Used to encrypt the plaintext. +/// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). +/// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. +/// - `recipient_pubkey` -- The recipient's Session public key (33 bytes). +/// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro +/// rotating public key, if using Session Pro features. If provided, the corresponding proof must +/// be set in the Content protobuf. Pass NULL if not using Session Pro features. +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned success was false, untouched otherwise. If this is set to NULL, then on failure, +/// the returned error_len_incl_null_terminator is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that error is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// error is NULL. This function will fill the buffer up to error_len - 1 characters with the last +/// character reserved for the null-terminator. +/// +/// Outputs: +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// are to be ignored in the result on failure. +/// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for +/// sending on the wire (i.e: it has been protobuf encoded/wrapped if necessary). +/// - `error_len_incl_null_terminator` -- The length of the error message if success was false. If +/// the user passes in a non-NULL error buffer this is the amount of characters written to the +/// error buffer. If the user passes in a NULL error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_1o1( +session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -148,8 +190,56 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for char* error, size_t error_len); +/// API: session_protocol_encrypt_for_community_inbox +/// +/// Encrypt a plaintext message for a community inbox in the Session Protocol. This function wraps +/// the plaintext in the necessary structures and encrypts it for transmission to a community inbox +/// server. +/// +/// See: session_protocol/encrypt_for_community_inbox for more information +/// +/// The encryption result must be freed with session_protocol_encrypt_for_destination_free when +/// the caller is done with the result. +/// +/// Inputs: +/// - `plaintext `-- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - `plaintext_len` -- The length of the plaintext buffer in bytes. +/// - `ed25519_privkey` -- The sender's libsodium-style secret key (64 bytes). Can also be passed as +/// a 32-byte seed. Used to encrypt the plaintext. +/// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). +/// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. +/// - `recipient_pubkey` -- The recipient's Session public key (33 bytes). +/// - `community_pubkey` -- The community inbox server's public key (32 bytes). +/// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro +/// rotating public key, if using Session Pro features. If provided, the corresponding proof must +/// be set in the Content protobuf. Pass NULL if not using Session Pro features. TODO: Pro sig +/// is not incorporated into community/inbox messages yet. +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned success was false, untouched otherwise. If this is set to NULL, then on failure, +/// the returned error_len_incl_null_terminator is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that error is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// error is NULL. This function will fill the buffer up to error_len - 1 characters with the +/// last character reserved for the null-terminator. +/// +/// Outputs: +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// are to be ignored in the result on failure. +/// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for +/// sending on the wire (i.e: it has been protobuf encoded/wrapped if necessary). +/// - `error_len_incl_null_terminator` -- The length of the error message if success was false. If +/// the user passes in a non-NULL error buffer this is the amount of characters written to the +/// error buffer. If the user passes in a NULL error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. + LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_community_inbox( +session_protocol_encrypted_for_destination session_protocol_encrypt_for_community_inbox( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -161,8 +251,56 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for char* error, size_t error_len); +/// API: session_protocol_encrypt_for_group +/// +/// Encrypt a plaintext message for a group in the Session Protocol. This function wraps the +/// plaintext in the necessary structures and encrypts it for transmission to a group, using the +/// group's encryption key. Only v2 groups, (0x03) prefixed keys are supported. Passing a legacy +/// group (0x05) prefixed key will cause the function to return a failure with an error message. +/// +/// See: session_protocol/encrypt_for_group for more information +/// +/// The encryption result must be freed with session_protocol_encrypt_for_destination_free when +/// the caller is done with the result. +/// +/// Inputs: +/// - `plaintext` -- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - `plaintext_len` -- The length of the plaintext buffer in bytes. +/// - `ed25519_privkey` -- The sender's libsodium-style secret key (64 bytes). Can also be passed as +/// a 32-byte seed. Used to encrypt the plaintext. +/// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). +/// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. +/// - `group_ed25519_pubkey` -- The group's public key (33 bytes) for encryption with a 0x03 prefix. +/// - `group_ed25519_privkey` -- The group's private key (32 bytes) for groups v2 messages, typically +/// the latest encryption key for the group (e.g., Keys::group_enc_key). +/// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro +/// rotating public key, if using Session Pro features. If provided, the corresponding proof must +/// be set in the Content protobuf. Pass NULL if not using Session Pro features. +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned success was false, untouched otherwise. If this is set to NULL, then on failure, +/// the returned error_len_incl_null_terminator is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that error is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// error is NULL. This function will fill the buffer up to error_len - 1 characters with the +/// last character reserved for the null-terminator. +/// +/// Outputs: +/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// are to be ignored in the result on failure. +/// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for +/// sending on the wire (i.e: it has been protobuf encoded/wrapped if necessary). +/// - `error_len_incl_null_terminator` -- The length of the error message if success was false. If +/// the user passes in a non-NULL error buffer this is the amount of characters written to the +/// error buffer. If the user passes in a NULL error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length, including the null-terminator in order for the error message +/// to be preserved in full. LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_group( +session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -192,7 +330,6 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for /// passed as a 32-byte seed. Used to encrypt the plaintext. /// - `dest` -- the extra metadata indicating the destination of the message and the necessary data /// to encrypt a message for that destination. -/// - `space` -- the namespace to encrypt the message for /// - `error` -- Pointer to the character buffer to be populated with the error message if the /// returned `success` was false, untouched otherwise. If this is set to `NULL`, then on failure, /// the returned `error_len_incl_null_terminator` is the number of bytes required by the user to @@ -207,16 +344,8 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for /// - `success` -- True if encryption was successful, if the underlying implementation threw /// an exception then this is caught internally and success is set to false. All remaining fields /// are to be ignored in the result on failure. -/// - `encrypted` -- True if any encryption was performed. If the combination of the namespace and -/// destination does not require encryption, this flag is false. In this case, `ciphertext` will -/// not be assigned. The caller should proceed with the `plaintext` they initially passed in. -/// - `ciphertext` -- Encryption result for the plaintext. If the destination and namespace -/// combination did not require encryption, no payload is returned in the ciphertext and the user -/// should proceed with the plaintext. This should be validated by checking the `encrypted` flag -/// on the result to determine if the ciphertext or plaintext is to be used. -/// -/// The retured payload is suitable for sending on the wire (i.e: it has been protobuf -/// encoded/wrapped if necessary). +/// - `ciphertext` -- Encryption result for the plaintext. The retured payload is suitable for +/// sending on the wire (i.e: it has been protobuf encoded/wrapped if necessary). /// - `error_len_incl_null_terminator` The length of the error message if `success` was false. If /// the user passes in an non-`NULL` error buffer this is amount of characters written to the /// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters @@ -230,7 +359,6 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, - NAMESPACE space, char* error, size_t error_len); diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index a05c077b..f5e9976a 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -145,17 +145,6 @@ struct DecryptEnvelopeKey { std::span> ed25519_privkeys; }; -struct EncryptedForDestination { - // Indicates if the ciphertext was encrypted or not. This can be false if the message sent to - // the destination and namespace does not require encryption. In this case `ciphertext` is not - // set and the user should proceed with the original plaintext. - bool encrypted; - - // The plaintext encrypted in a manner suitable for the desired destination and namespace. This - // is not set if `encrypted` is false. - std::vector ciphertext; -}; - /// API: session_protocol/get_pro_features_for_msg /// /// Determine the Pro features that are used in a given conversation message. @@ -171,14 +160,66 @@ struct EncryptedForDestination { /// `Content` PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); -EncryptedForDestination encrypt_and_wrap_for_1o1( +/// API: session_protocol/encrypt_for_1o1 +/// +/// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session +/// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for +/// transmission to a single recipient. +/// +/// This is a high-level convenience function that internally calls encrypt_for_destination with +/// the appropriate Destination configuration for a 1o1 or sync message. +/// +/// This function throws if any input argument is invalid (e.g., incorrect key sizes). +/// +/// Inputs: +/// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - ed25519_privkey -- The sender's libsodium-style secret key (64 bytes). Can also be passed as +/// a 32-byte seed. Used to encrypt the plaintext. +/// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. +/// - recipient_pubkey -- The recipient's Session public key (33 bytes). +/// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro +/// rotating public key, if using Session Pro features. If provided, the corresponding proof must +/// be set in the Content protobuf. +/// +/// Outputs: +/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire +/// (i.e: it has been protobuf encoded/wrapped if necessary). +std::vector encrypt_for_1o1( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const std::optional& pro_sig); -EncryptedForDestination encrypt_and_wrap_for_community_inbox( +/// API: session_protocol/encrypt_for_community_inbox +/// +/// Encrypt a plaintext message for a community inbox in the Session Protocol. This function wraps +/// the plaintext in the necessary structures and encrypts it for transmission to a community inbox +/// server. +/// +/// This is a high-level convenience function that internally calls encrypt_for_destination with +/// the appropriate Destination configuration for a community inbox message. +/// +/// This function throws if any input argument is invalid (e.g., incorrect key sizes). +/// +/// Inputs: +/// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - ed25519_privkey -- The sender's libsodium-style secret key (64 bytes). Can also be passed as +/// a 32-byte seed. Used to encrypt the plaintext. +/// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. +/// - recipient_pubkey -- The recipient's Session public key (33 bytes). +/// - community_pubkey -- The community inbox server's public key (32 bytes). +/// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro +/// rotating public key, if using Session Pro features. If provided, the corresponding proof must +/// be set in the Content protobuf. +/// TODO: Pro sig is not incorporated into community/inbox messages yet +/// +/// Outputs: +/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire +/// (i.e: it has been protobuf encoded/wrapped if necessary). +std::vector encrypt_for_community_inbox( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -186,7 +227,35 @@ EncryptedForDestination encrypt_and_wrap_for_community_inbox( const array_uc32& community_pubkey, const std::optional& pro_sig); -EncryptedForDestination encrypt_and_wrap_for_group( +/// API: session_protocol/encrypt_for_group +/// +/// Encrypt a plaintext message for a group in the Session Protocol. This function wraps the +/// plaintext in the necessary structures and encrypts it for transmission to a group, using the +/// group's encryption key. Only v2 groups, (0x03) prefixed keys are supported. Passing a legacy +/// group (0x05) prefixed key will cause the function to throw. +/// +/// This is a high-level convenience function that internally calls encrypt_for_destination with +/// the appropriate Destination configuration for a group message. +/// +/// This function throws if any input argument is invalid (e.g., incorrect key sizes). +/// +/// Inputs: +/// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - ed25519_privkey -- The sender's libsodium-style secret key (64 bytes). Can also be passed as +/// a 32-byte seed. Used to encrypt the plaintext. +/// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. +/// - group_ed25519_pubkey -- The group's public key (33 bytes) for encryption with a 0x03 prefix +/// - group_ed25519_privkey -- The group's private key (32 bytes) for groups v2 messages, typically +/// the latest encryption key for the group (e.g., Keys::group_enc_key). +/// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro +/// rotating public key, if using Session Pro features. If provided, the corresponding proof must +/// be set in the Content protobuf. +/// +/// Outputs: +/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire +/// (i.e: it has been protobuf encoded/wrapped if necessary). +std::vector encrypt_for_group( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -200,18 +269,14 @@ EncryptedForDestination encrypt_and_wrap_for_group( /// `Content`), encrypt and/or wrap the plaintext in the necessary structures for transmission on /// the Session Protocol. /// -/// This function supports all combinatoric combinations of the destination type and namespace -/// including returning plaintext if the message is not meant to be encrypted and or wrapping in the -/// additional websocket wrapper or encrypting the envelope with the group keys if necessary -/// e.t.c. -/// /// Calling this function requires filling out the options in the `Destination` struct with the -/// appropriate values for the desired combination of destination type and namespace. Check the -/// annotation on `Destination` for more information. +/// appropriate values for the desired destination. Check the annotation on `Destination` for more +/// information on how to fill this struct. Alternatively, there are higher level functions, encrypt +/// for 1o1, group and community functions which thunk into this low-level function for convenience. /// /// This function throws if the API is misused (i.e.: A field was not set, but was required to be /// set for the given destination and namespace. For example the group keys not being set -/// when sending to a group prefixed [0x3] key in a group into the group message namespace) +/// when sending to a group prefixed [0x3] key in a group) /// but otherwise returns a struct with values. /// /// Inputs: @@ -221,27 +286,14 @@ EncryptedForDestination encrypt_and_wrap_for_group( /// passed as a 32-byte seed. Used to encrypt the plaintext. /// - `dest` -- the extra metadata indicating the destination of the message and the necessary data /// to encrypt a message for that destination. -/// - `space` -- the namespace to encrypt the message for /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw -/// an exception then this is caught internally and success is set to false. All remaining fields -/// are to be ignored in the result on failure. -/// - `encrypted` -- True if any encryption was performed. If the combination of the namespace and -/// destination does not require encryption, this flag is false. In this case, `ciphertext` will -/// not be assigned. The caller should proceed with the `plaintext` they initially passed in. -/// - `ciphertext` -- Encryption result for the plaintext. If the destination and namespace -/// combination did not require encryption, no payload is returned in the ciphertext and the user -/// should proceed with the plaintext. This should be validated by checking the `encrypted` flag -/// on the result to determine if the ciphertext or plaintext is to be used. -/// -/// The retured payload is suitable for sending on the wire (i.e: it has been protobuf -/// encoded/wrapped if necessary). -EncryptedForDestination encrypt_for_destination( +/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire +/// (i.e: it has been protobuf encoded/wrapped if necessary). +std::vector encrypt_for_destination( std::span plaintext, std::span ed25519_privkey, - const Destination& dest, - config::Namespace space); + const Destination& dest); /// API: session_protocol/decrypt_envelope /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 0f8096c1..0158d00e 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -34,55 +34,52 @@ PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES extra) return result; } -EncryptedForDestination encrypt_and_wrap_for_1o1( +std::vector encrypt_for_1o1( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, - const std::optional& pro_sig) -{ + const std::optional& pro_sig) { Destination dest = {}; dest.type = DestinationType::ContactOrSyncMessage; dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; - EncryptedForDestination result = encrypt_for_destination(plaintext, ed25519_privkey, dest, config::Namespace::Default); + std::vector result = encrypt_for_destination(plaintext, ed25519_privkey, dest); return result; } -EncryptedForDestination encrypt_and_wrap_for_community_inbox( +std::vector encrypt_for_community_inbox( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const array_uc32& community_pubkey, - const std::optional& pro_sig) -{ + const std::optional& pro_sig) { Destination dest = {}; dest.type = DestinationType::CommunityInbox; dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; dest.community_inbox_server_pubkey = community_pubkey; - EncryptedForDestination result = encrypt_for_destination(plaintext, ed25519_privkey, dest, config::Namespace::Default); + std::vector result = encrypt_for_destination(plaintext, ed25519_privkey, dest); return result; } -EncryptedForDestination encrypt_and_wrap_for_group( +std::vector encrypt_for_group( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, const cleared_uc32& group_ed25519_privkey, - const std::optional& pro_sig) -{ + const std::optional& pro_sig) { Destination dest = {}; dest.type = DestinationType::Group; dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp; dest.group_ed25519_pubkey = group_ed25519_pubkey; dest.group_ed25519_privkey = group_ed25519_privkey; - EncryptedForDestination result = encrypt_for_destination(plaintext, ed25519_privkey, dest, config::Namespace::GroupMessages); + std::vector result = encrypt_for_destination(plaintext, ed25519_privkey, dest); return result; } @@ -90,7 +87,6 @@ EncryptedForDestination encrypt_and_wrap_for_group( // This pointer is taken verbatim and avoids requiring a copy from the CPP vector. The CPP api will // steal the contents from `ciphertext_cpp`. struct EncryptedForDestinationInternal { - bool encrypted; std::vector ciphertext_cpp; span_u8 ciphertext_c; }; @@ -106,7 +102,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( std::span dest_community_inbox_server_pubkey, std::span dest_group_ed25519_pubkey, std::span dest_group_ed25519_privkey, - config::Namespace space, UseMalloc use_malloc) { assert(dest_pro_sig.empty() || dest_pro_sig.size() == crypto_sign_ed25519_BYTES); @@ -121,7 +116,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( EncryptedForDestinationInternal result = {}; enum class Mode { Envelope, - Plaintext, EncryptForBlindedRecipient, }; @@ -159,19 +153,11 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( bool has_03_prefix = dest_group_ed25519_pubkey[0] == static_cast(SessionIDPrefix::group); if (has_03_prefix) { - if (space == config::Namespace::GroupMessages) { - enc.mode = Mode::Envelope; - enc.before_envelope_encrypt_for_recipient_deterministic = false; - enc.after_envelope = AfterEnvelope::KeysEncryptMessage; - enc.envelope_type = - SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; - } else if (space == config::Namespace::RevokedRetrievableGroupMessages) { - enc.mode = Mode::Plaintext; - } else { - // See: - // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L494 - enc.mode = Mode::Plaintext; - } + enc.mode = Mode::Envelope; + enc.before_envelope_encrypt_for_recipient_deterministic = false; + enc.after_envelope = AfterEnvelope::KeysEncryptMessage; + enc.envelope_type = + SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; } else { // Legacy groups which have a 05 prefixed key throw std::runtime_error{ @@ -226,7 +212,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( envelope.set_prosig(dest_pro_sig.data(), dest_pro_sig.size()); } - result.encrypted = true; switch (enc.after_envelope) { case AfterEnvelope::Nil: assert(false && "Dev error, after envelope action was not set"); @@ -294,12 +279,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( } break; - case Mode::Plaintext: { - // No-op. We do not populate the ciphertext because there was no encryption. - } break; - case Mode::EncryptForBlindedRecipient: { - result.encrypted = true; std::vector ciphertext = encrypt_for_blinded_recipient( ed25519_privkey, dest_community_inbox_server_pubkey, @@ -317,11 +297,10 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( return result; } -EncryptedForDestination encrypt_for_destination( +std::vector encrypt_for_destination( std::span plaintext, std::span ed25519_privkey, - const Destination& dest, - config::Namespace space) { + const Destination& dest) { EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( /*plaintext=*/plaintext, @@ -333,13 +312,9 @@ EncryptedForDestination encrypt_for_destination( /*dest_community_inbox_server_pubkey=*/dest.community_inbox_server_pubkey, /*dest_group_ed25519_pubkey=*/dest.group_ed25519_pubkey, /*dest_group_ed25519_privkey=*/dest.group_ed25519_privkey, - /*space=*/space, /*use_malloc=*/UseMalloc::No); - EncryptedForDestination result = { - .encrypted = result_internal.encrypted, - .ciphertext = std::move(result_internal.ciphertext_cpp), - }; + std::vector result = std::move(result_internal.ciphertext_cpp); return result; } @@ -577,7 +552,7 @@ PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTR } LIBSESSION_C_API -session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_1o1( +session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -600,14 +575,13 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for ed25519_privkey, ed25519_privkey_len, &dest, - NAMESPACE_DEFAULT, error, error_len); return result; } LIBSESSION_C_API -session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_community_inbox( +session_protocol_encrypted_for_destination session_protocol_encrypt_for_community_inbox( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -632,14 +606,13 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for ed25519_privkey, ed25519_privkey_len, &dest, - NAMESPACE_DEFAULT, error, error_len); return result; } LIBSESSION_C_API -session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for_group( +session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -664,7 +637,6 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_and_wrap_for ed25519_privkey, ed25519_privkey_len, &dest, - NAMESPACE_GROUP_MESSAGES, error, error_len); return result; @@ -677,7 +649,6 @@ session_protocol_encrypt_for_destination( const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, - NAMESPACE space, char* error, size_t error_len) { session_protocol_encrypted_for_destination result = {}; @@ -693,12 +664,10 @@ session_protocol_encrypt_for_destination( /*dest_community_inbox_server_pubkey=*/dest->community_inbox_server_pubkey.data, /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey.data, /*dest_group_ed25519_privkey=*/dest->group_ed25519_privkey.data, - /*space=*/static_cast(space), /*use_malloc=*/UseMalloc::Yes); result = { .success = true, - .encrypted = result_internal.encrypted, .ciphertext = result_internal.ciphertext_c, }; } catch (const std::exception& e) { diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 1d80e9d3..148c419a 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -131,7 +131,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Withhold the pro signature char error[256]; session_protocol_encrypted_for_destination encrypt_without_pro_sig = - session_protocol_encrypt_and_wrap_for_1o1( + session_protocol_encrypt_for_1o1( data_body.data(), data_body.size(), keys.ed_sk0.data(), @@ -147,7 +147,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Set the pro signature bytes64 pro_sig = {}; session_protocol_encrypted_for_destination encrypt_with_pro_sig = - session_protocol_encrypt_and_wrap_for_1o1( + session_protocol_encrypt_for_1o1( data_body.data(), data_body.size(), keys.ed_sk0.data(), @@ -159,9 +159,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); REQUIRE(encrypt_with_pro_sig.error_len_incl_null_terminator == 0); - REQUIRE(encrypt_without_pro_sig.encrypted); - REQUIRE(encrypt_with_pro_sig.encrypted); - // Should have the same payload size REQUIRE(encrypt_without_pro_sig.ciphertext.size == encrypt_with_pro_sig.ciphertext.size); session_protocol_encrypt_for_destination_free(&encrypt_without_pro_sig); @@ -193,7 +190,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { bytes33 recipient_pubkey = {}; std::memcpy(recipient_pubkey.data, keys.session_pk1.data(), keys.session_pk1.size()); - encrypt_result = session_protocol_encrypt_and_wrap_for_1o1( + encrypt_result = session_protocol_encrypt_for_1o1( plaintext.data(), plaintext.size(), keys.ed_sk0.data(), @@ -203,7 +200,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { pro_sig, error, sizeof(error)); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); } @@ -281,8 +277,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Check non-encryptable messages produce only plaintext") { auto dest_list = { - DESTINATION_TYPE_COMMUNITY_INBOX, - DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE}; + DESTINATION_TYPE_COMMUNITY_INBOX, DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE}; for (auto dest_type : dest_list) { if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) @@ -292,8 +287,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_destination dest = base_dest; dest.type = dest_type; - - NAMESPACE space = NAMESPACE_DEFAULT; if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { auto [blind15_pk, blind15_sk] = session::blind15_key_pair( keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); @@ -308,11 +301,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.data(), keys.ed_sk0.size(), &dest, - space, error, sizeof(error)); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.ciphertext.size > 0); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); session_protocol_encrypt_for_destination_free(&encrypt_result); @@ -322,7 +313,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for contact in default namespace with Pro") { // Encrypt content session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_and_wrap_for_1o1( + session_protocol_encrypt_for_1o1( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -332,7 +323,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { base_dest.pro_sig, error, sizeof(error)); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope @@ -391,7 +381,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Encrypt content session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_and_wrap_for_1o1( + session_protocol_encrypt_for_1o1( protobuf_content_with_pro_and_features.plaintext.data(), protobuf_content_with_pro_and_features.plaintext.size(), keys.ed_sk0.data(), @@ -402,7 +392,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { .sig_over_plaintext_with_user_pro_key_c, error, sizeof(error)); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope @@ -455,13 +444,11 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.data(), keys.ed_sk0.size(), &dest, - NAMESPACE_DEFAULT, error, sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator > 0); REQUIRE(encrypt_result.error_len_incl_null_terminator <= sizeof(error)); REQUIRE(!encrypt_result.success); - REQUIRE(!encrypt_result.encrypted); session_protocol_encrypt_for_destination_free(&encrypt_result); } @@ -484,7 +471,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { std::memcpy( group_v2_session_sk.data, group_v2_sk.data(), sizeof(group_v2_session_sk.data)); - encrypt_result = session_protocol_encrypt_and_wrap_for_group( + encrypt_result = session_protocol_encrypt_for_group( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -497,7 +484,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); INFO("Encrypt for group error: " << error); REQUIRE(encrypt_result.success); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); } @@ -531,7 +517,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for sync messages with Pro") { // Encrypt session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_and_wrap_for_1o1( + session_protocol_encrypt_for_1o1( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -541,7 +527,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { base_dest.pro_sig, error, sizeof(error)); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt @@ -669,7 +654,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { bytes64 pro_sig = base_pro_sig; pro_sig.data[0] ^= 1; // Break the sig by flipping a bit - encrypt_result = session_protocol_encrypt_and_wrap_for_1o1( + encrypt_result = session_protocol_encrypt_for_1o1( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -679,7 +664,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &pro_sig, error, sizeof(error)); - REQUIRE(encrypt_result.encrypted); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); } From 42c288a1e98ed1c9b928e3c9aad5b71fdcfbdc10 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 15:49:27 +1000 Subject: [PATCH 057/171] Linting --- include/session/session_protocol.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 204bb31f..b28ac490 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -272,7 +272,8 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit /// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). /// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. /// - `group_ed25519_pubkey` -- The group's public key (33 bytes) for encryption with a 0x03 prefix. -/// - `group_ed25519_privkey` -- The group's private key (32 bytes) for groups v2 messages, typically +/// - `group_ed25519_privkey` -- The group's private key (32 bytes) for groups v2 messages, +/// typically /// the latest encryption key for the group (e.g., Keys::group_enc_key). /// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro /// rotating public key, if using Session Pro features. If provided, the corresponding proof must From 4e4a8332a3b5160c0ac85bffb22aa3c8eb84e58b Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 24 Sep 2025 12:47:40 +1000 Subject: [PATCH 058/171] Add missing memory header for zstd --- include/session/config/user_profile.hpp | 1 - src/util.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index a96c2b49..a59c191e 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/src/util.cpp b/src/util.cpp index c05c7bdc..30bc4dcc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,6 +1,7 @@ #include #include +#include #include namespace session { From 975a611bbd5bdabdb719515705009f727b28c495 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 24 Sep 2025 15:07:01 +1000 Subject: [PATCH 059/171] Move ProProof into session_protocol.hpp Pro proof is part of the session protocol and is required by some of the higher-level helper functions in the crypto layer. Because of this we were having some circular dependency issues, Debian 12 ARM build was complaining that session_protocol.cpp was calling out to functions in session/config/pro.h which sits in a layer above us. This created a circular dependency and upon re-assessment the pro proof structures really belong in the protocol layer. What does belong in the config section is the top-level pro config object that contains the Session Pro rotating key pair and the proof itself. --- include/session/config/pro.h | 121 +---------- include/session/config/pro.hpp | 141 +----------- include/session/pro_backend.hpp | 3 +- include/session/session_encrypt.hpp | 2 + include/session/session_protocol.h | 124 ++++++++++- include/session/session_protocol.hpp | 125 ++++++++++- src/config/pro.cpp | 312 +++++---------------------- src/session_protocol.cpp | 201 ++++++++++++++++- tests/test_config_pro.cpp | 4 +- tests/test_session_protocol.cpp | 8 +- 10 files changed, 511 insertions(+), 530 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index df2b155c..b8bfadb0 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -9,132 +9,13 @@ extern "C" { #include #include "../export.h" -#include "../types.h" - -typedef enum PRO_STATUS { // See session::ProStatus - PRO_STATUS_NIL, - PRO_STATUS_INVALID_PRO_BACKEND_SIG, - PRO_STATUS_INVALID_USER_SIG, - PRO_STATUS_VALID, - PRO_STATUS_EXPIRED, -} PRO_STATUS; - -typedef struct pro_signed_message { - span_u8 sig; - span_u8 msg; -} pro_signed_message; - -typedef struct pro_proof { - uint8_t version; - uint8_t gen_index_hash[32]; - uint8_t rotating_pubkey[32]; - uint64_t expiry_unix_ts; - uint8_t sig[64]; -} pro_proof; +#include "session/session_protocol.h" typedef struct pro_config { uint8_t rotating_privkey[64]; pro_proof proof; } pro_pro_config; -/// API: pro/pro_proof_hash -/// -/// Generate the 32 byte hash that is to be signed by the rotating key or Session Pro Backend key to -/// embed in the envelope or proof respectively which other clients use to authenticate the validity -/// of a proof. -/// -/// Inputs: -/// - `proof` -- Proof to calculate the hash from -/// -/// Outputs: -/// - `bytes32` -- The 32 byte hash calculated from the proof -LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); - -/// API: pro/pro_proof_verify_signature -/// -/// Verify the proof was signed by the `verify_pubkey` -/// -/// 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: -/// - `bool` -- True if verified, false otherwise -LIBSESSION_EXPORT bool pro_proof_verify_signature( - pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len); - -/// API: pro/pro_proof_verify_message -/// -/// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature -/// passed in. This function throws if an signature is passed in that isn't 64 bytes. -/// -/// Inputs: -/// - `proof` -- Proof to verify -/// - `sig` -- Signature to verify with the `rotating_pubkey`. The signature should have -/// originally been signed over `msg` passed in. -/// - `sig_len` -- Length of the signature, should be 64 bytes -/// - `msg` -- Message that the signature signed over with. It will be verified using the -/// embedded `rotating_pubkey`. -/// - `msg_len` -- Length of the message -/// -/// Outputs: -/// - `bool` -- True if verified, false otherwise (bad signature, or, invalid arguments). -LIBSESSION_EXPORT bool pro_proof_verify_message( - pro_proof const* proof, - uint8_t const* sig, - size_t sig_len, - uint8_t const* msg, - size_t msg_len); - -/// API: pro/pro_proof_is_active -/// -/// Check if the Pro proof is currently entitled to Pro given the `unix_ts` with respect to the -/// proof's `expiry_unix_ts` -/// -/// Inputs: -/// - `proof` -- Proof to verify -/// - `unix_ts_s` -- The unix timestamp in seconds to check the proof expiry time against -/// -/// Outputs: -/// - `bool` -- True if expired, false otherwise -LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s); - -/// API: pro/pro_proof_status -/// -/// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has -/// not expired via `unix_ts_s` and optionally verify that the `signed_msg` was signed by the -/// `rotating_pubkey` embedded in the proof. -/// -/// Internally this function calls `pro_proof_verify_signature`, `pro_proof_verify_message` and -/// optionally `pro_proof_is_active` in sequence. This function fails if an invalidly sized public -/// key or signature are passed in. They must be 32 and 64 bytes respectively, the appropriate -/// invalid status will be returned. -/// -/// Inputs: -/// - `proof` -- Proof to verify -/// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if -/// they are the original signatory of the proof. -/// - `verify_pubkey_len` -- Length of the `verify_pubkey` should be 32 bytes -/// they are the original signatory of the proof. -/// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` -/// to determine if the proof has expired or not -/// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if -/// the embedded `rotating_pubkey` in the proof signed the given message. -/// -/// Outputs: -/// - `status` - The derived status given the components of the message. If `signed_msg` is -/// not set then this function can never return `PRO_STATUS_INVALID_USER_SIG` from the set of -/// possible enum values. Otherwise this funtion can return all possible values. -LIBSESSION_EXPORT PRO_STATUS pro_proof_status( - pro_proof const* proof, - const uint8_t* verify_pubkey, - size_t verify_pubkey_len, - uint64_t unix_ts_s, - const pro_signed_message* signed_msg); - /// API: pro/pro_verify /// /// Verify the proof was signed by the `verify_pubkey` and that the `rotating_privkey` in the `pro` diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 011abc77..62715a6b 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -1,143 +1,22 @@ #pragma once -#include - -#include -#include #include #include -#include -#include +#include namespace session::config { -enum ProProofVersion { ProProofVersion_v0 }; - -enum class ProStatus { - // Pro proof sig was not signed by the Pro backend key - InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, - // Pro sig in the envelope was not signed by the Rotating key - InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, - Valid = PRO_STATUS_VALID, // Proof is verified; has not expired - Expired = PRO_STATUS_EXPIRED, // Proof is verified; has expired -}; - -struct ProSignedMessage { - std::span sig; - std::span msg; -}; - -/// keys used currently or in the past (so that we don't reuse): -/// -/// @ - version -/// g - gen_index_hash -/// r - rotating ed25519 pubkey -/// e - expiry unix timestamp (in seconds) -/// s - proof signature, signed by the Session Pro Backend's ed25519 key -class ProProof { - public: - /// Version of the proof set by the Session Pro Backend - std::uint8_t version; - - /// Hash of the generation index set by the Session Pro Backend - array_uc32 gen_index_hash; - - /// The public key that the Session client registers their Session Pro entitlement under. - /// Session clients must sign messages with this key along side the sending of this proof for - /// the network to authenticate their usage of the proof - array_uc32 rotating_pubkey; - - /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid to - std::chrono::sys_seconds expiry_unix_ts; - - /// Signature over the contents of the proof. It is signed by the Session Pro Backend key which - /// is the entity responsible for issueing tamper-proof Sesison Pro certificates for Session - /// clients. - array_uc64 sig; - - /// API: pro/Proof::verify_signature - /// - /// Verify that the proof's contents was not tampered with by hashing the proof and checking - /// that the hash was signed by the secret key of the given Ed25519 public key. - /// - /// For Session Pro intents and purposes, we expect proofs to be signed by the Session Pro - /// Backend public key. This function throws if an incorrectly sized key is passed in. - /// - /// Inputs: - /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if - /// they are the original signatory of the proof. - /// - /// Outputs: - /// - `bool` - True if the given key was the signatory of the proof, false otherwise - bool verify_signature(const std::span& verify_pubkey) const; - - /// API: pro/Proof::verify_message - /// - /// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature - /// passed in. This function throws if an signature is passed in that isn't 64 bytes. - /// - /// Inputs: - /// - `sig` -- Signature to verify with the `rotating_pubkey`. The signature should have - /// originally been signed over `msg` passed in. - /// - `msg` -- Message that the signature signed over with. It will be verified using the - /// embedded `rotating_pubkey`. - /// - /// Outputs: - /// - `bool` - True if the message was signed by the embedded `rotating_pubkey` false otherwise. - bool verify_message(std::span sig, const std::span msg) const; - - /// API: pro/Proof::is_active - /// - /// Check if Pro proof is currently entitled to Pro given the `unix_ts` with respect to the - /// proof's `expiry_unix_ts` - /// - /// Inputs: - /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` - /// to determine if the proof has expired or not - /// - /// Outputs: - /// - `bool` - True if proof is active (i.e. has not expired), false otherwise. - bool is_active(std::chrono::sys_seconds unix_ts) const; - - /// API: pro/Proof::status - /// - /// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has - /// not expired via `unix_ts` and optionally verify that the `signed_msg` was signed by the - /// `rotating_pubkey` embedded in the proof. - /// - /// Internally this function calls `verify_signature`, `verify_message` and optionally - /// `is_active` in sequence. This function throws if an invalidly sized public key or signature - /// are passed in. They must be 32 and 64 bytes respectively. - /// - /// Inputs: - /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if - /// they are the original signatory of the proof. - /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` - /// to determine if the proof has expired or not - /// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if - /// the embedded `rotating_pubkey` in the proof signed the given message. - /// - /// Outputs: - /// - `ProStatus` - The derived status given the components of the message. If `signed_msg` is - /// not set then this function can never return `ProStatus::InvalidUserSig` from the set of - /// possible enum values. Otherwise this funtion can return all possible values. - ProStatus status( - std::span verify_pubkey, - std::chrono::sys_seconds unix_ts, - const std::optional& signed_msg); - - /// API: pro/Proof::hash - /// - /// Create a 32-byte hash from the proof. This hash is the payload that is signed in the proof. - array_uc32 hash() const; - - bool load(const dict& root); -}; - /// keys used currently or in the past (so that we don't reuse): /// -/// r - rotating ed25519 privkey -/// p - proof +/// p + pro data +/// | +/// +-- @ - version +/// +-- g - gen_index_hash +/// +-- r - rotating ed25519 pubkey +/// +-- e - expiry unix timestamp (in seconds) +/// +-- s - proof signature, signed by the Session Pro Backend's ed25519 key +/// +-- r - rotating ed25519 privkey +/// +-- p - proof class ProConfig { public: /// Private key for the public key key specified in the proof. This is synced between clients diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 9a05d08c..15c2cbfc 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -1,7 +1,8 @@ #pragma once -#include +#include #include +#include namespace session::pro_backend { diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index f3415e09..78d23528 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index b28ac490..c929b023 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -1,14 +1,13 @@ +#pragma once + #include -#include "config/pro.h" #include "export.h" #include "types.h" /// The C header for session_protocol. See the CPP header for more indepth comments. Only the /// differences between the C and CPP headers are documented to avoid duplication. -struct config_group_keys; - #ifdef __cplusplus extern "C" { #endif @@ -30,6 +29,27 @@ enum { PRO_HIGHER_CHARACTER_LIMIT = 10'000, }; +typedef enum PRO_STATUS { // See session::ProStatus + PRO_STATUS_NIL, + PRO_STATUS_INVALID_PRO_BACKEND_SIG, + PRO_STATUS_INVALID_USER_SIG, + PRO_STATUS_VALID, + PRO_STATUS_EXPIRED, +} PRO_STATUS; + +typedef struct pro_signed_message { + span_u8 sig; + span_u8 msg; +} pro_signed_message; + +typedef struct pro_proof { + uint8_t version; + uint8_t gen_index_hash[32]; + uint8_t rotating_pubkey[32]; + uint64_t expiry_unix_ts; + uint8_t sig[64]; +} pro_proof; + // Bit flags for features that are not currently able to be determined by the state stored in // Libsession. They are to be passed in by the client into `get_pro_msg_for_features` to return the // bitset of `PRO_FEATURES` that a message will use. @@ -118,6 +138,104 @@ typedef struct session_protocol_encrypted_for_destination { size_t error_len_incl_null_terminator; } session_protocol_encrypted_for_destination; +/// API: pro/pro_proof_hash +/// +/// Generate the 32 byte hash that is to be signed by the rotating key or Session Pro Backend key to +/// embed in the envelope or proof respectively which other clients use to authenticate the validity +/// of a proof. +/// +/// Inputs: +/// - `proof` -- Proof to calculate the hash from +/// +/// Outputs: +/// - `bytes32` -- The 32 byte hash calculated from the proof +LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); + +/// API: pro/pro_proof_verify_signature +/// +/// Verify the proof was signed by the `verify_pubkey` +/// +/// 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: +/// - `bool` -- True if verified, false otherwise +LIBSESSION_EXPORT bool pro_proof_verify_signature( + pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len); + +/// API: pro/pro_proof_verify_message +/// +/// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature +/// passed in. This function throws if an signature is passed in that isn't 64 bytes. +/// +/// Inputs: +/// - `proof` -- Proof to verify +/// - `sig` -- Signature to verify with the `rotating_pubkey`. The signature should have +/// originally been signed over `msg` passed in. +/// - `sig_len` -- Length of the signature, should be 64 bytes +/// - `msg` -- Message that the signature signed over with. It will be verified using the +/// embedded `rotating_pubkey`. +/// - `msg_len` -- Length of the message +/// +/// Outputs: +/// - `bool` -- True if verified, false otherwise (bad signature, or, invalid arguments). +LIBSESSION_EXPORT bool pro_proof_verify_message( + pro_proof const* proof, + uint8_t const* sig, + size_t sig_len, + uint8_t const* msg, + size_t msg_len); + +/// API: pro/pro_proof_is_active +/// +/// Check if the Pro proof is currently entitled to Pro given the `unix_ts` with respect to the +/// proof's `expiry_unix_ts` +/// +/// Inputs: +/// - `proof` -- Proof to verify +/// - `unix_ts_s` -- The unix timestamp in seconds to check the proof expiry time against +/// +/// Outputs: +/// - `bool` -- True if expired, false otherwise +LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s); + +/// API: pro/pro_proof_status +/// +/// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has +/// not expired via `unix_ts_s` and optionally verify that the `signed_msg` was signed by the +/// `rotating_pubkey` embedded in the proof. +/// +/// Internally this function calls `pro_proof_verify_signature`, `pro_proof_verify_message` and +/// optionally `pro_proof_is_active` in sequence. This function fails if an invalidly sized public +/// key or signature are passed in. They must be 32 and 64 bytes respectively, the appropriate +/// invalid status will be returned. +/// +/// Inputs: +/// - `proof` -- Proof to verify +/// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if +/// they are the original signatory of the proof. +/// - `verify_pubkey_len` -- Length of the `verify_pubkey` should be 32 bytes +/// they are the original signatory of the proof. +/// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` +/// to determine if the proof has expired or not +/// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if +/// the embedded `rotating_pubkey` in the proof signed the given message. +/// +/// Outputs: +/// - `status` - The derived status given the components of the message. If `signed_msg` is +/// not set then this function can never return `PRO_STATUS_INVALID_USER_SIG` from the set of +/// possible enum values. Otherwise this funtion can return all possible values. +LIBSESSION_EXPORT PRO_STATUS pro_proof_status( + pro_proof const* proof, + const uint8_t* verify_pubkey, + size_t verify_pubkey_len, + uint64_t unix_ts_s, + const pro_signed_message* signed_msg); + /// API: session_protocol/session_protocol_get_pro_features_for_msg /// /// Determine the Pro features that are used in a given conversation message. diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index f5e9976a..1e9ce19c 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -2,7 +2,10 @@ #include -#include +#include +#include +#include +#include #include #include @@ -33,9 +36,119 @@ namespace session { -namespace config::groups { - class Keys; -} +enum ProProofVersion { ProProofVersion_v0 }; + +enum class ProStatus { + // Pro proof sig was not signed by the Pro backend key + InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, + // Pro sig in the envelope was not signed by the Rotating key + InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, + Valid = PRO_STATUS_VALID, // Proof is verified; has not expired + Expired = PRO_STATUS_EXPIRED, // Proof is verified; has expired +}; + +struct ProSignedMessage { + std::span sig; + std::span msg; +}; + +class ProProof { + public: + /// Version of the proof set by the Session Pro Backend + std::uint8_t version; + + /// Hash of the generation index set by the Session Pro Backend + array_uc32 gen_index_hash; + + /// The public key that the Session client registers their Session Pro entitlement under. + /// Session clients must sign messages with this key along side the sending of this proof for + /// the network to authenticate their usage of the proof + array_uc32 rotating_pubkey; + + /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid to + std::chrono::sys_seconds expiry_unix_ts; + + /// Signature over the contents of the proof. It is signed by the Session Pro Backend key which + /// is the entity responsible for issueing tamper-proof Sesison Pro certificates for Session + /// clients. + array_uc64 sig; + + /// API: pro/Proof::verify_signature + /// + /// Verify that the proof's contents was not tampered with by hashing the proof and checking + /// that the hash was signed by the secret key of the given Ed25519 public key. + /// + /// For Session Pro intents and purposes, we expect proofs to be signed by the Session Pro + /// Backend public key. This function throws if an incorrectly sized key is passed in. + /// + /// Inputs: + /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if + /// they are the original signatory of the proof. + /// + /// Outputs: + /// - `bool` - True if the given key was the signatory of the proof, false otherwise + bool verify_signature(const std::span& verify_pubkey) const; + + /// API: pro/Proof::verify_message + /// + /// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature + /// passed in. This function throws if an signature is passed in that isn't 64 bytes. + /// + /// Inputs: + /// - `sig` -- Signature to verify with the `rotating_pubkey`. The signature should have + /// originally been signed over `msg` passed in. + /// - `msg` -- Message that the signature signed over with. It will be verified using the + /// embedded `rotating_pubkey`. + /// + /// Outputs: + /// - `bool` - True if the message was signed by the embedded `rotating_pubkey` false otherwise. + bool verify_message(std::span sig, const std::span msg) const; + + /// API: pro/Proof::is_active + /// + /// Check if Pro proof is currently entitled to Pro given the `unix_ts` with respect to the + /// proof's `expiry_unix_ts` + /// + /// Inputs: + /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` + /// to determine if the proof has expired or not + /// + /// Outputs: + /// - `bool` - True if proof is active (i.e. has not expired), false otherwise. + bool is_active(std::chrono::sys_seconds unix_ts) const; + + /// API: pro/Proof::status + /// + /// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has + /// not expired via `unix_ts` and optionally verify that the `signed_msg` was signed by the + /// `rotating_pubkey` embedded in the proof. + /// + /// Internally this function calls `verify_signature`, `verify_message` and optionally + /// `is_active` in sequence. This function throws if an invalidly sized public key or signature + /// are passed in. They must be 32 and 64 bytes respectively. + /// + /// Inputs: + /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if + /// they are the original signatory of the proof. + /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` + /// to determine if the proof has expired or not + /// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if + /// the embedded `rotating_pubkey` in the proof signed the given message. + /// + /// Outputs: + /// - `ProStatus` - The derived status given the components of the message. If `signed_msg` is + /// not set then this function can never return `ProStatus::InvalidUserSig` from the set of + /// possible enum values. Otherwise this funtion can return all possible values. + ProStatus status( + std::span verify_pubkey, + std::chrono::sys_seconds unix_ts, + const std::optional& signed_msg); + + /// API: pro/Proof::hash + /// + /// Create a 32-byte hash from the proof. This hash is the payload that is signed in the proof. + array_uc32 hash() const; +}; enum class DestinationType { ContactOrSyncMessage = DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE, @@ -91,10 +204,10 @@ struct Envelope { }; struct DecryptedPro { - config::ProStatus status; // Validity of the proof embedded in the envelope + ProStatus status; // Validity of the proof embedded in the envelope // Session Pro proof that was embedded in the envelope, this is always populated irrespective of // the status but the validity of the contents should be verified by checking `status` - config::ProProof proof; + ProProof proof; PRO_FEATURES features; // Bit flag features that were used in the embedded message }; diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 281a5c2a..66e92156 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -6,54 +6,11 @@ #include "internal.hpp" -namespace { -session::array_uc32 proof_hash_internal( - std::uint8_t version, - std::span gen_index_hash, - std::span rotating_pubkey, - std::uint64_t expiry_unix_ts) { - // This must match the hashing routine at - // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 - session::array_uc32 result = {}; - crypto_generichash_blake2b_state state; - crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); - crypto_generichash_blake2b_update(&state, &version, sizeof(version)); - crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); - crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); - crypto_generichash_blake2b_update( - &state, reinterpret_cast(&expiry_unix_ts), sizeof(expiry_unix_ts)); - crypto_generichash_blake2b_final(&state, result.data(), result.size()); - return result; -} - -bool proof_verify_signature_internal( - std::span hash, - std::span sig, - std::span verify_pubkey) { - // The C/C++ interface verifies that the payloads are the correct size using the type system so - // only need asserts here. - assert(hash.size() == 32); - assert(sig.size() == crypto_sign_ed25519_BYTES); - assert(verify_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); - - int verify_result = crypto_sign_ed25519_verify_detached( - sig.data(), hash.data(), hash.size(), verify_pubkey.data()); - bool result = verify_result == 0; - return result; -} - -bool config_verify_signature_internal( - std::span rotating_privkey, - std::span verify_pubkey, - std::uint8_t version, - std::span gen_index_hash, - std::span rotating_pubkey, - std::uint64_t expiry_unix_ts, - std::span sig) { - - session::array_uc32 hash = - proof_hash_internal(version, gen_index_hash, rotating_pubkey, expiry_unix_ts); - if (!proof_verify_signature_internal(hash, sig, verify_pubkey)) +namespace session::config { +static_assert(sizeof(((ProConfig*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); +bool ProConfig::verify_signature(const array_uc32& verify_pubkey) const { + uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); + if (!proof.verify_signature(verify_pubkey)) return false; session::array_uc32 rederived_pk; @@ -62,131 +19,10 @@ bool config_verify_signature_internal( rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); bool result = false; - if (rederived_pk.size() == rotating_pubkey.size()) - result = std::memcmp(rederived_pk.data(), rotating_pubkey.data(), rederived_pk.size()) == 0; - - return result; -} - -bool proof_verify_message_internal( - std::span rotating_pubkey, - std::span sig, - std::span msg) { - // C++ throws on bad size, C uses a fixed sized array - assert(rotating_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); - if (sig.size() != crypto_sign_ed25519_BYTES) - return false; - - int verify_result = crypto_sign_ed25519_verify_detached( - reinterpret_cast(sig.data()), - msg.data(), - msg.size(), - reinterpret_cast(rotating_pubkey.data())); - bool result = verify_result == 0; - return result; -} - -bool proof_is_active_internal(uint64_t expiry_unix_ts, uint64_t unix_ts_s) { - bool result = unix_ts_s <= expiry_unix_ts; - return result; -} -} // namespace - -namespace session::config { - -static_assert(sizeof(((ProConfig*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); -static_assert(sizeof(((ProProof*)0)->gen_index_hash) == 32); -static_assert(sizeof(((ProProof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); -static_assert(sizeof(((ProProof*)0)->sig) == crypto_sign_ed25519_BYTES); - -bool ProProof::verify_signature(const std::span& verify_pubkey) const { - if (verify_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) - throw std::invalid_argument{fmt::format( - "Invalid verify_pubkey: Must be 32 byte Ed25519 public key (was: {})", - verify_pubkey.size())}; - - array_uc32 hash_to_sign = hash(); - bool result = proof_verify_signature_internal(hash_to_sign, sig, verify_pubkey); - return result; -} - -bool ProProof::verify_message(std::span sig, std::span msg) const { - if (sig.size() != crypto_sign_ed25519_BYTES) - throw std::invalid_argument{fmt::format( - "Invalid signed_msg: Signature must be 64 bytes (was: {})", sig.size())}; - bool result = proof_verify_message_internal(rotating_pubkey, sig, msg); - return result; -} - -bool ProProof::is_active(std::chrono::sys_seconds unix_ts) const { - bool result = proof_is_active_internal( - expiry_unix_ts.time_since_epoch().count(), unix_ts.time_since_epoch().count()); - return result; -} - -ProStatus ProProof::status( - std::span verify_pubkey, - std::chrono::sys_seconds unix_ts, - const std::optional& signed_msg) { - ProStatus result = ProStatus::Valid; - // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was - // issued by an authoritative backend) - if (!verify_signature(verify_pubkey)) - result = ProStatus::InvalidProBackendSig; - - // Check if the message was signed if the user passed one in to verify against - if (result == ProStatus::Valid && signed_msg) { - if (!verify_message(signed_msg->sig, signed_msg->msg)) - result = ProStatus::InvalidUserSig; - } - - // Check if the proof has expired - if (result == ProStatus::Valid && !is_active(unix_ts)) - result = ProStatus::Expired; - return result; -} - -array_uc32 ProProof::hash() const { - array_uc32 result = proof_hash_internal( - version, gen_index_hash, rotating_pubkey, expiry_unix_ts.time_since_epoch().count()); - return result; -} - -bool ProProof::load(const dict& root) { - std::optional version = maybe_int(root, "@"); - std::optional> maybe_gen_index_hash = maybe_vector(root, "g"); - std::optional> maybe_rotating_pubkey = maybe_vector(root, "r"); - std::optional maybe_expiry_unix_ts = maybe_ts(root, "e"); - std::optional> maybe_sig = maybe_vector(root, "s"); - - if (!version) - return false; - if (!maybe_gen_index_hash || maybe_gen_index_hash->size() != gen_index_hash.size()) - return false; - if (!maybe_rotating_pubkey || maybe_rotating_pubkey->size() != rotating_pubkey.max_size()) - return false; - if (!maybe_sig || maybe_sig->size() != sig.max_size()) - return false; - - version = *version; - std::memcpy(gen_index_hash.data(), maybe_gen_index_hash->data(), gen_index_hash.size()); - std::memcpy(rotating_pubkey.data(), maybe_rotating_pubkey->data(), rotating_pubkey.size()); - expiry_unix_ts = *maybe_expiry_unix_ts; - std::memcpy(sig.data(), maybe_sig->data(), sig.size()); - - return true; -} - -bool ProConfig::verify_signature(const array_uc32& verify_pubkey) const { - uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); - bool result = config_verify_signature_internal( - rotating_privkey, - verify_pubkey, - proof.version, - proof.gen_index_hash, - proof.rotating_pubkey, - expiry_unix_ts, - proof.sig); + if (rederived_pk.size() == proof.rotating_pubkey.size()) + result = std::memcmp( + rederived_pk.data(), proof.rotating_pubkey.data(), rederived_pk.size()) == + 0; return result; } @@ -205,8 +41,36 @@ bool ProConfig::load(const dict& root) { if (!maybe_rotating_privkey || maybe_rotating_privkey->size() != rotating_privkey.max_size()) return false; - if (!proof.load(*p)) - return false; + // NOTE: Load into the proof object + { + std::optional version = maybe_int(*p, "@"); + std::optional> maybe_gen_index_hash = maybe_vector(*p, "g"); + std::optional> maybe_rotating_pubkey = maybe_vector(*p, "r"); + std::optional maybe_expiry_unix_ts = maybe_ts(*p, "e"); + std::optional> maybe_sig = maybe_vector(*p, "s"); + + if (!version) + return false; + if (!maybe_gen_index_hash || maybe_gen_index_hash->size() != proof.gen_index_hash.size()) + return false; + if (!maybe_rotating_pubkey || + maybe_rotating_pubkey->size() != proof.rotating_pubkey.max_size()) + return false; + if (!maybe_sig || maybe_sig->size() != proof.sig.max_size()) + return false; + + version = *version; + std::memcpy( + proof.gen_index_hash.data(), + maybe_gen_index_hash->data(), + proof.gen_index_hash.size()); + std::memcpy( + proof.rotating_pubkey.data(), + maybe_rotating_pubkey->data(), + proof.rotating_pubkey.size()); + proof.expiry_unix_ts = *maybe_expiry_unix_ts; + std::memcpy(proof.sig.data(), maybe_sig->data(), proof.sig.size()); + } std::memcpy(rotating_privkey.data(), maybe_rotating_privkey->data(), rotating_privkey.size()); return true; @@ -216,88 +80,30 @@ bool ProConfig::load(const dict& root) { // Ensure these are byte buffers and we can just use sizeof to build std::spans to interop with C++ static_assert((sizeof((pro_pro_config*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); -static_assert((sizeof((pro_proof*)0)->gen_index_hash) == 32); -static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); -static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); - -LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { - bytes32 result = {}; - if (proof) { - session::array_uc32 hash = proof_hash_internal( - proof->version, - proof->gen_index_hash, - proof->rotating_pubkey, - proof->expiry_unix_ts); - std::memcpy(result.data, hash.data(), hash.size()); - } - return result; -} - -LIBSESSION_C_API bool pro_proof_verify_signature( - pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { - if (!proof || verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) - return false; - auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); - session::array_uc32 hash = proof_hash_internal( - proof->version, proof->gen_index_hash, proof->rotating_pubkey, proof->expiry_unix_ts); - bool result = proof_verify_signature_internal(hash, proof->sig, verify_pubkey_span); - return result; -} - -LIBSESSION_C_API bool pro_proof_verify_message( - pro_proof const* proof, - uint8_t const* sig, - size_t sig_len, - uint8_t const* msg, - size_t msg_len) { - std::span sig_span = {sig, sig_len}; - std::span msg_span = {msg, msg_len}; - bool result = proof_verify_message_internal(proof->rotating_pubkey, sig_span, msg_span); - return result; -} - -LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) { - bool result = proof && proof_is_active_internal(proof->expiry_unix_ts, unix_ts_s); - return result; -} - -LIBSESSION_C_API PRO_STATUS pro_proof_status( - pro_proof const* proof, - const uint8_t* verify_pubkey, - size_t verify_pubkey_len, - uint64_t unix_ts_s, - const pro_signed_message* signed_msg) { - PRO_STATUS result = PRO_STATUS_VALID; - if (!pro_proof_verify_signature(proof, verify_pubkey, verify_pubkey_len)) - result = PRO_STATUS_INVALID_PRO_BACKEND_SIG; - - // Check if the message was signed if the user passed one in to verify against - if (result == PRO_STATUS_VALID && signed_msg) { - if (!pro_proof_verify_message( - proof, - signed_msg->sig.data, - signed_msg->sig.size, - signed_msg->msg.data, - signed_msg->msg.size)) - result = PRO_STATUS_INVALID_USER_SIG; - } - - // Check if the proof has expired - if (result == PRO_STATUS_VALID && !pro_proof_is_active(proof, unix_ts_s)) - result = PRO_STATUS_EXPIRED; - return result; -} LIBSESSION_C_API bool pro_config_verify_signature( pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { - auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); - bool result = config_verify_signature_internal( - pro->rotating_privkey, - verify_pubkey_span, - pro->proof.version, + if (verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) + return false; + + session::config::ProConfig config = {}; + std::memcpy( + config.rotating_privkey.data(), pro->rotating_privkey, sizeof pro->rotating_privkey); + config.proof.version = pro->proof.version; + std::memcpy( + config.proof.gen_index_hash.data(), pro->proof.gen_index_hash, + sizeof pro->proof.gen_index_hash); + std::memcpy( + config.proof.rotating_pubkey.data(), pro->proof.rotating_pubkey, - pro->proof.expiry_unix_ts, - pro->proof.sig); + sizeof pro->proof.rotating_pubkey); + config.proof.expiry_unix_ts = + std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts)); + std::memcpy(config.proof.sig.data(), pro->proof.sig, sizeof pro->proof.sig); + + session::array_uc32 verify_pubkey_cpp; + std::memcpy(verify_pubkey_cpp.data(), verify_pubkey, verify_pubkey_len); + bool result = config.verify_signature(verify_pubkey_cpp); return result; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 0158d00e..4153187d 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,13 +1,9 @@ #include #include -#include +#include #include #include -#include -#include -#include -#include #include #include #include @@ -16,8 +12,125 @@ #include "WebSocketResources.pb.h" #include "session/export.h" +namespace { +session::array_uc32 proof_hash_internal( + std::uint8_t version, + std::span gen_index_hash, + std::span rotating_pubkey, + std::uint64_t expiry_unix_ts) { + // This must match the hashing routine at + // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 + session::array_uc32 result = {}; + crypto_generichash_blake2b_state state; + crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); + crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&expiry_unix_ts), sizeof(expiry_unix_ts)); + crypto_generichash_blake2b_final(&state, result.data(), result.size()); + return result; +} + +bool proof_verify_signature_internal( + std::span hash, + std::span sig, + std::span verify_pubkey) { + // The C/C++ interface verifies that the payloads are the correct size using the type system so + // only need asserts here. + assert(hash.size() == 32); + assert(sig.size() == crypto_sign_ed25519_BYTES); + assert(verify_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + + int verify_result = crypto_sign_ed25519_verify_detached( + sig.data(), hash.data(), hash.size(), verify_pubkey.data()); + bool result = verify_result == 0; + return result; +} + +bool proof_verify_message_internal( + std::span rotating_pubkey, + std::span sig, + std::span msg) { + // C++ throws on bad size, C uses a fixed sized array + assert(rotating_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); + if (sig.size() != crypto_sign_ed25519_BYTES) + return false; + + int verify_result = crypto_sign_ed25519_verify_detached( + reinterpret_cast(sig.data()), + msg.data(), + msg.size(), + reinterpret_cast(rotating_pubkey.data())); + bool result = verify_result == 0; + return result; +} + +bool proof_is_active_internal(uint64_t expiry_unix_ts, uint64_t unix_ts_s) { + bool result = unix_ts_s <= expiry_unix_ts; + return result; +} +} // namespace + namespace session { +static_assert(sizeof(((ProProof*)0)->gen_index_hash) == 32); +static_assert(sizeof(((ProProof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert(sizeof(((ProProof*)0)->sig) == crypto_sign_ed25519_BYTES); + +bool ProProof::verify_signature(const std::span& verify_pubkey) const { + if (verify_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) + throw std::invalid_argument{fmt::format( + "Invalid verify_pubkey: Must be 32 byte Ed25519 public key (was: {})", + verify_pubkey.size())}; + + array_uc32 hash_to_sign = hash(); + bool result = proof_verify_signature_internal(hash_to_sign, sig, verify_pubkey); + return result; +} + +bool ProProof::verify_message(std::span sig, std::span msg) const { + if (sig.size() != crypto_sign_ed25519_BYTES) + throw std::invalid_argument{fmt::format( + "Invalid signed_msg: Signature must be 64 bytes (was: {})", sig.size())}; + bool result = proof_verify_message_internal(rotating_pubkey, sig, msg); + return result; +} + +bool ProProof::is_active(std::chrono::sys_seconds unix_ts) const { + bool result = proof_is_active_internal( + expiry_unix_ts.time_since_epoch().count(), unix_ts.time_since_epoch().count()); + return result; +} + +ProStatus ProProof::status( + std::span verify_pubkey, + std::chrono::sys_seconds unix_ts, + const std::optional& signed_msg) { + ProStatus result = ProStatus::Valid; + // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was + // issued by an authoritative backend) + if (!verify_signature(verify_pubkey)) + result = ProStatus::InvalidProBackendSig; + + // Check if the message was signed if the user passed one in to verify against + if (result == ProStatus::Valid && signed_msg) { + if (!verify_message(signed_msg->sig, signed_msg->msg)) + result = ProStatus::InvalidUserSig; + } + + // Check if the proof has expired + if (result == ProStatus::Valid && !is_active(unix_ts)) + result = ProStatus::Expired; + return result; +} + +array_uc32 ProProof::hash() const { + array_uc32 result = proof_hash_internal( + version, gen_index_hash, rotating_pubkey, expiry_unix_ts.time_since_epoch().count()); + return result; +} + PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES extra) { PRO_FEATURES result = PRO_FEATURES_NIL; @@ -502,10 +615,10 @@ DecryptedEnvelope decrypt_envelope( // Parse the proof from protobufs const SessionProtos::ProProof& proto_proof = pro_msg.proof(); - session::config::ProProof& proof = pro.proof; + session::ProProof& proof = pro.proof; // clang-format off size_t proof_errors = 0; - proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::ProProofVersion_v0); proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); proof_errors += !proto_proof.has_expiryunixts(); @@ -533,7 +646,7 @@ DecryptedEnvelope decrypt_envelope( // Evaluate the pro status given the extracted components (was it signed, is it expired, // was the message signed validly?) - config::ProSignedMessage signed_msg = {}; + ProSignedMessage signed_msg = {}; signed_msg.sig = to_span(pro_sig); signed_msg.msg = result.content_plaintext; pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); @@ -545,6 +658,78 @@ DecryptedEnvelope decrypt_envelope( using namespace session; +static_assert((sizeof((pro_proof*)0)->gen_index_hash) == 32); +static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); + +LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { + bytes32 result = {}; + if (proof) { + session::array_uc32 hash = proof_hash_internal( + proof->version, + proof->gen_index_hash, + proof->rotating_pubkey, + proof->expiry_unix_ts); + std::memcpy(result.data, hash.data(), hash.size()); + } + return result; +} + +LIBSESSION_C_API bool pro_proof_verify_signature( + pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { + if (!proof || verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) + return false; + auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); + session::array_uc32 hash = proof_hash_internal( + proof->version, proof->gen_index_hash, proof->rotating_pubkey, proof->expiry_unix_ts); + bool result = proof_verify_signature_internal(hash, proof->sig, verify_pubkey_span); + return result; +} + +LIBSESSION_C_API bool pro_proof_verify_message( + pro_proof const* proof, + uint8_t const* sig, + size_t sig_len, + uint8_t const* msg, + size_t msg_len) { + std::span sig_span = {sig, sig_len}; + std::span msg_span = {msg, msg_len}; + bool result = proof_verify_message_internal(proof->rotating_pubkey, sig_span, msg_span); + return result; +} + +LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) { + bool result = proof && proof_is_active_internal(proof->expiry_unix_ts, unix_ts_s); + return result; +} + +LIBSESSION_C_API PRO_STATUS pro_proof_status( + pro_proof const* proof, + const uint8_t* verify_pubkey, + size_t verify_pubkey_len, + uint64_t unix_ts_s, + const pro_signed_message* signed_msg) { + PRO_STATUS result = PRO_STATUS_VALID; + if (!pro_proof_verify_signature(proof, verify_pubkey, verify_pubkey_len)) + result = PRO_STATUS_INVALID_PRO_BACKEND_SIG; + + // Check if the message was signed if the user passed one in to verify against + if (result == PRO_STATUS_VALID && signed_msg) { + if (!pro_proof_verify_message( + proof, + signed_msg->sig.data, + signed_msg->sig.size, + signed_msg->msg.data, + signed_msg->msg.size)) + result = PRO_STATUS_INVALID_USER_SIG; + } + + // Check if the proof has expired + if (result == PRO_STATUS_VALID && !pro_proof_is_active(proof, unix_ts_s)) + result = PRO_STATUS_EXPIRED; + return result; +} + LIBSESSION_C_API PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) { PRO_FEATURES result = get_pro_features_for_msg(msg_size, flags); diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 9937c659..eb98ece2 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -110,7 +110,7 @@ TEST_CASE("Pro", "[config][pro]") { session::config::dict good_dict; { // clang-format off - const session::config::ProProof& proof = pro_cpp.proof; + const session::ProProof& proof = pro_cpp.proof; good_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ @@ -141,7 +141,7 @@ TEST_CASE("Pro", "[config][pro]") { broken_sig[0] = ~broken_sig[0]; // Break the sig // clang-format off - const session::config::ProProof& proof = pro_cpp.proof; + const session::ProProof& proof = pro_cpp.proof; bad_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 148c419a..5e3e2bec 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -2,10 +2,6 @@ #include #include -#include -#include -#include -#include #include #include #include @@ -18,7 +14,7 @@ using namespace session; struct SerialisedProtobufContentWithProForTesting { - config::ProProof proof; + ProProof proof; std::string plaintext; array_uc64 sig_over_plaintext_with_user_pro_key; array_uc32 pro_proof_hash; @@ -222,7 +218,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encrypt_for_destination_free(&encrypt_result); // Verify pro - config::ProProof nil_proof = {}; + ProProof nil_proof = {}; array_uc32 nil_hash = nil_proof.hash(); bytes32 decrypt_result_pro_hash = pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(decrypt_result.pro_status == PRO_STATUS_NIL); // Pro was not attached From fa4a11a9796c4fe2d7d7f8404ff94458dbcffca4 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 4 Aug 2025 16:43:08 +1000 Subject: [PATCH 060/171] Add pro proof and rotating key pair to user profile --- include/session/config/pro.h | 2 +- include/session/config/user_profile.hpp | 1 + src/config/pro.cpp | 1 + src/config/user_profile.cpp | 1 - 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index b8bfadb0..2618957c 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -31,7 +31,7 @@ typedef struct pro_config { /// Outputs: /// - `bytes32` -- The 32 byte hash calculated from the proof LIBSESSION_EXPORT bool pro_config_verify_signature( - pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len); + pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len); #ifdef __cplusplus } // extern "C" diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index a59c191e..20027d6a 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -8,6 +8,7 @@ #include "namespaces.hpp" #include "pro.hpp" #include "profile_pic.hpp" +#include "pro.hpp" namespace session::config { diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 66e92156..0d1ac56b 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "internal.hpp" diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index ba36a51b..aef24d9b 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -315,5 +315,4 @@ LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro std::memcpy(val.proof.sig.data(), pro->proof.sig, val.proof.sig.size()); unbox(conf)->set_pro_config(val); } - } // extern "C" From b8b48193bc40db8d4621d17946d837bdfc4ba6d9 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 6 Aug 2025 16:06:44 +1000 Subject: [PATCH 061/171] Add Pro message to Content and decrypt it --- include/session/config/pro.hpp | 2 + include/session/pro.hpp | 72 ++++++++++++++++++++++++++++++++++ src/pro_backend.cpp | 2 + 3 files changed, 76 insertions(+) create mode 100644 include/session/pro.hpp diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 62715a6b..7c5380f2 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -6,6 +6,8 @@ namespace session::config { +enum ProProofVersion { ProProofVersion_v0 }; + /// keys used currently or in the past (so that we don't reuse): /// /// p + pro data diff --git a/include/session/pro.hpp b/include/session/pro.hpp new file mode 100644 index 00000000..d41776d2 --- /dev/null +++ b/include/session/pro.hpp @@ -0,0 +1,72 @@ +#pragma once + +#include +#include + +namespace session::pro { + +struct add_payment_request { + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + array_uc32 payment_token; + array_uc32 master_sig; + array_uc32 rotating_sig; + std::string to_json() const; +}; + +struct get_proof_request { + std::uint8_t version; + array_uc32 master_pkey; + array_uc32 rotating_pkey; + std::chrono::seconds unix_ts_s; + array_uc32 master_sig; + array_uc32 rotating_sig; + std::string to_json() const; +}; + +struct master_rotating_sigs { + array_uc64 master_sig; + array_uc64 rotating_sig; +}; + +struct revocation_item { + array_uc32 gen_index_hash; + std::chrono::seconds expiry_unix_ts; +}; + +enum class Status { + Nil, // Pro proof was not set + Invalid, // Pro proof was set; signature validation failed + Valid, // Pro proof was set, is verified; has not expired + Expired, // Pro proof was set, is verified; has expired +}; + +typedef std::uint32_t FeatureFlag; +enum FeatureFlag_ { + FeatureFlag_HigherCharacterLimit = 0 << 1, + FeatureFlag_ProBadge = 1 << 1, + FeatureFlag_AnimatedAvatar = 2 << 1, + FeatureFlag_All = + FeatureFlag_HigherCharacterLimit | FeatureFlag_ProBadge | FeatureFlag_AnimatedAvatar, +}; + +struct DecryptIncomingWithPro +{ + std::vector plaintext; + std::vector ed25519_pubkey; + ProProof pro_proof; + Status pro_status; + FeatureFlag pro_flags; +}; + +master_rotating_sigs build_get_proof_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts); +master_rotating_sigs build_add_payment_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); + +constexpr array_uc32 BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + +} // namespace session::pro diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index f54d5bf8..4b84843b 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include "SessionProtos.pb.h" namespace session::pro_backend { master_rotating_sigs build_get_proof_sigs( From 7d6d7cb33492d0b9b241e4c6783a093f41852682 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 8 Aug 2025 16:29:31 +1000 Subject: [PATCH 062/171] Port encrypt for namespace into libsession --- include/session/config/pro.h | 1 + include/session/config/user_profile.h | 1 + include/session/pro.hpp | 72 --------------------------- 3 files changed, 2 insertions(+), 72 deletions(-) delete mode 100644 include/session/pro.hpp diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 2618957c..ccbe8d59 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -4,6 +4,7 @@ extern "C" { #endif +#include #include #include #include diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index ee7c842e..874a426d 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -7,6 +7,7 @@ extern "C" { #include "base.h" #include "pro.h" #include "profile_pic.h" +#include "pro.h" /// API: user_profile/user_profile_init /// diff --git a/include/session/pro.hpp b/include/session/pro.hpp deleted file mode 100644 index d41776d2..00000000 --- a/include/session/pro.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include - -namespace session::pro { - -struct add_payment_request { - std::uint8_t version; - array_uc32 master_pkey; - array_uc32 rotating_pkey; - array_uc32 payment_token; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; - -struct get_proof_request { - std::uint8_t version; - array_uc32 master_pkey; - array_uc32 rotating_pkey; - std::chrono::seconds unix_ts_s; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; - -struct master_rotating_sigs { - array_uc64 master_sig; - array_uc64 rotating_sig; -}; - -struct revocation_item { - array_uc32 gen_index_hash; - std::chrono::seconds expiry_unix_ts; -}; - -enum class Status { - Nil, // Pro proof was not set - Invalid, // Pro proof was set; signature validation failed - Valid, // Pro proof was set, is verified; has not expired - Expired, // Pro proof was set, is verified; has expired -}; - -typedef std::uint32_t FeatureFlag; -enum FeatureFlag_ { - FeatureFlag_HigherCharacterLimit = 0 << 1, - FeatureFlag_ProBadge = 1 << 1, - FeatureFlag_AnimatedAvatar = 2 << 1, - FeatureFlag_All = - FeatureFlag_HigherCharacterLimit | FeatureFlag_ProBadge | FeatureFlag_AnimatedAvatar, -}; - -struct DecryptIncomingWithPro -{ - std::vector plaintext; - std::vector ed25519_pubkey; - ProProof pro_proof; - Status pro_status; - FeatureFlag pro_flags; -}; - -master_rotating_sigs build_get_proof_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, std::chrono::seconds unix_ts); -master_rotating_sigs build_add_payment_sigs(const array_uc64& master_privkey, const array_uc64& rotating_privkey, const array_uc32& payment_token_hash, std::chrono::seconds unix_ts); - -constexpr array_uc32 BACKEND_PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - -} // namespace session::pro From 9f0907edf6aad91b9fe48e18d06b02ba8f310c20 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 14 Aug 2025 17:37:30 +1000 Subject: [PATCH 063/171] Linting --- include/session/config/pro.h | 1 - include/session/config/user_profile.h | 1 - include/session/config/user_profile.hpp | 1 - 3 files changed, 3 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index ccbe8d59..2618957c 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -4,7 +4,6 @@ extern "C" { #endif -#include #include #include #include diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index 874a426d..ee7c842e 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -7,7 +7,6 @@ extern "C" { #include "base.h" #include "pro.h" #include "profile_pic.h" -#include "pro.h" /// API: user_profile/user_profile_init /// diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index 20027d6a..a59c191e 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -8,7 +8,6 @@ #include "namespaces.hpp" #include "pro.hpp" #include "profile_pic.hpp" -#include "pro.hpp" namespace session::config { From 04321d29766f7915e4bc53f5739df5ef51406893 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 15 Aug 2025 12:07:09 +1000 Subject: [PATCH 064/171] Move group msg encryption primitive into session encrypt, avoids circular dependency --- include/session/config/groups/keys.hpp | 3 +-- src/config/groups/keys.cpp | 1 + src/util.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/session/config/groups/keys.hpp b/include/session/config/groups/keys.hpp index c8f7c194..5eaa27bb 100644 --- a/include/session/config/groups/keys.hpp +++ b/include/session/config/groups/keys.hpp @@ -700,8 +700,7 @@ class Keys : public ConfigSig { /// 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 diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index a09c8d88..293322c4 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -24,6 +24,7 @@ #include "session/multi_encrypt.hpp" #include "session/session_encrypt.hpp" #include "session/xed25519.hpp" +#include "session/session_encrypt.hpp" using namespace std::literals; diff --git a/src/util.cpp b/src/util.cpp index 30bc4dcc..1dd49540 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace session { From 3f35b52d9c462cf3ab63ff39c71e1bad5149e759 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 21 Aug 2025 14:05:50 +1000 Subject: [PATCH 065/171] Add docs to pro config --- include/session/config/pro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 2618957c..df1b2a6b 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -16,7 +16,7 @@ typedef struct pro_config { pro_proof proof; } pro_pro_config; -/// API: pro/pro_verify +/// API: pro/pro_config_verify_signature /// /// 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. From c2a05bac1975bdb03868f5bc703330d28f5fcd05 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 22 Aug 2025 17:56:17 +1000 Subject: [PATCH 066/171] Polish C++ pro backend APIs and add C variants --- include/session/pro_backend.h | 283 +++++++++++ include/session/pro_backend.hpp | 273 +++++++++- include/session/types.h | 21 + src/CMakeLists.txt | 1 + src/pro_backend.cpp | 854 +++++++++++++++++++++++++++++--- src/types.cpp | 41 ++ tests/CMakeLists.txt | 1 + tests/test_pro_backend.cpp | 454 +++++++++++++++++ 8 files changed, 1842 insertions(+), 86 deletions(-) create mode 100644 include/session/pro_backend.h create mode 100644 tests/test_pro_backend.cpp diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h new file mode 100644 index 00000000..b0cf4776 --- /dev/null +++ b/include/session/pro_backend.h @@ -0,0 +1,283 @@ +#pragma once + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + SESSION_PRO_BACKEND_STATUS_SUCCESS = 0, + SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR = 1, +}; + +typedef struct { + uint32_t status; + /// Array of error messages (NULL if no errors), with errors_count elements + string8* errors; + size_t errors_count; + uint8_t* internal_arena_buf_; /// Internal buffer for all the memory allocations, do not touch +} session_pro_backend_response_header; + +typedef struct { + bool success; /// True if conversion to JSON was successful, false if out-of-memory + string8 json; +} session_pro_backend_to_json; + +typedef struct { + bool success; + char error[256]; + size_t error_count; + bytes64 master_sig; + bytes64 rotating_sig; +} session_pro_backend_master_rotating_signatures; + +typedef struct { + uint8_t version; + bytes32 master_pkey; + bytes32 rotating_pkey; + bytes32 payment_token; + bytes64 master_sig; + bytes64 rotating_sig; +} session_pro_backend_add_pro_payment_request; + +typedef struct { + uint8_t version; + bytes32 master_pkey; + bytes32 rotating_pkey; + uint64_t unix_ts_s; + bytes64 master_sig; + bytes64 rotating_sig; +} session_pro_backend_get_pro_proof_request; + +typedef struct { + session_pro_backend_response_header header; + uint64_t expiry_unix_ts_s; + bytes32 gen_index_hash; + bytes32 rotating_pkey; + bytes64 sig; +} session_pro_backend_add_pro_payment_or_get_pro_proof_response; + +typedef struct { + uint8_t version; + uint32_t ticket; +} session_pro_backend_get_pro_revocations_request; + +typedef struct { + bytes32 gen_index_hash; + uint64_t expiry_unix_ts_s; +} session_pro_backend_pro_revocation_item; + +typedef struct { + session_pro_backend_response_header header; + uint32_t ticket; + /// Array of items, with items_count elements + session_pro_backend_pro_revocation_item* items; + size_t items_count; +} session_pro_backend_get_pro_revocations_response; + +typedef struct { + uint8_t version; + bytes32 master_pkey; + bytes64 master_sig; + uint64_t unix_ts_s; + uint32_t page; +} session_pro_backend_get_pro_payments_request; + +typedef struct { + uint64_t activation_unix_ts_s; + uint64_t archive_unix_ts_s; + uint64_t creation_unix_ts_s; + uint64_t subscription_duration; + bytes32 payment_token_hash; +} session_pro_backend_pro_payment_item; + +typedef struct { + session_pro_backend_response_header header; + /// Array of payment items, with items_count elements + session_pro_backend_pro_payment_item* items; + size_t items_count; + uint32_t pages; + uint32_t payments; +} session_pro_backend_get_pro_payments_response; + +/// API: session_pro_backend/add_pro_payment_request_build_sigs +/// +/// Builds master and rotating signatures for an AddProPaymentRequest. +/// Returns false if the keys (32-byte or 64-byte libsodium format) or payment token hash are +/// incorrectly sized. Using 64-byte libsodium keys is more efficient. +/// +/// Inputs: +/// - `request_version` -- Version of the request. +/// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). +/// - `master_privkey_len` -- Length of master_privkey. +/// - `rotating_privkey` -- Ed25519 rotating private key (32-byte or 64-byte libsodium format). +/// - `rotating_privkey_len` -- Length of rotating_privkey. +/// - `payment_token_hash` -- 32-byte hash of the payment token. +/// - `payment_token_hash_len` -- Length of payment_token_hash. +/// - `unix_ts_s` -- Unix timestamp (seconds) for the request. +/// +/// Outputs: +/// - `success` - True if signatures are built successfully, false otherwise. +/// - `error` - Backing error buffer for the signatures if `success` is false +/// - `errors_count` - length of the error if `success` is false +/// - `master_sig` - Master signature +/// - `rotating_sig` - Rotating signature +LIBSESSION_EXPORT +session_pro_backend_master_rotating_signatures +session_pro_backend_add_pro_payment_request_build_sigs( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + const uint8_t* payment_token_hash, + size_t payment_token_hash_len, + uint64_t unix_ts_s); + +/// API: session_pro_backend/get_pro_proof_request_build_sigs +/// +/// Builds master and rotating signatures for a GetProProofRequest. +/// Returns false if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. +/// Using 64-byte libsodium keys is more efficient. +/// +/// Inputs: +/// - `request_version` -- Version of the request. +/// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). +/// - `master_privkey_len` -- Length of master_privkey. +/// - `rotating_privkey` -- Ed25519 rotating private key (32-byte or 64-byte libsodium format). +/// - `rotating_privkey_len` -- Length of rotating_privkey. +/// - `unix_ts_s` -- Unix timestamp (seconds) for the request. +/// - `out_sigs` -- Pointer to store the master and rotating signatures. +/// +/// Outputs: +/// - `bool` - True if signatures are built successfully, false otherwise. +/// - `error` - Backing error buffer for the signatures if `success` is false +/// - `errors_count` - length of the error if `success` is false +/// - `master_sig` - Master signature +/// - `rotating_sig` - Rotating signature +LIBSESSION_EXPORT +session_pro_backend_master_rotating_signatures +session_pro_backend_get_pro_proof_request_build_sigs( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + uint64_t unix_ts_s); + +/// API: session_pro_backend/add_pro_payment_request_to_json +/// +/// Serializes an `AddProPaymentRequest` to a JSON string. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +/// +/// Inputs: +/// - `request` -- Pointer to the request struct. +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_add_pro_payment_request_to_json( + const session_pro_backend_add_pro_payment_request* request); + +/// API: session_pro_backend/get_pro_proof_request_to_json +/// +/// Serializes a `GetProProofRequest` to a JSON string. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +/// +/// Inputs: +/// - `request` -- Pointer to the request struct. +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_get_pro_proof_request_to_json( + const session_pro_backend_get_pro_proof_request* request); + +/// API: session_pro_backend/get_pro_revocations_request_to_json +/// +/// Serializes a `GetProRevocationsRequest` to a JSON string. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_json( + const session_pro_backend_get_pro_revocations_request* request); + +/// API: session_pro_backend/get_pro_payments_request_to_json +/// +/// Serializes a `GetProPaymentsRequest` to a JSON string. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_get_pro_payments_request_to_json( + const session_pro_backend_get_pro_payments_request* request); + +/// API: session_pro_backend/add_pro_payment_or_get_pro_proof_response_parse +/// +/// Parses a JSON string into an `AddProPaymentOrGetProProofResponse` struct. +/// The caller must free the response using +/// `session_pro_backend_add_pro_payment_or_get_pro_proof_response_free`. +/// +/// Inputs: +/// - `json` -- JSON string to parse. +/// - `json_len` -- Length of the JSON string. +LIBSESSION_EXPORT +session_pro_backend_add_pro_payment_or_get_pro_proof_response +session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + const char* json, + size_t json_len); + +/// API: session_pro_backend/get_pro_revocations_response_parse +/// +/// Parses a JSON string into a GetProRevocationsResponse struct. +/// The caller must free the response using session_pro_backend_get_pro_revocations_response_free. +/// +/// Inputs: +/// - `json` -- JSON string to parse. +/// - `json_len` -- Length of the JSON string. +LIBSESSION_EXPORT +session_pro_backend_get_pro_revocations_response +session_pro_backend_get_pro_revocations_response_parse( + const char* json, + size_t json_len); + +/// API: session_pro_backend/get_pro_payments_response_parse +/// +/// Parses a JSON string into a GetProPaymentsResponse struct. +/// The caller must free the response using session_pro_backend_get_pro_payments_response_free. +/// +/// Inputs: +/// - `json` -- JSON string to parse. +/// - `json_len` -- Length of the JSON string. +LIBSESSION_EXPORT +session_pro_backend_get_pro_payments_response +session_pro_backend_get_pro_payments_response_parse( + const char* json, + size_t json_len); + +/// API: session_pro_backend/to_json_free +/// +/// Frees the JSON +LIBSESSION_EXPORT +void session_pro_backend_to_json_free(session_pro_backend_to_json* to_json); + +/// API: session_pro_backend/add_pro_payment_or_get_pro_proof_response_free +/// +/// Frees the response +LIBSESSION_EXPORT +void session_pro_backend_add_pro_payment_or_get_pro_proof_response_free( + session_pro_backend_add_pro_payment_or_get_pro_proof_response* response); + +/// API: session_pro_backend/get_pro_revocations_response_free +/// +/// Frees the respone +LIBSESSION_EXPORT +void session_pro_backend_get_pro_revocations_response_free( + session_pro_backend_get_pro_revocations_response* response); + +/// API: session_pro_backend/get_pro_payments_response_free +/// +/// Frees the respone +LIBSESSION_EXPORT +void session_pro_backend_get_pro_payments_response_free( + session_pro_backend_get_pro_payments_response* response); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 15c2cbfc..f8ea4b74 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -13,44 +13,275 @@ constexpr array_uc32 PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static_assert(sizeof(PUBKEY) == array_uc32{}.size()); -struct add_payment_request { +struct ResponseHeader { + /// Status code: RESPONSE_STATUS_SUCCESS for success, other values indicate errors + std::uint32_t status; + + /// List of parsing or processing errors. Empty if there are no parsing errors, if there are + /// errors, the parse may be partially complete, always check the errors before proceeding. + std::vector errors; +}; + +struct MasterRotatingSignatures { + array_uc64 master_sig; + array_uc64 rotating_sig; +}; + +/// Register a new Session Pro proof to the backend. The payment is registered under the +/// `master_pkey` and authorises the `rotating_pkey` to use the proof. In practice this means that +/// the caller will receive a Session Pro Proof that can be attached to messages that have to be +/// signed by the `rotating_pkey` for other clients to entitle that message to Pro privileges. +/// +/// The attached signatures must sign over the contents of the request which can be generated by the +/// helper function `build_sigs`. +struct AddProPaymentRequest { + /// Request version. The latest accepted version is 0 std::uint8_t version; + + /// 32-byte Ed25519 Session Pro master public key derived from the Session account seed to + /// register a Session Pro payment under. array_uc32 master_pkey; + + /// 32-byte Ed25519 Session Pro rotating public key to authorise to use the generated Session + /// Pro proof array_uc32 rotating_pkey; + + /// 32-byte payment token hash from a third-party store proving purchase of a subscription array_uc32 payment_token; - array_uc32 master_sig; - array_uc32 rotating_sig; + + /// 64-byte signature proving knowledge of the master key's secret component + array_uc64 master_sig; + + /// 64-byte signature proving knowledge of the rotating key's secret component + array_uc64 rotating_sig; + + /// API: pro/AddProPaymentRequest::to_json + /// + /// Serializes the request to a JSON string. + /// + /// Outputs: + /// - `std::string` - JSON representation of the request. std::string to_json() const; + + /// API: pro/AddProPaymentRequest::build_sigs + /// + /// Builds the master and rotating signatures using the provided private keys and payment token + /// hash. Throws if the keys (32-byte or 64-byte libsodium format) or 32-byte payment token hash + /// are passed with an incorrect size. Using 64-byte libsodium keys is more efficient. + /// + /// Inputs: + /// - `request_version` -- Version of the request to build a hash for + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key + /// - `payment_token_hash` -- 32-byte hash of the payment token. + /// - `unix_ts` -- Unix timestamp (seconds) for the request. + /// + /// Outputs: + /// - `MasterRotatingSignatures` - Struct containing the 64-byte master and rotating signatures. + static MasterRotatingSignatures build_sigs( + std::uint8_t request_version, + std::span master_privkey, + std::span rotating_privkey, + std::span payment_token_hash, + std::chrono::sys_seconds unix_ts); }; -struct get_proof_request { +/// The generated proof from the Session Pro backend that has been parsed from JSON. This structure +/// is the raw parse result that can then be converted into the config::ProProof or equivalent +/// structure. +struct AddProPaymentOrGetProProofResponse : public ResponseHeader { + /// Unix timestamp (seconds) of when the proof expires + std::chrono::sys_seconds expiry_unix_ts; + + /// 32-byte hash of the internal generation index shared across all proofs generated under the + /// same group of payments + array_uc32 gen_index_hash; + + /// 32-byte Ed25519 Session Pro rotating public key authorized to use the proof + array_uc32 rotating_pkey; + + /// 64-byte signature by the Session Pro backend to allow other clients to validate that the + /// proof was issued by an authoritative backend. + array_uc64 sig; + + /// API: pro/AddProPaymentOrGetProProofResponse::parse + /// + /// Parses a JSON string into the response struct. + /// + /// Inputs: + /// - `json` -- JSON string to parse. + /// + /// Outputs: + /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. + bool parse(std::string_view json); +}; + +/// Request a new Session Pro proof from the backend. The specified `master_pkey` must have +/// previously already registered a payment to the backend that is still active and hence entitled +/// to Session Pro features. This endpoint can then be used to pair a new Ed25519 key to be +/// authorised to use a the Session Pro proof. +struct GetProProofRequest { + /// Request version. The latest accepted version is 0 std::uint8_t version; + + /// 32-byte Ed25519 Session Pro master public key to generate a Session Pro proof from. This key + /// must have had a prior, and still active payment registered under it for a new proof to be + /// generated successfully. array_uc32 master_pkey; + + /// 32-byte Ed25519 Session Pro rotating public key authorized to use the generated proof array_uc32 rotating_pkey; - std::chrono::seconds unix_ts_s; - array_uc32 master_sig; - array_uc32 rotating_sig; - std::string to_json() const; -}; -struct master_rotating_sigs { + /// Unix timestamp (seconds) of the request + std::chrono::seconds unix_ts; + + /// 64-byte signature proving knowledge of the master key's secret component array_uc64 master_sig; + + /// 64-byte signature proving knowledge of the rotating key's secret component array_uc64 rotating_sig; + + /// API: pro/MasterRotatingSignatures::build_sigs + /// + /// Builds master and rotating signatures using the provided private keys and timestamp. + /// Throws if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. + /// Using 64-byte libsodium keys is more efficient. + /// + /// Inputs: + /// - `request_version` -- Version of the request to build a hash for + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key + /// - `unix_ts` -- Unix timestamp (seconds) for the request. + /// + /// Outputs: + /// - `MasterRotatingSignatures` - Struct containing the 64-byte master and rotating signatures. + static MasterRotatingSignatures build_sigs( + std::uint8_t request_version, + std::span master_privkey, + std::span rotating_privkey, + std::chrono::seconds unix_ts); + + /// API: pro/GetProProofRequest::to_json + /// + /// Serializes the request to a JSON string. + /// + /// Outputs: + /// - `std::string` - JSON representation of the request. + std::string to_json() const; +}; + +/// Retrieve the current list of revocations for currently active Session Pro proofs (because of +/// refunds for example). The caller should maintain this list until the revocation has expired and +/// periodically retrieve this list from the backend every hour. +struct GetProRevocationsRequest { + /// Request version. The latest accepted version is 0 + std::uint8_t version; + + /// 4-byte monotonic integer for the caller's revocation list iteration. Set to 0 if unknown; + /// otherwise, use the latest known `ticket` from a prior `GetProRevocationResponse` to allow + /// the Session Pro Backend to omit the revocation list if it has not changed. + std::uint32_t ticket; + + /// API: pro/GetProProofRequest::to_json + /// + /// Serializes the request to a JSON string. + /// + /// Outputs: + /// - `std::string` - JSON representation of the request. + std::string to_json() const; }; -struct revocation_item { +struct ProRevocationItem { + /// 32-byte hash of the generation index, identifying a proof array_uc32 gen_index_hash; - std::chrono::seconds expiry_unix_ts; + + /// Unix timestamp (seconds) when the proof expires + std::chrono::sys_seconds expiry_unix_ts; +}; + +struct GetProRevocationsResponse : public ResponseHeader { + /// 4-byte monotonic integer for the latest revocation list iteration. + /// Update the caller's ticket to this value for subsequent requests. + std::uint32_t ticket; + + /// List of revoked Session Pro proofs + std::vector items; + + /// API: pro/GetProRevocationsResponse::parse + /// + /// Parses a JSON string into the response struct. + /// + /// Inputs: + /// - `json` -- JSON string to parse. + /// + /// Outputs: + /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. + bool parse(std::string_view json); +}; + +struct GetProPaymentsRequest { + /// Request version for the API + std::uint8_t version; + + /// 32-byte Ed25519 master public key to retrieve payments for + array_uc32 master_pkey; + + /// 64-byte signature proving knowledge of the master public key's secret component + array_uc64 master_sig; + + /// Unix timestamp (seconds) of the request + std::chrono::sys_seconds unix_ts; + + /// Page number for paginated API requests + std::uint32_t page; + + /// API: pro/GetProProofRequest::to_json + /// + /// Serializes the request to a JSON string. + /// + /// Outputs: + /// - `std::string` - JSON representation of the request. + std::string to_json() const; +}; + +struct ProPaymentItem { + /// Unix timestamp (seconds) when the payment was activated for Session Pro. + /// 0 if not activated (e.g., another active subscription or refunded). + std::chrono::sys_seconds activation_unix_ts; + + /// Unix timestamp (seconds) when the payment was archived (e.g., refunded or revoked). + /// 0 if not archived. + std::chrono::sys_seconds archive_unix_ts; + + /// Unix timestamp (seconds) of payment registration, rounded to the next day + std::chrono::sys_seconds creation_unix_ts; + + /// Subscription duration in seconds + std::chrono::seconds subscription_duration; + + /// 32-byte hash of the payment token + array_uc32 payment_token_hash; }; -master_rotating_sigs build_get_proof_sigs( - const array_uc64& master_privkey, - const array_uc64& rotating_privkey, - std::chrono::seconds unix_ts); -master_rotating_sigs build_add_payment_sigs( - const array_uc64& master_privkey, - const array_uc64& rotating_privkey, - const array_uc32& payment_token_hash, - std::chrono::seconds unix_ts); +struct GetProPaymentsResponse : public ResponseHeader { + /// List of payment items for the master public key + std::vector items; + + /// Total pages available in the paginated API + std::uint32_t pages; + /// Total payments for the user (active, refunded, or non-active) + std::uint32_t payments; + + /// API: pro/GetProPaymentsResponse::parse + /// + /// Parses a JSON string into the response struct. + /// + /// Inputs: + /// - `json` -- JSON string to parse. + /// + /// Outputs: + /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. + bool parse(std::string_view json); +}; } // namespace session::pro_backend diff --git a/include/session/types.h b/include/session/types.h index 47026c2d..241ea5e8 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -13,6 +13,11 @@ struct span_u8 { size_t size; }; +struct string8 { + char* data; + size_t size; +}; + struct bytes32 { uint8_t data[32]; }; @@ -25,6 +30,14 @@ struct bytes64 { uint8_t data[64]; }; +/// Basic bump allocating arena +struct arena_t +{ + uint8_t *data; + size_t size; + size_t max; +}; + /// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this /// function throws a runtime exception. The `data` pointer is span must be freed once the span /// is no longer needed. @@ -53,6 +66,14 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size); /// entire string (as per normal snprintf behaviour). int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, ...); +string8 string8_alloc_or_throw(size_t size); + +string8 string8_copy_or_throw(const void* data, size_t size); + +void* arena_alloc(arena_t* arena, size_t bytes); + +string8 arena_alloc_to_string8(arena_t* arena, void const* data, size_t size); + #ifdef __cplusplus } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a3c0be7..cddcbe04 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -93,6 +93,7 @@ target_link_libraries(crypto util PRIVATE libsodium::sodium-internal + nlohmann_json::nlohmann_json libsession::protos ) diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 4b84843b..f9788685 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -1,40 +1,170 @@ #include #include +#include +#include #include #include #include +#include #include #include #include #include "SessionProtos.pb.h" +namespace { +const nlohmann::json json_parse(std::string_view json, std::vector& errors) { + nlohmann::json result; + try { + result = nlohmann::json::parse(json); + } catch (const std::exception& e) { + errors.push_back(fmt::format("Invalid JSON received, parse failed: {}", e.what())); + } + return result; +} + +template +const T json_require( + const nlohmann::json& j, std::string_view key, std::vector& errors) { + T result = {};; + auto it = j.find(key); + if (it == j.end()) { + errors.push_back(fmt::format("Key '{}' is missing", key)); + } else { + bool success = false; + std::string_view type = {}; + if constexpr (session::config::is_one_of) { + type = "a float"; + success = it->is_number_float(); + } else if constexpr (session::config::is_one_of) { + type = "a number"; + success = it->is_number(); + } else if constexpr (session::config::is_one_of) { + type = "a string"; + success = it->is_string(); + } else if constexpr (session::config::is_one_of) { + type = "an array"; + success = it->is_array(); + } else { + static_assert(session::config::is_one_of); + type = "an object"; + success = it->is_object(); + } + + if (success) + it->get_to(result); + else + errors.push_back(fmt::format("Key value ({}, {}) was not {}", key, it->dump(1), type)); + } + return result; +} + +void parse_json_response_errors(const nlohmann::json& j, std::vector& errors) +{ + const auto& array = json_require(j, "errors", errors); + errors.reserve(errors.size() + array.size()); + for (size_t index = 0; index < array.size(); index++) { + const auto& it = array[index]; + if (it.is_string()) { + errors.push_back(it.get()); + } else { + errors.push_back( + fmt::format( + "Aborting parse, 'result.errors[{}]' was not a string " + "error: '{}'", + index, + it.dump(1))); + break; + } + } +} + +bool json_require_fixed_bytes_from_hex( + const nlohmann::json& j, + std::string_view key, + std::vector& errors, + std::span dest) { + auto hex = json_require(j, key, errors); + if (hex.starts_with("0X") || hex.starts_with("0x")) + hex = hex.substr(2); + + size_t hex_avail = dest.size() * 2; + if (hex.size() != hex_avail) { + errors.push_back( + fmt::format( + "Hex -> bytes failed ({}, {}). {} hex chars capacity (requires {})", + key, + hex, + hex_avail, + hex.size())); + return false; + } + + bool result = oxenc::is_hex(hex); + if (result) + oxenc::from_hex(hex.begin(), hex.end(), dest.begin()); + else + errors.push_back(fmt::format("Key value string was not hex: '{}': '{}'", key, hex)); + return result; +} +}; // namespace + namespace session::pro_backend { -master_rotating_sigs build_get_proof_sigs( - const array_uc64& master_privkey, - const array_uc64& rotating_privkey, - std::chrono::seconds unix_ts) { - // Derive the public keys - array_uc32 master_pubkey; - array_uc32 rotating_pubkey; - crypto_sign_ed25519_sk_to_pk(master_pubkey.data(), master_privkey.data()); - crypto_sign_ed25519_sk_to_pk(rotating_pubkey.data(), rotating_privkey.data()); +std::string AddProPaymentRequest::to_json() const { + nlohmann::json j; + j["version"] = version; + j["master_pkey"] = oxenc::to_hex(master_pkey); + j["rotating_pkey"] = oxenc::to_hex(rotating_pkey); + j["payment_token"] = oxenc::to_hex(payment_token); + j["master_sig"] = oxenc::to_hex(master_sig); + j["rotating_sig"] = oxenc::to_hex(rotating_sig); + std::string result = j.dump(); + return result; +} + +MasterRotatingSignatures AddProPaymentRequest::build_sigs( + std::uint8_t version, + std::span master_privkey, + std::span rotating_privkey, + std::span payment_token_hash, + std::chrono::sys_seconds unix_ts) { + if (payment_token_hash.size() != 32) + throw std::invalid_argument{"Invalid payment_token_hash: expected 32 bytes"}; + + cleared_uc64 master_from_seed; + if (master_privkey.size() == 32) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != 64) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + cleared_uc64 rotating_from_seed; + if (rotating_privkey.size() == 32) { + array_uc32 rotating_pubkey; + crypto_sign_ed25519_seed_keypair( + rotating_pubkey.data(), rotating_from_seed.data(), rotating_privkey.data()); + rotating_privkey = rotating_from_seed; + } else if (rotating_privkey.size() != 64) { + throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; + } // Hash components to 32 bytes - uint8_t version = 0; - uint64_t unix_ts_s = unix_ts.count(); array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state; crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); - crypto_generichash_blake2b_update(&state, master_pubkey.data(), master_pubkey.size()); - crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); crypto_generichash_blake2b_update( - &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + &state, master_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); + crypto_generichash_blake2b_update( + &state, rotating_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); + crypto_generichash_blake2b_update(&state, payment_token_hash.data(), payment_token_hash.size()); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash with both keys - master_rotating_sigs result = {}; + MasterRotatingSignatures result = {}; crypto_sign_ed25519_detached( result.master_sig.data(), nullptr, @@ -50,30 +180,92 @@ master_rotating_sigs build_get_proof_sigs( return result; } -master_rotating_sigs build_add_payment_sigs( - const array_uc64& master_privkey, - const array_uc64& rotating_privkey, - const array_uc32& payment_token_hash, +bool AddProPaymentOrGetProProofResponse::parse(std::string_view json) { + // Parse basics + *this = {}; + nlohmann::json j = json_parse(json, errors); + status = json_require(j, "status", errors); + if (errors.size()) { + status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return errors.empty(); + } + + auto result_obj = json_require(j, "result", errors); + if (errors.size()) + return errors.empty(); + + // Parse errors + if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, errors); + return errors.empty(); + } + + // Parse payload + auto expiry_unix_ts_s = json_require(result_obj, "expiry_unix_ts_s", errors); + expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); + json_require_fixed_bytes_from_hex( + result_obj, "gen_index_hash", errors, gen_index_hash); + json_require_fixed_bytes_from_hex( + result_obj, "rotating_pkey", errors, rotating_pkey); + json_require_fixed_bytes_from_hex(result_obj, "sig", errors, sig); + return errors.empty(); +} + +std::string GetProProofRequest::to_json() const { + nlohmann::json j; + j["version"] = version; + j["master_pkey"] = oxenc::to_hex(master_pkey); + j["rotating_pkey"] = oxenc::to_hex(rotating_pkey); + j["unix_ts_s"] = unix_ts.count(); + j["master_sig"] = oxenc::to_hex(master_sig); + j["rotating_sig"] = oxenc::to_hex(rotating_sig); + std::string result = j.dump(); + return result; +} + +MasterRotatingSignatures GetProProofRequest::build_sigs( + std::uint8_t request_version, + std::span master_privkey, + std::span rotating_privkey, std::chrono::seconds unix_ts) { - // Derive the public keys - array_uc32 master_pubkey; - array_uc32 rotating_pubkey; - crypto_sign_ed25519_sk_to_pk(master_pubkey.data(), master_privkey.data()); - crypto_sign_ed25519_sk_to_pk(rotating_pubkey.data(), rotating_privkey.data()); + + cleared_uc64 master_from_seed; + if (master_privkey.size() == 32) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != 64) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + cleared_uc64 rotating_from_seed; + if (rotating_privkey.size() == 32) { + array_uc32 rotating_pubkey; + crypto_sign_ed25519_seed_keypair( + rotating_pubkey.data(), rotating_from_seed.data(), rotating_privkey.data()); + rotating_privkey = rotating_from_seed; + } else if (rotating_privkey.size() != 64) { + throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; + } // Hash components to 32 bytes uint8_t version = 0; + uint64_t unix_ts_s = unix_ts.count(); array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state; crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); - crypto_generichash_blake2b_update(&state, master_pubkey.data(), master_pubkey.size()); - crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); - crypto_generichash_blake2b_update(&state, payment_token_hash.data(), payment_token_hash.size()); + crypto_generichash_blake2b_update( + &state, master_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); + crypto_generichash_blake2b_update( + &state, rotating_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash with both keys - master_rotating_sigs result = {}; + MasterRotatingSignatures result = {}; crypto_sign_ed25519_detached( result.master_sig.data(), nullptr, @@ -89,43 +281,575 @@ master_rotating_sigs build_add_payment_sigs( return result; } -std::string get_proof_request::to_json() const { - // TODO: Cleanup - std::string result = fmt::format( - R"({{ - "version": {}, - "master_pkey": "{}", - "rotating_pkey": "{}", - "unix_ts_s": {}, - "master_sig": "{}", - "rotating_sig": "{}", -}})", - 0, - oxenc::to_hex(master_pkey), - oxenc::to_hex(rotating_pkey), - unix_ts_s.count(), - oxenc::to_hex(master_sig), - oxenc::to_hex(rotating_sig)); - return result; -} - -std::string add_payment_request::to_json() const { - // TODO: Cleanup - std::string result = fmt::format( - R"({{ - "version": {}, - "master_pkey": "{}", - "rotating_pkey": "{}", - "payment_token": "{}", - "master_sig": "{}", - "rotating_sig": "{}", -}})", - 0, - oxenc::to_hex(master_pkey), - oxenc::to_hex(rotating_pkey), - oxenc::to_hex(payment_token), - oxenc::to_hex(master_sig), - oxenc::to_hex(rotating_sig)); +std::string GetProRevocationsRequest::to_json() const { + nlohmann::json j; + j["version"] = version; + j["ticket"] = ticket; + std::string result = j.dump(); + return result; +} + +bool GetProRevocationsResponse::parse(std::string_view json) { + // Parse basics + *this = {}; + nlohmann::json j = json_parse(json, errors); + status = json_require(j, "status", errors); + if (errors.size()) { + status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return errors.empty(); + } + + auto result_obj = json_require(j, "result", errors); + if (errors.size()) + return errors.empty(); + + // Parse errors + if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, errors); + return errors.empty(); + } + + // Parse payload + ticket = json_require(result_obj, "ticket", errors); + + auto array = json_require(result_obj, "items", errors); + items.reserve(array.size()); + for (size_t index = 0; index < array.size(); index++) { + const auto& it = array[index]; + if (!it.is_object()) { + errors.push_back( + fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", + index, + it.dump(1))); + break; + } + + // Parse revocation item + auto obj = it.get(); + auto expiry_unix_ts = json_require(obj, "expiry_unix_ts_s", errors); + + ProRevocationItem item = {}; + item.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts)); + json_require_fixed_bytes_from_hex( + obj, "gen_index_hash", errors, item.gen_index_hash); + + // Handle parsing result + if (errors.size()) + break; + items.emplace_back(std::move(item)); + } + + return errors.empty(); +} + +std::string GetProPaymentsRequest::to_json() const { + nlohmann::json j; + j["version"] = version; + j["master_pkey"] = oxenc::to_hex(master_pkey); + j["master_sig"] = oxenc::to_hex(master_sig); + j["unix_ts_s"] = unix_ts.time_since_epoch().count(); + j["page"] = page; + std::string result = j.dump(); return result; } + +bool GetProPaymentsResponse::parse(std::string_view json) { + // Parse basics + *this = {}; + nlohmann::json j = json_parse(json, errors); + status = json_require(j, "status", errors); + if (errors.size()) { + status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return errors.empty(); + } + + auto result_obj = json_require(j, "result", errors); + if (errors.size()) + return errors.empty(); + + // Parse errors + if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, errors); + return errors.empty(); + } + + // Parse payload + pages = json_require(result_obj, "pages", errors); + payments = json_require(result_obj, "payments", errors); + + auto array = json_require(result_obj, "items", errors); + items.reserve(array.size()); + for (size_t index = 0; index < array.size(); index++) { + const auto& it = array[index]; + if (!it.is_object()) { + errors.push_back( + fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", + index, + it.dump(1))); + break; + } + + // Parse payment item + auto obj = it.get(); + auto activation_ts = json_require(obj, "activation_unix_ts_s", errors); + auto archive_ts = json_require(obj, "archive_unix_ts_s", errors); + auto creation_ts = json_require(obj, "creation_unix_ts_s", errors); + auto sub_duration_s = json_require(obj, "subscription_duration_s", errors); + + ProPaymentItem item = {}; + item.activation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activation_ts)); + item.archive_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(archive_ts)); + item.creation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(creation_ts)); + item.subscription_duration = std::chrono::seconds(sub_duration_s); + json_require_fixed_bytes_from_hex(obj, "payment_token_hash", errors, item.payment_token_hash); + + // Handle parsing result + if (errors.size()) + break; + + items.emplace_back(std::move(item)); + } + return errors.empty(); +} } // namespace session::pro_backend + +using namespace session::pro_backend; + +/// Define a string8 from a c-string literal. The string should not be modified as it'll live in the +/// data-section of the binary (or be interned, e.t.c) +#define STRING8_LIT(val) {(char*)val, sizeof(val) - 1} + +static string8 C_PARSE_ERROR_OUT_OF_MEMORY = STRING8_LIT("Ran out-of-memory creating C response"); +static string8 C_PARSE_ERROR_INVALID_ARGS = STRING8_LIT("One or more C arguments were NULL"); + +LIBSESSION_C_API session_pro_backend_master_rotating_signatures +session_pro_backend_add_pro_payment_request_build_sigs( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + const uint8_t* payment_token_hash, + size_t payment_token_hash_len, + uint64_t unix_ts_s) { + + // Convert C inputs to C++ types + std::span master_span(master_privkey, master_privkey_len); + std::span rotating_span(rotating_privkey, rotating_privkey_len); + std::span token_span(payment_token_hash, payment_token_hash_len); + std::chrono::sys_seconds ts{std::chrono::seconds{unix_ts_s}}; + + session_pro_backend_master_rotating_signatures result = {}; + try { + auto sigs = AddProPaymentRequest::build_sigs( + request_version, master_span, rotating_span, token_span, ts); + std::memcpy(result.master_sig.data, sigs.master_sig.data(), sigs.master_sig.size()); + std::memcpy(result.rotating_sig.data, sigs.rotating_sig.data(), sigs.rotating_sig.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = std::snprintf( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_master_rotating_signatures +session_pro_backend_get_pro_proof_request_build_sigs( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + uint64_t unix_ts_s) { + + // Convert C inputs to C++ types + std::span master_span(master_privkey, master_privkey_len); + std::span rotating_span(rotating_privkey, rotating_privkey_len); + std::chrono::seconds ts{unix_ts_s}; + + session_pro_backend_master_rotating_signatures result = {}; + try { + auto sigs = GetProProofRequest::build_sigs(request_version, master_span, rotating_span, ts); + std::memcpy(result.master_sig.data, sigs.master_sig.data(), sigs.master_sig.size()); + std::memcpy(result.rotating_sig.data, sigs.rotating_sig.data(), sigs.rotating_sig.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = std::snprintf( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment_request_to_json( + const session_pro_backend_add_pro_payment_request* request) { + session_pro_backend_to_json result = {}; + if (!request) + return result; + + // Construct C++ struct + AddProPaymentRequest cpp = {}; + cpp.version = request->version; + std::memcpy( + cpp.master_pkey.data(), + request->master_pkey.data, + cpp.master_pkey.size()); + std::memcpy( + cpp.rotating_pkey.data(), + request->rotating_pkey.data, + cpp.rotating_pkey.size()); + std::memcpy( + cpp.payment_token.data(), + request->payment_token.data, + cpp.payment_token.size()); + std::memcpy( + cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); + std::memcpy( + cpp.rotating_sig.data(), + request->rotating_sig.data, + cpp.rotating_sig.size()); + + try { + std::string json = cpp.to_json(); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (...) { + } + + return result; +} + +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_request_to_json( + const session_pro_backend_get_pro_proof_request* request) { + session_pro_backend_to_json result = {}; + if (!request) + return result; + + // Construct C++ struct + GetProProofRequest cpp; + cpp.version = request->version; + std::memcpy( + cpp.master_pkey.data(), + request->master_pkey.data, + cpp.master_pkey.size()); + std::memcpy( + cpp.rotating_pkey.data(), + request->rotating_pkey.data, + cpp.rotating_pkey.size()); + cpp.unix_ts = std::chrono::seconds{request->unix_ts_s}; + std::memcpy( + cpp.master_sig.data(), + request->master_sig.data, + cpp.master_sig.size()); + std::memcpy( + cpp.rotating_sig.data(), + request->rotating_sig.data, + cpp.rotating_sig.size()); + + try { + std::string json = cpp.to_json(); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (...) { + } + + return result; +} + +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_json( + const session_pro_backend_get_pro_revocations_request* request) { + session_pro_backend_to_json result = {}; + if (!request) + return result; + + // Construct C++ struct + GetProRevocationsRequest cpp = {}; + cpp.version = request->version; + cpp.ticket = request->ticket; + + try { + std::string json = cpp.to_json(); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (...) { + } + + return result; +} + +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_payments_request_to_json( + const session_pro_backend_get_pro_payments_request* request) { + session_pro_backend_to_json result = {}; + if (!request) + return result; + + // Construct C++ struct + GetProPaymentsRequest cpp = {}; + cpp.version = request->version; + std::memcpy( + cpp.master_pkey.data(), + request->master_pkey.data, + sizeof(request->master_pkey.data)); + std::memcpy( + cpp.master_sig.data(), + request->master_sig.data, + sizeof(request->master_sig.data)); + cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{request->unix_ts_s}}; + cpp.page = request->page; + + try { + std::string json = cpp.to_json(); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (...) { + } + return result; +} + +LIBSESSION_C_API session_pro_backend_add_pro_payment_or_get_pro_proof_response +session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + const char* json, size_t json_len) { + + session_pro_backend_add_pro_payment_or_get_pro_proof_response result = {}; + if (!json) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; + result.header.errors_count = 1; + return result; + } + + // Note, parse is written to not throw so we can safely read without try-catch crap + AddProPaymentOrGetProProofResponse cpp = {}; + cpp.parse({json, json_len}); + + // Calculate how much memory we need and create an arena + arena_t arena = {}; + { + for (const auto& it : cpp.errors) + arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); + + if (arena.max) + arena.data = static_cast(malloc(arena.max)); + + if (arena.max && !arena.data) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_OUT_OF_MEMORY; + result.header.errors_count = 1; + return result; + } + + // Store the pointer to the backing memory. Upon freeing, we release this one pointer + result.header.internal_arena_buf_ = arena.data; + } + + // Copy to C struct, this is guaranteed not to fail because we pre-allocated memory upfront. + // Note that a response error and success case folds into the same code path. A success and error + // response returns the same struct just with different fields populated. + result.header.status = cpp.status; + result.expiry_unix_ts_s = + std::chrono::duration_cast(cpp.expiry_unix_ts.time_since_epoch()) + .count(); + std::memcpy(result.gen_index_hash.data, cpp.gen_index_hash.data(), cpp.gen_index_hash.size()); + std::memcpy(result.rotating_pkey.data, cpp.rotating_pkey.data(), cpp.rotating_pkey.size()); + std::memcpy(result.sig.data, cpp.sig.data(), cpp.sig.size()); + + // Copy errors + result.header.errors_count = cpp.errors.size(); + result.header.errors = static_cast( + arena_alloc(&arena, result.header.errors_count * sizeof(*result.header.errors))); + for (size_t index = 0; index < cpp.errors.size(); index++) { + const std::string& it = cpp.errors[index]; + result.header.errors[index] = arena_alloc_to_string8(&arena, it.data(), it.size()); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_get_pro_revocations_response +session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t json_len) { + session_pro_backend_get_pro_revocations_response result = {}; + if (!json) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; + result.header.errors_count = 1; + return result; + } + + // Note, parse is written to not throw so we can safely read without try-catch crap + GetProRevocationsResponse cpp = {}; + cpp.parse({json, json_len}); + + // Calculate how much memory we need and create an arena + arena_t arena = {}; + { + arena.max += cpp.items.size() * sizeof(*result.items); + static_assert( + sizeof(cpp.items[0]) >= sizeof(*result.items), + "Ensure we allocate enough memory. We might slightly over-allocate but that's not " + "a big deal"); + for (auto it : cpp.errors) + arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); + + if (arena.max) + arena.data = static_cast(malloc(arena.max)); + + if (arena.max && !arena.data) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_OUT_OF_MEMORY; + result.header.errors_count = 1; + return result; + } + + // Store the pointer to the backing memory. Upon freeing, we release this one pointer + result.header.internal_arena_buf_ = arena.data; + } + + // Copy to C struct, this is guaranteed not to fail because we pre-allocated memory upfront. + result.header.status = cpp.status; + result.ticket = cpp.ticket; + + // Copy errors + result.header.errors_count = cpp.errors.size(); + result.header.errors = + (string8*)arena_alloc(&arena, result.header.errors_count * sizeof(*result.header.errors)); + for (size_t index = 0; index < cpp.errors.size(); index++) { + const std::string& it = cpp.errors[index]; + result.header.errors[index] = arena_alloc_to_string8(&arena, it.data(), it.size()); + } + + // Copy items + result.items_count = cpp.items.size(); + result.items = static_cast( + arena_alloc(&arena, result.items_count * sizeof(*result.items))); + + for (size_t index = 0; index < result.items_count; ++index) { + const ProRevocationItem& src = cpp.items[index]; + session_pro_backend_pro_revocation_item& dest = result.items[index]; + std::memcpy(dest.gen_index_hash.data, src.gen_index_hash.data(), src.gen_index_hash.size()); + dest.expiry_unix_ts_s = std::chrono::duration_cast( + src.expiry_unix_ts.time_since_epoch()) + .count(); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_get_pro_payments_response session_pro_backend_get_pro_payments_response_parse( + const char* json, size_t json_len) { + session_pro_backend_get_pro_payments_response result = {}; + if (!json) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; + result.header.errors_count = 1; + return result; + } + + // Note, parse is written to not throw so we can safely read without try-catch crap + GetProPaymentsResponse cpp = {}; + cpp.parse({json, json_len}); + + // Calculate how much memory we need and create an arena + arena_t arena = {}; + { + arena.max += cpp.items.size() * sizeof(*result.items); + static_assert( + sizeof(cpp.items[0]) >= sizeof(*result.items), + "Ensure we allocate enough memory. We might slightly over-allocate but that's not " + "a big deal"); + + for (auto it : cpp.errors) + arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); + + if (arena.max) + arena.data = static_cast(malloc(arena.max)); + + if (arena.max && !arena.data) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_OUT_OF_MEMORY; + result.header.errors_count = 1; + return result; + } + + // Store the pointer to the backing memory. Upon freeing, we release this one pointer + result.header.internal_arena_buf_ = arena.data; + } + + // Copy to C struct, this is guaranteed not to fail because we pre-allocated memory upfront. + result.header.status = cpp.status; + result.pages = cpp.pages; + result.payments = cpp.payments; + result.items_count = cpp.items.size(); + result.items = (session_pro_backend_pro_payment_item*)arena_alloc( + &arena, result.items_count * sizeof(*result.items)); + + for (size_t index = 0; index < result.items_count; ++index) { + const ProPaymentItem& src = cpp.items[index]; + session_pro_backend_pro_payment_item& dest = result.items[index]; + dest.activation_unix_ts_s = std::chrono::duration_cast( + src.activation_unix_ts.time_since_epoch()) + .count(); + dest.archive_unix_ts_s = std::chrono::duration_cast( + src.archive_unix_ts.time_since_epoch()) + .count(); + dest.creation_unix_ts_s = std::chrono::duration_cast( + src.creation_unix_ts.time_since_epoch()) + .count(); + dest.subscription_duration = + std::chrono::duration_cast(src.subscription_duration).count(); + std::memcpy( + dest.payment_token_hash.data, + src.payment_token_hash.data(), + src.payment_token_hash.size()); + } + + // Copy errors + result.header.errors_count = cpp.errors.size(); + result.header.errors = + (string8*)arena_alloc(&arena, result.header.errors_count * sizeof(*result.header.errors)); + for (size_t index = 0; index < cpp.errors.size(); index++) { + const std::string& it = cpp.errors[index]; + result.header.errors[index] = arena_alloc_to_string8(&arena, it.data(), it.size()); + } + + return result; +} + +LIBSESSION_C_API void session_pro_backend_to_json_free(session_pro_backend_to_json* to_json) { + if (to_json) { + free(to_json->json.data); + *to_json = {}; + } +} + +LIBSESSION_C_API void session_pro_backend_add_pro_payment_or_get_pro_proof_response_free( + session_pro_backend_add_pro_payment_or_get_pro_proof_response* response) { + if (response) { + free(response->header.internal_arena_buf_); + *response = {}; + } +} + +LIBSESSION_C_API void session_pro_backend_get_pro_revocations_response_free( + session_pro_backend_get_pro_revocations_response* response) { + if (response) { + free(response->header.internal_arena_buf_); + *response = {}; + } +} + +LIBSESSION_C_API void session_pro_backend_get_pro_payments_response_free( + session_pro_backend_get_pro_payments_response* response) { + if (response) { + free(response->header.internal_arena_buf_); + *response = {}; + } +} diff --git a/src/types.cpp b/src/types.cpp index c8dc8c23..c48f18a3 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -30,3 +30,44 @@ int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, . result = size - 1; return result; } + +string8 string8_alloc_or_throw(size_t size) +{ + string8 result = {}; + result.size = size; + result.data = static_cast(malloc(size + 1 /*null-terminator*/)); + if (!result.data) + throw std::runtime_error( + fmt::format("Failed to allocate {} bytes for string8, out of memory", size + 1)); + result.data[result.size] = 0; + return result; +} + +string8 string8_copy_or_throw(const void *data, size_t size) +{ + string8 result = string8_alloc_or_throw(size); + std::memcpy(result.data, data, result.size); + result.data[result.size] = 0; + return result; +} + +void* arena_alloc(arena_t* arena, size_t bytes) { + void* result = nullptr; + size_t new_size = arena->size + bytes; + if (bytes && new_size <= arena->max) { + result = arena->data + arena->size; + arena->size = new_size; + } + return result; +} + +string8 arena_alloc_to_string8(arena_t* arena, void const* data, size_t size) { + string8 result = {}; + result.data = static_cast(arena_alloc(arena, size + 1)); + if (result.data) { + result.size = size; + std::memcpy(result.data, data, size); + result.data[result.size] = 0; + } + return result; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 66b7e7b2..70b0bbb1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,6 +27,7 @@ set(LIB_SESSION_UTESTS_SOURCES #test_logging.cpp # Handled separately, see below test_multi_encrypt.cpp test_proto.cpp + test_pro_backend.cpp test_random.cpp test_session_encrypt.cpp test_session_protocol.cpp diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp new file mode 100644 index 00000000..f0b3648b --- /dev/null +++ b/tests/test_pro_backend.cpp @@ -0,0 +1,454 @@ +#include +#include +#include + +#include +#include +#include +#include + +using namespace session::pro_backend; + +static bool string8_equals(string8 s8, std::string_view str) { + return s8.size == str.size() && std::memcmp(s8.data, str.data(), s8.size) == 0; +} + +TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { + // Setup: Generate keys and payment token hash + bytes32 master_pubkey = {}; + bytes64 master_privkey = {}; + crypto_sign_ed25519_keypair(master_pubkey.data, master_privkey.data); + + bytes32 rotating_pubkey = {}; + bytes64 rotating_privkey = {}; + crypto_sign_ed25519_keypair(rotating_pubkey.data, rotating_privkey.data); + + bytes32 payment_token_hash; + randombytes_buf(payment_token_hash.data, sizeof(payment_token_hash.data)); + uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp + + SECTION("session_pro_backend_add_pro_payment_request_build_sigs") { + // Valid inputs + session_pro_backend_master_rotating_signatures result = + session_pro_backend_add_pro_payment_request_build_sigs( + /*version*/ 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + payment_token_hash.data, + sizeof(payment_token_hash), + unix_ts_s); + REQUIRE(result.success); + REQUIRE(result.error_count == 0); + + // Verify signatures match C++ implementation + auto cpp = AddProPaymentRequest::build_sigs( + 0, + master_privkey.data, + rotating_privkey.data, + payment_token_hash.data, + std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}); + REQUIRE(std::memcmp( + result.master_sig.data, + cpp.master_sig.data(), + sizeof(result.master_sig.data)) == 0); + REQUIRE(std::memcmp( + result.rotating_sig.data, + cpp.rotating_sig.data(), + sizeof(result.rotating_sig.data)) == 0); + + // Invalid master key size + result = session_pro_backend_add_pro_payment_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey) - 1, + rotating_privkey.data, + sizeof(rotating_privkey), + payment_token_hash.data, + sizeof(payment_token_hash.data), + unix_ts_s); + REQUIRE(!result.success); + REQUIRE(result.error_count > 0); + + // Invalid payment token hash size + result = session_pro_backend_add_pro_payment_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + payment_token_hash.data, + sizeof(payment_token_hash) - 1, + unix_ts_s); + REQUIRE(!result.success); + REQUIRE(result.error_count > 0); + } + + SECTION("session_pro_backend_get_pro_proof_request_build_sigs") { + session_pro_backend_master_rotating_signatures result = {}; + + // Valid inputs + result = session_pro_backend_get_pro_proof_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + unix_ts_s); + REQUIRE(result.success); + REQUIRE(result.error_count == 0); + + // Verify signatures match C++ implementation + auto cpp_sigs = GetProProofRequest::build_sigs( + 0, master_privkey.data, rotating_privkey.data, std::chrono::seconds{unix_ts_s}); + REQUIRE(std::memcmp( + result.master_sig.data, + cpp_sigs.master_sig.data(), + sizeof(result.master_sig)) == 0); + REQUIRE(std::memcmp( + result.rotating_sig.data, + cpp_sigs.rotating_sig.data(), + sizeof(result.rotating_sig)) == 0); + + // Invalid rotating key size + result = session_pro_backend_get_pro_proof_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey) - 1, + unix_ts_s); + REQUIRE(!result.success); + REQUIRE(result.error_count > 0); + } + + SECTION("session_pro_backend_add_pro_payment_request_to_json") { + session_pro_backend_add_pro_payment_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.payment_token = payment_token_hash; + + // Note just write some junk to the request + request.master_sig = master_privkey; + request.rotating_sig = rotating_privkey; + + // Valid request + auto result = session_pro_backend_add_pro_payment_request_to_json(&request); + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + AddProPaymentRequest cpp = {}; + cpp.version = request.version; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); + std::memcpy(cpp.payment_token.data(), payment_token_hash.data, sizeof(payment_token_hash)); + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + + // Free memory + session_pro_backend_to_json_free(&result); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + + // Null request + result = session_pro_backend_add_pro_payment_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + } + + SECTION("session_pro_backend_get_pro_proof_request_to_json") { + session_pro_backend_get_pro_proof_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.unix_ts_s = unix_ts_s; + + // Note just write some junk to the request + request.master_sig = master_privkey; + request.rotating_sig = rotating_privkey; + + // Valid request + auto result = session_pro_backend_get_pro_proof_request_to_json(&request); + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProProofRequest cpp = {}; + cpp.version = request.version; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); + cpp.unix_ts = std::chrono::seconds{unix_ts_s}; + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + + // Free memory + session_pro_backend_to_json_free(&result); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + + // Null request + result = session_pro_backend_get_pro_proof_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + } + + SECTION("session_pro_backend_get_pro_revocations_request_to_json") { + session_pro_backend_get_pro_revocations_request request = {}; + request.version = 0; + request.ticket = 123; + + // Valid request + auto result = session_pro_backend_get_pro_revocations_request_to_json(&request); + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProRevocationsRequest cpp = {}; + cpp.version = request.version; + cpp.ticket = request.ticket; + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + + // Free memory + session_pro_backend_to_json_free(&result); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + + // Null request + result = session_pro_backend_get_pro_revocations_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + } + + SECTION("session_pro_backend_get_pro_payments_request_to_json") { + session_pro_backend_get_pro_payments_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.master_sig = master_privkey; // Write some junk + request.unix_ts_s = unix_ts_s; + request.page = 1; + + // Valid request + auto result = session_pro_backend_get_pro_payments_request_to_json(&request); + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProPaymentsRequest cpp = {}; + cpp.version = 0; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}; + cpp.page = request.page; + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + + // Free memory + session_pro_backend_to_json_free(&result); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + + // Null request + result = session_pro_backend_get_pro_payments_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + } + + SECTION("session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse") { + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = { + {"expiry_unix_ts_s", unix_ts_s}, + {"gen_index_hash", oxenc::to_hex(payment_token_hash.data)}, + {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, + {"sig", oxenc::to_hex(master_privkey.data)} + }; + std::string json = j.dump(); + + // Valid JSON + auto result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(json.data(), json.size()); + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp(result.gen_index_hash.data, payment_token_hash.data, sizeof(payment_token_hash)) == 0); + REQUIRE(std::memcmp(result.rotating_pkey.data, rotating_pubkey.data, sizeof(rotating_pubkey)) == 0); + REQUIRE(std::memcmp(result.sig.data, master_privkey.data, sizeof(master_privkey)) == 0); + + // Free memory + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.header.errors_count == 0); + + // Invalid JSON + json = "{invalid}"; + result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(json.data(), json.size()); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + + // Free memory + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + + // Null JSON + result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(nullptr, 0); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 1); + REQUIRE(result.header.errors != nullptr); + + // No need to free, as errors point to static memory + } + + SECTION("session_pro_backend_get_pro_revocations_response_parse") { + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = {{"ticket", 123}, {"items", nlohmann::json::array()}}; + + auto obj = nlohmann::json::object(); + obj["expiry_unix_ts_s"] = unix_ts_s; + obj["gen_index_hash"] = oxenc::to_hex(payment_token_hash.data); + j["result"]["items"].push_back(obj); + + std::string json = j.dump(); + + // Valid JSON + auto result = session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.ticket == 123); + REQUIRE(result.items_count == 1); + REQUIRE(result.items != nullptr); + REQUIRE(result.items[0].expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp( + result.items[0].gen_index_hash.data, + payment_token_hash.data, + sizeof(payment_token_hash)) == 0); + + // Free memory + session_pro_backend_get_pro_revocations_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + REQUIRE(result.items == nullptr); + REQUIRE(result.items_count == 0); + + // Invalid JSON + json = "{invalid}"; + result = session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + + // Free memory + session_pro_backend_get_pro_revocations_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + + // Null JSON + result = session_pro_backend_get_pro_revocations_response_parse(nullptr, 0); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 1); + REQUIRE(result.header.errors != nullptr); + } + + SECTION("session_pro_backend_get_pro_payments_response_parse") { + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = { + {"pages", 2}, + {"payments", 10}, + {"items", nlohmann::json::array({ + { + {"activation_unix_ts_s", unix_ts_s}, + {"archive_unix_ts_s", unix_ts_s + 3600}, + {"creation_unix_ts_s", unix_ts_s - 3600}, + {"subscription_duration_s", 86400}, + {"payment_token_hash", oxenc::to_hex(payment_token_hash.data)} + } + })} + }; + std::string json = j.dump(); + + // Valid JSON + auto result = session_pro_backend_get_pro_payments_response_parse(json.data(), json.size()); + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.pages == 2); + REQUIRE(result.payments == 10); + REQUIRE(result.items_count == 1); + REQUIRE(result.items != nullptr); + REQUIRE(result.items[0].activation_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].archive_unix_ts_s == unix_ts_s + 3600); + REQUIRE(result.items[0].creation_unix_ts_s == unix_ts_s - 3600); + REQUIRE(result.items[0].subscription_duration == 86400); + REQUIRE(std::memcmp( + result.items[0].payment_token_hash.data, + payment_token_hash.data, + sizeof(payment_token_hash)) == 0); + + // Free memory + session_pro_backend_get_pro_payments_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + REQUIRE(result.items == nullptr); + REQUIRE(result.items_count == 0); + + // Invalid JSON + json = "{invalid}"; + result = session_pro_backend_get_pro_payments_response_parse(json.data(), json.size()); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + + // Free memory + session_pro_backend_get_pro_payments_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + + // Null JSON + result = session_pro_backend_get_pro_payments_response_parse(nullptr, 0); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 1); + REQUIRE(result.header.errors != nullptr); + } + + SECTION("Memory management edge cases") { + // Test freeing null/empty structs + session_pro_backend_to_json to_json = {}; + session_pro_backend_to_json_free(&to_json); + REQUIRE(to_json.json.data == nullptr); + REQUIRE(to_json.json.size == 0); + + session_pro_backend_add_pro_payment_or_get_pro_proof_response proof_response = {}; + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&proof_response); + REQUIRE(proof_response.header.internal_arena_buf_ == nullptr); + + session_pro_backend_get_pro_revocations_response rev_response = {}; + session_pro_backend_get_pro_revocations_response_free(&rev_response); + REQUIRE(rev_response.header.internal_arena_buf_ == nullptr); + + session_pro_backend_get_pro_payments_response pay_response = {}; + session_pro_backend_get_pro_payments_response_free(&pay_response); + REQUIRE(pay_response.header.internal_arena_buf_ == nullptr); + } +} From eaa40fd68fafac1169ee2c5885d4786750390628 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 25 Aug 2025 16:06:50 +1000 Subject: [PATCH 067/171] Document the new c helper functions --- include/session/types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/session/types.h b/include/session/types.h index 241ea5e8..f5e1f91d 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -66,12 +66,16 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size); /// entire string (as per normal snprintf behaviour). int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, ...); +/// Allocate the string with the specific size. Throws on allocation failure. string8 string8_alloc_or_throw(size_t size); +/// Create a string by copying the given pointer and size. Throws on allocation failure string8 string8_copy_or_throw(const void* data, size_t size); +/// Allocate memory from the basic bump allocating arena. Returns a null pointer on failure. void* arena_alloc(arena_t* arena, size_t bytes); +/// Create a string and allocate a copy of the data at pointer and size string8 arena_alloc_to_string8(arena_t* arena, void const* data, size_t size); #ifdef __cplusplus From c04ebf34994471f83d668865e4bdfae9b39faf4e Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 25 Aug 2025 16:46:32 +1000 Subject: [PATCH 068/171] Document the dev flow for pro backend --- include/session/pro_backend.hpp | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index f8ea4b74..1fb65301 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -4,6 +4,43 @@ #include #include +/// Helper functions to construct payloads to communicate with the Session Pro Backend. The data +/// structures here are largely bindings to the endpoints exposed on the Session Pro Backend: +/// +/// github.com/Doy-lee/session-pro-backend/blob/2afe310adad52f211e3b2cfcbdfc9eda6ff1778e/server.py#L24 +/// +/// The high level summary of the functionality in this file. Clients can: +/// +/// 1. Build a request with `AddProPaymentRequest::to_json` from a Session Pro payment and submit it +/// to the backend to register the specified Ed25519 keys for Session Pro. +/// +/// Server responds JSON to be parsed with `GetProPaymentsRequest::parse`. Clients should +/// validate the response and update their `UserProfile` by constructing a `ProConfig` with the +/// proof from the response filling in the remaining fields appropriately in `ProConfig` +/// +/// The server will only respond successfully if it can also independently verify the purchase +/// otherwise an error is returned and can be read from the `ResponseHeader` after parsing the +/// raw response. +/// +/// 2. Attach the proof to their messages. Libsession has helper functions to embed the proof into +/// their messages via the helper functions in the Session Protocol header file. +/// +/// 3. Periodically poll the global revocation list which overrides the validity of current +/// circulating proofs. This is done by constructing the request via +/// `GetProRevocationsRequest::to_json` and sending it to the backend. +/// +/// Server responds JSON to be parsed with `GetProRevocationResponse::parse` which contains the +/// list that clients should cache. Any incoming messages with a Pro proof that is in the list of +/// revoked proofs will not be entitled to Pro features. +/// +/// 4. Query the list of historical payments that the master Ed25519 key has registered by building +/// a `GetProPaymentsRequest::to_json` query and submitting it. +/// +/// Server responds JSON to be parsed with `GetProPaymentsResponse::parse` which they can use to +/// populate their client's payment history. +/// +/// See the unit tests for examples of the API. + namespace session::pro_backend { /// TODO: Assign the Session Pro backend public key for verifying proofs to allow users of the From e7d239b5bb8c2be8fbd50b6001cbb1e6284ea25a Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 10:20:29 +1000 Subject: [PATCH 069/171] Test pro backend against local dev server --- include/session/config/base.hpp | 4 +- include/session/config/pro.h | 2 +- include/session/config/pro.hpp | 2 - include/session/pro_backend.h | 35 +++- include/session/pro_backend.hpp | 25 +++ include/session/session_protocol.h | 8 +- include/session/types.hpp | 4 + src/config/pro.cpp | 14 +- src/config/user_profile.cpp | 16 +- src/pro_backend.cpp | 160 ++++++++++++++---- src/session_protocol.cpp | 25 +-- tests/CMakeLists.txt | 8 + tests/test_config_pro.cpp | 14 +- tests/test_pro_backend.cpp | 252 +++++++++++++++++++++++++++++ 14 files changed, 491 insertions(+), 78 deletions(-) diff --git a/include/session/config/base.hpp b/include/session/config/base.hpp index 64bb7b06..fd906911 100644 --- a/include/session/config/base.hpp +++ b/include/session/config/base.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -29,9 +30,6 @@ class bt_dict_consumer; namespace session::config { -template -static constexpr bool is_one_of = (std::is_same_v || ...); - /// True for a dict_value direct subtype, but not scalar sub-subtypes. template static constexpr bool is_dict_subtype = is_one_of; diff --git a/include/session/config/pro.h b/include/session/config/pro.h index df1b2a6b..8a65e0f8 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -12,7 +12,7 @@ extern "C" { #include "session/session_protocol.h" typedef struct pro_config { - uint8_t rotating_privkey[64]; + bytes64 rotating_privkey; pro_proof proof; } pro_pro_config; diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 7c5380f2..62715a6b 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -6,8 +6,6 @@ namespace session::config { -enum ProProofVersion { ProProofVersion_v0 }; - /// keys used currently or in the past (so that we don't reuse): /// /// p + pro data diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index b0cf4776..a1aa5b8a 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -36,6 +36,13 @@ typedef struct { bytes64 rotating_sig; } session_pro_backend_master_rotating_signatures; +typedef struct { + bool success; + char error[256]; + size_t error_count; + bytes64 sig; +} session_pro_backend_signature; + typedef struct { uint8_t version; bytes32 master_pkey; @@ -56,6 +63,7 @@ typedef struct { typedef struct { session_pro_backend_response_header header; + uint8_t version; uint64_t expiry_unix_ts_s; bytes32 gen_index_hash; bytes32 rotating_pkey; @@ -152,7 +160,6 @@ session_pro_backend_add_pro_payment_request_build_sigs( /// - `rotating_privkey` -- Ed25519 rotating private key (32-byte or 64-byte libsodium format). /// - `rotating_privkey_len` -- Length of rotating_privkey. /// - `unix_ts_s` -- Unix timestamp (seconds) for the request. -/// - `out_sigs` -- Pointer to store the master and rotating signatures. /// /// Outputs: /// - `bool` - True if signatures are built successfully, false otherwise. @@ -170,6 +177,32 @@ session_pro_backend_get_pro_proof_request_build_sigs( size_t rotating_privkey_len, uint64_t unix_ts_s); +/// API: session_pro_backend/get_pro_payments_request_build_sig +/// +/// Builds the signature for GetProPaymentsRequest +/// Returns false if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. +/// Using 64-byte libsodium keys is more efficient. +/// +/// Inputs: +/// - `request_version` -- Version of the request. +/// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). +/// - `master_privkey_len` -- Length of master_privkey. +/// - `unix_ts_s` -- Unix timestamp (seconds) for the request. +/// - `page` -- The page in the paginated list of historical payments to request +/// +/// Outputs: +/// - `bool` - True if signature was built successfully, false otherwise. +/// - `error` - Backing error buffer for the signatures if `success` is false +/// - `errors_count` - length of the error if `success` is false +/// - `sig` - 64 byte signature +LIBSESSION_EXPORT +session_pro_backend_signature session_pro_backend_get_pro_payments_request_build_sig( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_s, + uint32_t page); + /// API: session_pro_backend/add_pro_payment_request_to_json /// /// Serializes an `AddProPaymentRequest` to a JSON string. diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 1fb65301..3856e52b 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -127,6 +127,9 @@ struct AddProPaymentRequest { /// is the raw parse result that can then be converted into the config::ProProof or equivalent /// structure. struct AddProPaymentOrGetProProofResponse : public ResponseHeader { + /// Version of the proof + uint8_t version; + /// Unix timestamp (seconds) of when the proof expires std::chrono::sys_seconds expiry_unix_ts; @@ -272,6 +275,26 @@ struct GetProPaymentsRequest { /// Page number for paginated API requests std::uint32_t page; + /// API: pro/AddProPaymentRequest::build_sigs + /// + /// Builds the master and rotating signatures using the provided private keys and payment token + /// hash. Throws if the keys (32-byte or 64-byte libsodium format) or 32-byte payment token hash + /// are passed with an incorrect size. Using 64-byte libsodium keys is more efficient. + /// + /// Inputs: + /// - `request_version` -- Version of the request to build a hash for + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `unix_ts` -- Unix timestamp (seconds) for the request. + /// - `page` -- The page in the paginated list of historical payments to request + /// + /// Outputs: + /// - `array_uc64` - the 64-byte signature + static array_uc64 build_sig( + uint8_t version, + std::span master_privkey, + std::chrono::sys_seconds unix_ts, + uint32_t page); + /// API: pro/GetProProofRequest::to_json /// /// Serializes the request to a JSON string. @@ -321,4 +344,6 @@ struct GetProPaymentsResponse : public ResponseHeader { /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. bool parse(std::string_view json); }; + +void make_blake2b32_hasher(struct crypto_generichash_blake2b_state *hasher); } // namespace session::pro_backend diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index c929b023..b4bf8f9d 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -44,10 +44,10 @@ typedef struct pro_signed_message { typedef struct pro_proof { uint8_t version; - uint8_t gen_index_hash[32]; - uint8_t rotating_pubkey[32]; - uint64_t expiry_unix_ts; - uint8_t sig[64]; + bytes32 gen_index_hash; + bytes32 rotating_pubkey; + uint64_t expiry_unix_ts_s; + bytes64 sig; } pro_proof; // Bit flags for features that are not currently able to be determined by the state stored in diff --git a/include/session/types.hpp b/include/session/types.hpp index 1bc2ca00..b66f39ba 100644 --- a/include/session/types.hpp +++ b/include/session/types.hpp @@ -4,6 +4,10 @@ #include namespace session { + +template +static constexpr bool is_one_of = (std::is_same_v || ...); + using array_uc32 = std::array; using array_uc33 = std::array; using array_uc64 = std::array; diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 0d1ac56b..76fd560f 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -89,19 +89,19 @@ LIBSESSION_C_API bool pro_config_verify_signature( session::config::ProConfig config = {}; std::memcpy( - config.rotating_privkey.data(), pro->rotating_privkey, sizeof pro->rotating_privkey); + config.rotating_privkey.data(), pro->rotating_privkey.data, sizeof pro->rotating_privkey.data); config.proof.version = pro->proof.version; std::memcpy( config.proof.gen_index_hash.data(), - pro->proof.gen_index_hash, - sizeof pro->proof.gen_index_hash); + pro->proof.gen_index_hash.data, + sizeof pro->proof.gen_index_hash.data); std::memcpy( config.proof.rotating_pubkey.data(), - pro->proof.rotating_pubkey, - sizeof pro->proof.rotating_pubkey); + pro->proof.rotating_pubkey.data, + sizeof pro->proof.rotating_pubkey.data); config.proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts)); - std::memcpy(config.proof.sig.data(), pro->proof.sig, sizeof pro->proof.sig); + std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts_s)); + std::memcpy(config.proof.sig.data(), pro->proof.sig.data, sizeof pro->proof.sig.data); session::array_uc32 verify_pubkey_cpp; std::memcpy(verify_pubkey_cpp.data(), verify_pubkey, verify_pubkey_len); diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index aef24d9b..3ba12181 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -285,15 +285,15 @@ LIBSESSION_C_API bool user_profile_get_pro_config(const config_object* conf, pro static_assert(sizeof pro->proof.sig == sizeof(val->proof.sig)); pro->proof.version = val->proof.version; std::memcpy( - pro->proof.gen_index_hash, + pro->proof.gen_index_hash.data, val->proof.gen_index_hash.data(), val->proof.gen_index_hash.size()); std::memcpy( - pro->proof.rotating_pubkey, + pro->proof.rotating_pubkey.data, val->proof.rotating_pubkey.data(), val->proof.rotating_pubkey.size()); - pro->proof.expiry_unix_ts = val->proof.expiry_unix_ts.time_since_epoch().count(); - std::memcpy(pro->proof.sig, val->proof.sig.data(), val->proof.sig.size()); + pro->proof.expiry_unix_ts_s = val->proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro->proof.sig.data, val->proof.sig.data(), val->proof.sig.size()); return true; } return false; @@ -304,15 +304,15 @@ LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro val.proof.version = pro->proof.version; std::memcpy( val.proof.gen_index_hash.data(), - pro->proof.gen_index_hash, + pro->proof.gen_index_hash.data, val.proof.gen_index_hash.size()); std::memcpy( val.proof.rotating_pubkey.data(), - pro->proof.rotating_pubkey, + pro->proof.rotating_pubkey.data, val.proof.rotating_pubkey.size()); val.proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts)); - std::memcpy(val.proof.sig.data(), pro->proof.sig, val.proof.sig.size()); + std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts_s)); + std::memcpy(val.proof.sig.data(), pro->proof.sig.data, val.proof.sig.size()); unbox(conf)->set_pro_config(val); } } // extern "C" diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index f9788685..4957c30a 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -13,6 +14,12 @@ #include "SessionProtos.pb.h" namespace { + +// NOTE: Personalization data must match +// https://github.com/Doy-lee/session-pro-backend/blob/2afe310adad52f211e3b2cfcbdfc9eda6ff1778e/backend.py#L156 +constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALIZATION = "SeshProBackend__"; +static_assert(PRO_BACKEND_BLAKE2B_PERSONALIZATION.size() == crypto_generichash_blake2b_PERSONALBYTES); + const nlohmann::json json_parse(std::string_view json, std::vector& errors) { nlohmann::json result; try { @@ -33,20 +40,20 @@ const T json_require( } else { bool success = false; std::string_view type = {}; - if constexpr (session::config::is_one_of) { + if constexpr (session::is_one_of) { type = "a float"; success = it->is_number_float(); - } else if constexpr (session::config::is_one_of) { + } else if constexpr (session::is_one_of) { type = "a number"; success = it->is_number(); - } else if constexpr (session::config::is_one_of) { + } else if constexpr (session::is_one_of) { type = "a string"; success = it->is_string(); - } else if constexpr (session::config::is_one_of) { + } else if constexpr (session::is_one_of) { type = "an array"; success = it->is_array(); } else { - static_assert(session::config::is_one_of); + static_assert(session::is_one_of); type = "an object"; success = it->is_object(); } @@ -132,34 +139,35 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( throw std::invalid_argument{"Invalid payment_token_hash: expected 32 bytes"}; cleared_uc64 master_from_seed; - if (master_privkey.size() == 32) { + if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; crypto_sign_ed25519_seed_keypair( master_pubkey.data(), master_from_seed.data(), master_privkey.data()); master_privkey = master_from_seed; - } else if (master_privkey.size() != 64) { + } else if (master_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; } cleared_uc64 rotating_from_seed; - if (rotating_privkey.size() == 32) { + if (rotating_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 rotating_pubkey; crypto_sign_ed25519_seed_keypair( rotating_pubkey.data(), rotating_from_seed.data(), rotating_privkey.data()); rotating_privkey = rotating_from_seed; - } else if (rotating_privkey.size() != 64) { + } else if (rotating_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; } - // Hash components to 32 bytes + // Hash components to 32 bytes, must match: + // https://github.com/Doy-lee/session-pro-backend/blob/5b66b1a4a64dc8da0225507019cbe21d7642fa78/backend.py#L171 array_uc32 hash_to_sign = {}; - crypto_generichash_blake2b_state state; - crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); + crypto_generichash_blake2b_state state = {}; + make_blake2b32_hasher(&state); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( - &state, master_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); + &state, master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( - &state, rotating_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); + &state, rotating_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update(&state, payment_token_hash.data(), payment_token_hash.size()); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); @@ -190,17 +198,18 @@ bool AddProPaymentOrGetProProofResponse::parse(std::string_view json) { return errors.empty(); } - auto result_obj = json_require(j, "result", errors); - if (errors.size()) - return errors.empty(); - // Parse errors if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { parse_json_response_errors(j, errors); - return errors.empty(); + return false; } + auto result_obj = json_require(j, "result", errors); + if (errors.size()) + return errors.empty(); + // Parse payload + version = json_require(result_obj, "version", errors); auto expiry_unix_ts_s = json_require(result_obj, "expiry_unix_ts_s", errors); expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); json_require_fixed_bytes_from_hex( @@ -249,12 +258,13 @@ MasterRotatingSignatures GetProProofRequest::build_sigs( throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; } - // Hash components to 32 bytes + // Hash components to 32 bytes, must match: + // https://github.com/Doy-lee/session-pro-backend/blob/5b66b1a4a64dc8da0225507019cbe21d7642fa78/backend.py#L631 uint8_t version = 0; uint64_t unix_ts_s = unix_ts.count(); array_uc32 hash_to_sign = {}; - crypto_generichash_blake2b_state state; - crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, hash_to_sign.max_size()); + crypto_generichash_blake2b_state state = {}; + make_blake2b32_hasher(&state); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, master_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); @@ -299,16 +309,16 @@ bool GetProRevocationsResponse::parse(std::string_view json) { return errors.empty(); } - auto result_obj = json_require(j, "result", errors); - if (errors.size()) - return errors.empty(); - // Parse errors if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { parse_json_response_errors(j, errors); - return errors.empty(); + return false; } + auto result_obj = json_require(j, "result", errors); + if (errors.size()) + return errors.empty(); + // Parse payload ticket = json_require(result_obj, "ticket", errors); @@ -354,6 +364,47 @@ std::string GetProPaymentsRequest::to_json() const { return result; } +array_uc64 GetProPaymentsRequest::build_sig( + uint8_t version, + std::span master_privkey, + std::chrono::sys_seconds unix_ts, + uint32_t page) { + cleared_uc64 master_from_seed; + if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + // Hash components to 32 bytes, must match: + // https://github.com/Doy-lee/session-pro-backend/blob/635b14fc93302658de6c07c017f705673fc7c57f/server.py#L395 + array_uc32 hash_to_sign = {}; + crypto_generichash_blake2b_state state = {}; + uint64_t unix_ts_s = unix_ts.time_since_epoch().count(); + make_blake2b32_hasher(&state); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update( + &state, master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&page), sizeof(page)); + crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); + + // Sign the hash + array_uc64 result = {}; + crypto_sign_ed25519_detached( + result.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + master_privkey.data()); + return result; +} + bool GetProPaymentsResponse::parse(std::string_view json) { // Parse basics *this = {}; @@ -364,16 +415,16 @@ bool GetProPaymentsResponse::parse(std::string_view json) { return errors.empty(); } - auto result_obj = json_require(j, "result", errors); - if (errors.size()) - return errors.empty(); - // Parse errors if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { parse_json_response_errors(j, errors); - return errors.empty(); + return false; } + auto result_obj = json_require(j, "result", errors); + if (errors.size()) + return errors.empty(); + // Parse payload pages = json_require(result_obj, "pages", errors); payments = json_require(result_obj, "payments", errors); @@ -413,6 +464,17 @@ bool GetProPaymentsResponse::parse(std::string_view json) { } return errors.empty(); } + +void make_blake2b32_hasher(crypto_generichash_blake2b_state *hasher) +{ + crypto_generichash_blake2b_init_salt_personal( + hasher, + /*key*/ nullptr, + 0, + 32, + /*salt*/ nullptr, + reinterpret_cast(PRO_BACKEND_BLAKE2B_PERSONALIZATION.data())); +} } // namespace session::pro_backend using namespace session::pro_backend; @@ -450,7 +512,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); - result.error_count = std::snprintf( + result.error_count = snprintf_bytes_written_clamped( result.error, sizeof(result.error_count), "%.*s", @@ -482,7 +544,36 @@ session_pro_backend_get_pro_proof_request_build_sigs( result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); - result.error_count = std::snprintf( + result.error_count = snprintf_bytes_written_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_signature +session_pro_backend_get_pro_payments_request_build_sig( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_s, + uint32_t page) +{ + // Convert C inputs to C++ types + std::span master_span{master_privkey, master_privkey_len}; + std::chrono::sys_seconds ts{std::chrono::seconds(unix_ts_s)}; + + session_pro_backend_signature result = {}; + try { + auto sig = GetProPaymentsRequest::build_sig(request_version, master_span, ts, page); + std::memcpy(result.sig.data, sig.data(), sig.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_bytes_written_clamped( result.error, sizeof(result.error_count), "%.*s", @@ -657,6 +748,7 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( // Note that a response error and success case folds into the same code path. A success and error // response returns the same struct just with different fields populated. result.header.status = cpp.status; + result.version = cpp.version; result.expiry_unix_ts_s = std::chrono::duration_cast(cpp.expiry_unix_ts.time_since_epoch()) .count(); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 4153187d..52f3d257 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -667,9 +667,9 @@ LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { if (proof) { session::array_uc32 hash = proof_hash_internal( proof->version, - proof->gen_index_hash, - proof->rotating_pubkey, - proof->expiry_unix_ts); + proof->gen_index_hash.data, + proof->rotating_pubkey.data, + proof->expiry_unix_ts_s); std::memcpy(result.data, hash.data(), hash.size()); } return result; @@ -681,8 +681,11 @@ LIBSESSION_C_API bool pro_proof_verify_signature( return false; auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); session::array_uc32 hash = proof_hash_internal( - proof->version, proof->gen_index_hash, proof->rotating_pubkey, proof->expiry_unix_ts); - bool result = proof_verify_signature_internal(hash, proof->sig, verify_pubkey_span); + proof->version, + proof->gen_index_hash.data, + proof->rotating_pubkey.data, + proof->expiry_unix_ts_s); + bool result = proof_verify_signature_internal(hash, proof->sig.data, verify_pubkey_span); return result; } @@ -694,12 +697,12 @@ LIBSESSION_C_API bool pro_proof_verify_message( size_t msg_len) { std::span sig_span = {sig, sig_len}; std::span msg_span = {msg, msg_len}; - bool result = proof_verify_message_internal(proof->rotating_pubkey, sig_span, msg_span); + bool result = proof_verify_message_internal(proof->rotating_pubkey.data, sig_span, msg_span); return result; } LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) { - bool result = proof && proof_is_active_internal(proof->expiry_unix_ts, unix_ts_s); + bool result = proof && proof_is_active_internal(proof->expiry_unix_ts_s, unix_ts_s); return result; } @@ -969,19 +972,19 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const DecryptedPro& pro = *result_cpp.pro; result.pro_status = static_cast(pro.status); result.pro_proof.version = pro.proof.version; - result.pro_proof.expiry_unix_ts = + result.pro_proof.expiry_unix_ts_s = static_cast(pro.proof.expiry_unix_ts.time_since_epoch().count()); result.pro_features = pro.features; std::memcpy( - result.pro_proof.gen_index_hash, + result.pro_proof.gen_index_hash.data, pro.proof.gen_index_hash.data(), sizeof(result.pro_proof.gen_index_hash)); std::memcpy( - result.pro_proof.rotating_pubkey, + result.pro_proof.rotating_pubkey.data, pro.proof.rotating_pubkey.data(), sizeof(result.pro_proof.rotating_pubkey)); - std::memcpy(result.pro_proof.sig, pro.proof.sig.data(), sizeof(pro.proof.sig)); + std::memcpy(result.pro_proof.sig.data, pro.proof.sig.data(), sizeof(pro.proof.sig)); } // Since we support multiple keys, if some of the keys failed but one of them succeeded, we will diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 70b0bbb1..ca1157af 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -60,6 +60,14 @@ target_link_libraries(testAll PRIVATE test_libs Catch2::Catch2) +option(TEST_PRO_BACKEND_WITH_DEV_SERVER "Run the Pro Backend tests relying on a development server at 127.0.0.1:5000 and CURL" OFF) +if (TEST_PRO_BACKEND_WITH_DEV_SERVER) + find_package(CURL REQUIRED) + target_link_libraries(testAll PRIVATE CURL::libcurl) + target_compile_definitions(testAll PRIVATE TEST_PRO_BACKEND_WITH_DEV_SERVER) +endif() + + # This one is compiled to a separate binary because it manipulates the logging level and sinks, and # thus breaks logging in any tests that would run after it if bundled into the main testAll: add_executable(testLogging test_logging.cpp) diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index eb98ece2..21c04bf2 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -32,11 +32,11 @@ TEST_CASE("Pro", "[config][pro]") { pro_cpp.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); // C - std::memcpy(pro.rotating_privkey, rotating_sk.data(), rotating_sk.size()); + std::memcpy(pro.rotating_privkey.data, rotating_sk.data(), rotating_sk.size()); pro.proof.version = pro_cpp.proof.version; - std::memcpy(pro.proof.rotating_pubkey, rotating_pk.data(), rotating_pk.size()); - pro.proof.expiry_unix_ts = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); - std::memcpy(pro.proof.gen_index_hash, gen_index_hash.data(), gen_index_hash.size()); + std::memcpy(pro.proof.rotating_pubkey.data, rotating_pk.data(), rotating_pk.size()); + pro.proof.expiry_unix_ts_s = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro.proof.gen_index_hash.data, gen_index_hash.data(), gen_index_hash.size()); } // Generate and write the hashes that are signed by the faux pro backend into the proof @@ -60,7 +60,7 @@ TEST_CASE("Pro", "[config][pro]") { CHECK(sig_result == 0); sig_result = crypto_sign_ed25519_detached( - pro.proof.sig, + pro.proof.sig.data, nullptr, hash_to_sign.data, sizeof(hash_to_sign.data), @@ -82,8 +82,8 @@ TEST_CASE("Pro", "[config][pro]") { CHECK(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts)); CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1s)); - CHECK(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts)); - CHECK_FALSE(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts + 1)); + CHECK(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_s)); + CHECK_FALSE(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_s + 1)); } // Verify it can verify messages signed with the rotating public key diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index f0b3648b..028e4d54 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -7,11 +8,41 @@ #include #include +#include "utils.hpp" + +#if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) +#include +#endif + using namespace session::pro_backend; static bool string8_equals(string8 s8, std::string_view str) { return s8.size == str.size() && std::memcmp(s8.data, str.data(), s8.size) == 0; } +[[maybe_unused]] static void dump_pro_proof_to_stderr(const pro_proof& proof) { + fprintf(stderr, "proof.version: %u\n", proof.version); + fprintf(stderr, "proof.gen_index_hash: %s\n", oxenc::to_hex(proof.gen_index_hash.data).c_str()); + fprintf(stderr, + "proof.rotating_pubkey: %s\n", + oxenc::to_hex(proof.rotating_pubkey.data).c_str()); + fprintf(stderr, "proof.expiry_unix_ts_s: %zu\n", proof.expiry_unix_ts_s); + fprintf(stderr, "proof.sig: %s\n", oxenc::to_hex(proof.sig.data).c_str()); +} + +[[maybe_unused]] static void dump_pro_payment_item(const session_pro_backend_pro_payment_item& item) { + fprintf(stderr, "item.activation_unix_ts_s: %zu\n", item.activation_unix_ts_s); + fprintf(stderr, "item.archive_unix_ts_s: %zu\n", item.archive_unix_ts_s); + fprintf(stderr, "item.creation_unix_ts_s: %zu\n", item.creation_unix_ts_s); + fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration); + fprintf(stderr, "item.payment_token_hash: %s\n", oxenc::to_hex(item.payment_token_hash.data).c_str()); +} + +size_t curl_perform_callback(void* contents, size_t size, size_t nmemb, void* userp) { + size_t total = size * nmemb; + auto* response_json = static_cast(userp); + *response_json += std::string_view(static_cast(contents), total); + return total; +}; TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Setup: Generate keys and payment token hash @@ -273,6 +304,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { nlohmann::json j; j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { + {"version", 0}, {"expiry_unix_ts_s", unix_ts_s}, {"gen_index_hash", oxenc::to_hex(payment_token_hash.data)}, {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, @@ -451,4 +483,224 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_payments_response_free(&pay_response); REQUIRE(pay_response.header.internal_arena_buf_ == nullptr); } + +#if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) + SECTION("Send to local dev server") { + const auto DEV_BACKEND_PUBKEY = + "fc947730f49eb01427a66e050733294d9e520e545c7a27125a780634e0860a27"_hexbytes; + + // Setup CURL + curl_global_init(CURL_GLOBAL_DEFAULT); + + CURL* curl = curl_easy_init(); + REQUIRE(curl); + + struct curl_slist* curl_headers = + curl_slist_append(curl_headers, "Content-Type: application/json"); + REQUIRE(curl_headers); + + // Add pro payment + { + // Build request + session_pro_backend_master_rotating_signatures add_pro_sigs = + session_pro_backend_add_pro_payment_request_build_sigs( + /*version*/ 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + payment_token_hash.data, + sizeof(payment_token_hash), + unix_ts_s); + + session_pro_backend_add_pro_payment_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.payment_token = payment_token_hash; + request.master_sig = add_pro_sigs.master_sig; + request.rotating_sig = add_pro_sigs.rotating_sig; + + session_pro_backend_to_json request_json = + session_pro_backend_add_pro_payment_request_to_json(&request); + + // Build CURL request + std::string response_json = {}; + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_POST, request_json.json.size); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json); + curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:5000/add_pro_payment"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_json.json.data); + + // Dispatch + CURLcode res = curl_easy_perform(curl); + REQUIRE(res == CURLE_OK); + + // Parse response + session_pro_backend_add_pro_payment_or_get_pro_proof_response response = + session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + response_json.data(), response_json.size()); + for (size_t index = 0; index < response.header.errors_count; index++) { + string8 error = response.header.errors[index]; + INFO("error: " << error.data); + } + + // Verify response + pro_proof proof = {}; + proof.version = response.version; + proof.gen_index_hash = response.gen_index_hash; + proof.rotating_pubkey = response.rotating_pkey; + proof.expiry_unix_ts_s = response.expiry_unix_ts_s; + proof.sig = response.sig; + + REQUIRE(pro_proof_verify_signature( + &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); + REQUIRE(std::memcmp( + response.rotating_pkey.data, + request.rotating_pkey.data, + sizeof(request.rotating_pkey)) == 0); + + session_pro_backend_to_json_free(&request_json); + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + } + + // Authorise new key + { + uint64_t now_unix_ts_s = time(nullptr); + // Build request + session_pro_backend_master_rotating_signatures pro_sigs = + session_pro_backend_get_pro_proof_request_build_sigs( + /*version*/ 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + now_unix_ts_s); + + session_pro_backend_get_pro_proof_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.unix_ts_s = now_unix_ts_s; + request.master_sig = pro_sigs.master_sig; + request.rotating_sig = pro_sigs.rotating_sig; + + session_pro_backend_to_json request_json = + session_pro_backend_get_pro_proof_request_to_json(&request); + + // Build CURL request + std::string response_json = {}; + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_POST, request_json.json.size); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json); + curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:5000/get_pro_proof"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_json.json.data); + + // Dispatch + CURLcode res = curl_easy_perform(curl); + REQUIRE(res == CURLE_OK); + + // Parse response + session_pro_backend_add_pro_payment_or_get_pro_proof_response response = + session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + response_json.data(), response_json.size()); + for (size_t index = 0; index < response.header.errors_count; index++) { + string8 error = response.header.errors[index]; + fprintf(stderr, "error: %s\n", error.data); + } + REQUIRE(response.header.errors_count == 0); + REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + + // Verify response + pro_proof proof = {}; + proof.version = response.version; + proof.gen_index_hash = response.gen_index_hash; + proof.rotating_pubkey = response.rotating_pkey; + proof.expiry_unix_ts_s = response.expiry_unix_ts_s; + proof.sig = response.sig; + + REQUIRE(pro_proof_verify_signature( + &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); + REQUIRE(std::memcmp( + response.rotating_pkey.data, + request.rotating_pkey.data, + sizeof(request.rotating_pkey)) == 0); + + session_pro_backend_to_json_free(&request_json); + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + } + + // Get payment history + { + uint64_t now_unix_ts_s = time(nullptr); + + // Build request + session_pro_backend_get_pro_payments_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.unix_ts_s = now_unix_ts_s; + request.page = 0; + + session_pro_backend_signature sig = + session_pro_backend_get_pro_payments_request_build_sig( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + request.unix_ts_s, + request.page); + REQUIRE(sig.success); + + request.master_sig = sig.sig; + + session_pro_backend_to_json request_json = + session_pro_backend_get_pro_payments_request_to_json(&request); + + // Build CURL request + std::string response_json = {}; + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_POST, request_json.json.size); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json); + curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:5000/get_pro_payments"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_json.json.data); + + // Dispatch + CURLcode res = curl_easy_perform(curl); + REQUIRE(res == CURLE_OK); + + // Parse response + session_pro_backend_get_pro_payments_response response = + session_pro_backend_get_pro_payments_response_parse( + response_json.data(), response_json.size()); + for (size_t index = 0; index < response.header.errors_count; index++) { + string8 error = response.header.errors[index]; + fprintf(stderr, "error: %s\n", error.data); + } + + // Verify the response + REQUIRE(response.header.errors_count == 0); + REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(response.pages == 0); + REQUIRE(response.payments > 0); + REQUIRE(response.items_count > 0); + for (size_t index = 0; index < response.items_count; index++) { + const session_pro_backend_pro_payment_item& payment = response.items[index]; + dump_pro_payment_item(payment); + } + + session_pro_backend_to_json_free(&request_json); + session_pro_backend_get_pro_payments_response_free(&response); + } + + // Cleanup CURL + curl_slist_free_all(curl_headers); + curl_easy_cleanup(curl); + curl_global_cleanup(); + } +#endif } From cc882891f36d79f3e13e704877dcccde650fa865 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 14:08:16 +1000 Subject: [PATCH 070/171] Add revocation tests, guard CURL tests behind CMake option --- include/session/pro_backend.h | 35 ++-- include/session/pro_backend.hpp | 29 +--- src/config/pro.cpp | 1 + src/pro_backend.cpp | 37 ++-- src/session_protocol.cpp | 1 + tests/test_pro_backend.cpp | 287 ++++++++++++++++++++++---------- 6 files changed, 246 insertions(+), 144 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index a1aa5b8a..367762b8 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "export.h" @@ -15,7 +16,7 @@ enum { SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR = 1, }; -typedef struct { +typedef struct session_pro_backend_response_header { uint32_t status; /// Array of error messages (NULL if no errors), with errors_count elements string8* errors; @@ -28,7 +29,7 @@ typedef struct { string8 json; } session_pro_backend_to_json; -typedef struct { +typedef struct session_pro_backend_master_rotating_signatures { bool success; char error[256]; size_t error_count; @@ -36,14 +37,14 @@ typedef struct { bytes64 rotating_sig; } session_pro_backend_master_rotating_signatures; -typedef struct { +typedef struct session_pro_backend_signature { bool success; char error[256]; size_t error_count; bytes64 sig; } session_pro_backend_signature; -typedef struct { +typedef struct session_pro_backend_add_pro_payment_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; @@ -52,7 +53,7 @@ typedef struct { bytes64 rotating_sig; } session_pro_backend_add_pro_payment_request; -typedef struct { +typedef struct session_pro_backend_get_pro_proof_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; @@ -61,26 +62,22 @@ typedef struct { bytes64 rotating_sig; } session_pro_backend_get_pro_proof_request; -typedef struct { +typedef struct session_pro_backend_add_pro_payment_or_get_pro_proof_response { session_pro_backend_response_header header; - uint8_t version; - uint64_t expiry_unix_ts_s; - bytes32 gen_index_hash; - bytes32 rotating_pkey; - bytes64 sig; + pro_proof proof; } session_pro_backend_add_pro_payment_or_get_pro_proof_response; -typedef struct { +typedef struct session_pro_backend_get_pro_revocations_request { uint8_t version; uint32_t ticket; } session_pro_backend_get_pro_revocations_request; -typedef struct { +typedef struct session_pro_backend_pro_revocation_item { bytes32 gen_index_hash; uint64_t expiry_unix_ts_s; } session_pro_backend_pro_revocation_item; -typedef struct { +typedef struct session_pro_backend_get_pro_revocations_response { session_pro_backend_response_header header; uint32_t ticket; /// Array of items, with items_count elements @@ -88,7 +85,7 @@ typedef struct { size_t items_count; } session_pro_backend_get_pro_revocations_response; -typedef struct { +typedef struct session_pro_backend_get_pro_payments_request { uint8_t version; bytes32 master_pkey; bytes64 master_sig; @@ -96,7 +93,7 @@ typedef struct { uint32_t page; } session_pro_backend_get_pro_payments_request; -typedef struct { +typedef struct session_pro_backend_pro_payment_item { uint64_t activation_unix_ts_s; uint64_t archive_unix_ts_s; uint64_t creation_unix_ts_s; @@ -104,7 +101,7 @@ typedef struct { bytes32 payment_token_hash; } session_pro_backend_pro_payment_item; -typedef struct { +typedef struct session_pro_backend_get_pro_payments_response { session_pro_backend_response_header header; /// Array of payment items, with items_count elements session_pro_backend_pro_payment_item* items; @@ -127,7 +124,6 @@ typedef struct { /// - `rotating_privkey_len` -- Length of rotating_privkey. /// - `payment_token_hash` -- 32-byte hash of the payment token. /// - `payment_token_hash_len` -- Length of payment_token_hash. -/// - `unix_ts_s` -- Unix timestamp (seconds) for the request. /// /// Outputs: /// - `success` - True if signatures are built successfully, false otherwise. @@ -144,8 +140,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( const uint8_t* rotating_privkey, size_t rotating_privkey_len, const uint8_t* payment_token_hash, - size_t payment_token_hash_len, - uint64_t unix_ts_s); + size_t payment_token_hash_len); /// API: session_pro_backend/get_pro_proof_request_build_sigs /// diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 3856e52b..a6e84080 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -2,7 +2,10 @@ #include #include +#include #include +#include +#include /// Helper functions to construct payloads to communicate with the Session Pro Backend. The data /// structures here are largely bindings to the endpoints exposed on the Session Pro Backend: @@ -22,8 +25,9 @@ /// otherwise an error is returned and can be read from the `ResponseHeader` after parsing the /// raw response. /// -/// 2. Attach the proof to their messages. Libsession has helper functions to embed the proof into -/// their messages via the helper functions in the Session Protocol header file. +/// 2. Attach the `ProProof` constructed from (1) into their messages. Libsession has helper +/// functions to embed the proof into their messages via the helper functions in the Session +/// Protocol header file. /// /// 3. Periodically poll the global revocation list which overrides the validity of current /// circulating proofs. This is done by constructing the request via @@ -111,7 +115,6 @@ struct AddProPaymentRequest { /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key /// - `payment_token_hash` -- 32-byte hash of the payment token. - /// - `unix_ts` -- Unix timestamp (seconds) for the request. /// /// Outputs: /// - `MasterRotatingSignatures` - Struct containing the 64-byte master and rotating signatures. @@ -119,30 +122,14 @@ struct AddProPaymentRequest { std::uint8_t request_version, std::span master_privkey, std::span rotating_privkey, - std::span payment_token_hash, - std::chrono::sys_seconds unix_ts); + std::span payment_token_hash); }; /// The generated proof from the Session Pro backend that has been parsed from JSON. This structure /// is the raw parse result that can then be converted into the config::ProProof or equivalent /// structure. struct AddProPaymentOrGetProProofResponse : public ResponseHeader { - /// Version of the proof - uint8_t version; - - /// Unix timestamp (seconds) of when the proof expires - std::chrono::sys_seconds expiry_unix_ts; - - /// 32-byte hash of the internal generation index shared across all proofs generated under the - /// same group of payments - array_uc32 gen_index_hash; - - /// 32-byte Ed25519 Session Pro rotating public key authorized to use the proof - array_uc32 rotating_pkey; - - /// 64-byte signature by the Session Pro backend to allow other clients to validate that the - /// proof was issued by an authoritative backend. - array_uc64 sig; + ProProof proof; /// API: pro/AddProPaymentOrGetProProofResponse::parse /// diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 76fd560f..2970c112 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 4957c30a..3fe8a48a 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -133,8 +133,7 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( std::uint8_t version, std::span master_privkey, std::span rotating_privkey, - std::span payment_token_hash, - std::chrono::sys_seconds unix_ts) { + std::span payment_token_hash) { if (payment_token_hash.size() != 32) throw std::invalid_argument{"Invalid payment_token_hash: expected 32 bytes"}; @@ -209,14 +208,14 @@ bool AddProPaymentOrGetProProofResponse::parse(std::string_view json) { return errors.empty(); // Parse payload - version = json_require(result_obj, "version", errors); + proof.version = json_require(result_obj, "version", errors); auto expiry_unix_ts_s = json_require(result_obj, "expiry_unix_ts_s", errors); - expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); + proof.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); json_require_fixed_bytes_from_hex( - result_obj, "gen_index_hash", errors, gen_index_hash); + result_obj, "gen_index_hash", errors, proof.gen_index_hash); json_require_fixed_bytes_from_hex( - result_obj, "rotating_pkey", errors, rotating_pkey); - json_require_fixed_bytes_from_hex(result_obj, "sig", errors, sig); + result_obj, "rotating_pkey", errors, proof.rotating_pubkey); + json_require_fixed_bytes_from_hex(result_obj, "sig", errors, proof.sig); return errors.empty(); } @@ -494,19 +493,17 @@ session_pro_backend_add_pro_payment_request_build_sigs( const uint8_t* rotating_privkey, size_t rotating_privkey_len, const uint8_t* payment_token_hash, - size_t payment_token_hash_len, - uint64_t unix_ts_s) { + size_t payment_token_hash_len) { // Convert C inputs to C++ types std::span master_span(master_privkey, master_privkey_len); std::span rotating_span(rotating_privkey, rotating_privkey_len); std::span token_span(payment_token_hash, payment_token_hash_len); - std::chrono::sys_seconds ts{std::chrono::seconds{unix_ts_s}}; session_pro_backend_master_rotating_signatures result = {}; try { auto sigs = AddProPaymentRequest::build_sigs( - request_version, master_span, rotating_span, token_span, ts); + request_version, master_span, rotating_span, token_span); std::memcpy(result.master_sig.data, sigs.master_sig.data(), sigs.master_sig.size()); std::memcpy(result.rotating_sig.data, sigs.rotating_sig.data(), sigs.rotating_sig.size()); result.success = true; @@ -748,13 +745,19 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( // Note that a response error and success case folds into the same code path. A success and error // response returns the same struct just with different fields populated. result.header.status = cpp.status; - result.version = cpp.version; - result.expiry_unix_ts_s = - std::chrono::duration_cast(cpp.expiry_unix_ts.time_since_epoch()) + result.proof.version = cpp.proof.version; + result.proof.expiry_unix_ts_s = + std::chrono::duration_cast(cpp.proof.expiry_unix_ts.time_since_epoch()) .count(); - std::memcpy(result.gen_index_hash.data, cpp.gen_index_hash.data(), cpp.gen_index_hash.size()); - std::memcpy(result.rotating_pkey.data, cpp.rotating_pkey.data(), cpp.rotating_pkey.size()); - std::memcpy(result.sig.data, cpp.sig.data(), cpp.sig.size()); + std::memcpy( + result.proof.gen_index_hash.data, + cpp.proof.gen_index_hash.data(), + cpp.proof.gen_index_hash.size()); + std::memcpy( + result.proof.rotating_pubkey.data, + cpp.proof.rotating_pubkey.data(), + cpp.proof.rotating_pubkey.size()); + std::memcpy(result.proof.sig.data, cpp.proof.sig.data(), cpp.proof.sig.size()); // Copy errors result.header.errors_count = cpp.errors.size(); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 52f3d257..5169e0c7 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include "SessionProtos.pb.h" diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 028e4d54..1dd0bde7 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -5,15 +5,12 @@ #include #include +#include #include #include #include "utils.hpp" -#if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) -#include -#endif - using namespace session::pro_backend; static bool string8_equals(string8 s8, std::string_view str) { @@ -37,6 +34,15 @@ static bool string8_equals(string8 s8, std::string_view str) { fprintf(stderr, "item.payment_token_hash: %s\n", oxenc::to_hex(item.payment_token_hash.data).c_str()); } +[[maybe_unused]] static void dump_pro_revocation(const session_pro_backend_pro_revocation_item& item) { + fprintf(stderr, "item.expiry_unix_ts: %zu\n", item.expiry_unix_ts_s); + fprintf(stderr, "item.gen_index_hash: %s\n", oxenc::to_hex(item.gen_index_hash.data).c_str()); +} + + +#if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) +#include + size_t curl_perform_callback(void* contents, size_t size, size_t nmemb, void* userp) { size_t total = size * nmemb; auto* response_json = static_cast(userp); @@ -44,6 +50,30 @@ size_t curl_perform_callback(void* contents, size_t size, size_t nmemb, void* us return total; }; +std::string curl_do_basic_blocking_post_request( + CURL* curl, curl_slist* headers, std::string_view url, std::string_view post_body) { + std::string url_null_terminated = std::string(url); + + std::string result; + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &result); + curl_easy_setopt(curl, CURLOPT_URL, url_null_terminated.c_str()); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2); + + if (post_body.size()) { + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_body.data()); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, post_body.size()); + } + + CURLcode res = curl_easy_perform(curl); + REQUIRE(res == CURLE_OK); + return result; +} +#endif + TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Setup: Generate keys and payment token hash bytes32 master_pubkey = {}; @@ -68,18 +98,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { rotating_privkey.data, sizeof(rotating_privkey), payment_token_hash.data, - sizeof(payment_token_hash), - unix_ts_s); + sizeof(payment_token_hash)); REQUIRE(result.success); REQUIRE(result.error_count == 0); // Verify signatures match C++ implementation auto cpp = AddProPaymentRequest::build_sigs( - 0, - master_privkey.data, - rotating_privkey.data, - payment_token_hash.data, - std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}); + 0, master_privkey.data, rotating_privkey.data, payment_token_hash.data); REQUIRE(std::memcmp( result.master_sig.data, cpp.master_sig.data(), @@ -97,8 +122,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { rotating_privkey.data, sizeof(rotating_privkey), payment_token_hash.data, - sizeof(payment_token_hash.data), - unix_ts_s); + sizeof(payment_token_hash.data)); REQUIRE(!result.success); REQUIRE(result.error_count > 0); @@ -110,8 +134,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { rotating_privkey.data, sizeof(rotating_privkey), payment_token_hash.data, - sizeof(payment_token_hash) - 1, - unix_ts_s); + sizeof(payment_token_hash) - 1); REQUIRE(!result.success); REQUIRE(result.error_count > 0); } @@ -313,16 +336,49 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string json = j.dump(); // Valid JSON - auto result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(json.data(), json.size()); + session_pro_backend_add_pro_payment_or_get_pro_proof_response result = + session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + json.data(), json.size()); + for (size_t index = 0; index < result.header.errors_count; index++) INFO(result.header.errors[index].data); REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count == 0); REQUIRE(result.header.errors == nullptr); - REQUIRE(result.expiry_unix_ts_s == unix_ts_s); - REQUIRE(std::memcmp(result.gen_index_hash.data, payment_token_hash.data, sizeof(payment_token_hash)) == 0); - REQUIRE(std::memcmp(result.rotating_pkey.data, rotating_pubkey.data, sizeof(rotating_pubkey)) == 0); - REQUIRE(std::memcmp(result.sig.data, master_privkey.data, sizeof(master_privkey)) == 0); + REQUIRE(result.proof.expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp( + result.proof.gen_index_hash.data, + payment_token_hash.data, + sizeof(payment_token_hash)) == 0); + REQUIRE(std::memcmp( + result.proof.rotating_pubkey.data, + rotating_pubkey.data, + sizeof(rotating_pubkey)) == 0); + REQUIRE(std::memcmp(result.proof.sig.data, master_privkey.data, sizeof(master_privkey)) == + 0); + + // Here we also create the CPP version, we will run the conversion functions into pro proofs + // (both C and CPP variants) and then compare the two structures to make sure the conversion + // functions are sound. + AddProPaymentOrGetProProofResponse result_cpp = {}; + REQUIRE(result_cpp.parse(json)); + + // Validate C and CPP variants + REQUIRE(result.proof.version == result_cpp.proof.version); + REQUIRE(std::memcmp( + result.proof.gen_index_hash.data, + result_cpp.proof.gen_index_hash.data(), + result_cpp.proof.gen_index_hash.size()) == 0); + REQUIRE(std::memcmp( + result.proof.rotating_pubkey.data, + result_cpp.proof.rotating_pubkey.data(), + result_cpp.proof.rotating_pubkey.size()) == 0); + REQUIRE(result.proof.expiry_unix_ts_s == + result_cpp.proof.expiry_unix_ts.time_since_epoch().count()); + REQUIRE(std::memcmp( + result.proof.sig.data, + result_cpp.proof.sig.data(), + result_cpp.proof.sig.size()) == 0); // Free memory session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); @@ -500,6 +556,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(curl_headers); // Add pro payment + pro_proof first_pro_proof = {}; { // Build request session_pro_backend_master_rotating_signatures add_pro_sigs = @@ -510,8 +567,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { rotating_privkey.data, sizeof(rotating_privkey), payment_token_hash.data, - sizeof(payment_token_hash), - unix_ts_s); + sizeof(payment_token_hash)); session_pro_backend_add_pro_payment_request request = {}; request.version = 0; @@ -524,41 +580,29 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_to_json request_json = session_pro_backend_add_pro_payment_request_to_json(&request); - // Build CURL request - std::string response_json = {}; - curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_POST, request_json.json.size); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json); - curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:5000/add_pro_payment"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_json.json.data); - - // Dispatch - CURLcode res = curl_easy_perform(curl); - REQUIRE(res == CURLE_OK); + // Do curl request + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + "http://127.0.0.1:5000/add_pro_payment", + std::string_view(request_json.json.data, request_json.json.size)); // Parse response session_pro_backend_add_pro_payment_or_get_pro_proof_response response = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( response_json.data(), response_json.size()); + for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; INFO("error: " << error.data); } // Verify response - pro_proof proof = {}; - proof.version = response.version; - proof.gen_index_hash = response.gen_index_hash; - proof.rotating_pubkey = response.rotating_pkey; - proof.expiry_unix_ts_s = response.expiry_unix_ts_s; - proof.sig = response.sig; - + first_pro_proof = response.proof; REQUIRE(pro_proof_verify_signature( - &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); + &first_pro_proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( - response.rotating_pkey.data, + response.proof.rotating_pubkey.data, request.rotating_pkey.data, sizeof(request.rotating_pkey)) == 0); @@ -590,19 +634,12 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_to_json request_json = session_pro_backend_get_pro_proof_request_to_json(&request); - // Build CURL request - std::string response_json = {}; - curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_POST, request_json.json.size); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json); - curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:5000/get_pro_proof"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_json.json.data); - - // Dispatch - CURLcode res = curl_easy_perform(curl); - REQUIRE(res == CURLE_OK); + // Do CURL request + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + "http://127.0.0.1:5000/get_pro_proof", + std::string_view(request_json.json.data, request_json.json.size)); // Parse response session_pro_backend_add_pro_payment_or_get_pro_proof_response response = @@ -616,17 +653,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); // Verify response - pro_proof proof = {}; - proof.version = response.version; - proof.gen_index_hash = response.gen_index_hash; - proof.rotating_pubkey = response.rotating_pkey; - proof.expiry_unix_ts_s = response.expiry_unix_ts_s; - proof.sig = response.sig; - + pro_proof proof = response.proof; REQUIRE(pro_proof_verify_signature( &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( - response.rotating_pkey.data, + response.proof.rotating_pubkey.data, request.rotating_pkey.data, sizeof(request.rotating_pkey)) == 0); @@ -636,13 +667,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Get payment history { - uint64_t now_unix_ts_s = time(nullptr); - // Build request session_pro_backend_get_pro_payments_request request = {}; request.version = 0; request.master_pkey = master_pubkey; - request.unix_ts_s = now_unix_ts_s; + request.unix_ts_s = time(nullptr); request.page = 0; session_pro_backend_signature sig = @@ -653,25 +682,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.unix_ts_s, request.page); REQUIRE(sig.success); - request.master_sig = sig.sig; + // Do CURL request session_pro_backend_to_json request_json = session_pro_backend_get_pro_payments_request_to_json(&request); - // Build CURL request - std::string response_json = {}; - curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_POST, request_json.json.size); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json); - curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:5000/get_pro_payments"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_json.json.data); - - // Dispatch - CURLcode res = curl_easy_perform(curl); - REQUIRE(res == CURLE_OK); + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + "http://127.0.0.1:5000/get_pro_payments", + std::string_view(request_json.json.data, request_json.json.size)); // Parse response session_pro_backend_get_pro_payments_response response = @@ -688,15 +709,109 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.pages == 0); REQUIRE(response.payments > 0); REQUIRE(response.items_count > 0); - for (size_t index = 0; index < response.items_count; index++) { - const session_pro_backend_pro_payment_item& payment = response.items[index]; - dump_pro_payment_item(payment); - } session_pro_backend_to_json_free(&request_json); session_pro_backend_get_pro_payments_response_free(&response); } + // Add _another_ payment, same details. This creates a revocation for + // the old proof and the subscription duration will stack, all old + // proofs invalidated and new ones issued with the combined duration. + { + // Build request + session_pro_backend_master_rotating_signatures add_pro_sigs = + session_pro_backend_add_pro_payment_request_build_sigs( + /*version*/ 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + payment_token_hash.data, + sizeof(payment_token_hash)); + + session_pro_backend_add_pro_payment_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.payment_token = payment_token_hash; + request.master_sig = add_pro_sigs.master_sig; + request.rotating_sig = add_pro_sigs.rotating_sig; + + session_pro_backend_to_json request_json = + session_pro_backend_add_pro_payment_request_to_json(&request); + + // Do curl request + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + "http://127.0.0.1:5000/add_pro_payment", + std::string_view(request_json.json.data, request_json.json.size)); + + // Parse response + session_pro_backend_add_pro_payment_or_get_pro_proof_response response = + session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + response_json.data(), response_json.size()); + + // Verify response + pro_proof proof = response.proof; + REQUIRE(pro_proof_verify_signature( + &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); + REQUIRE(std::memcmp( + response.proof.rotating_pubkey.data, + request.rotating_pkey.data, + sizeof(request.rotating_pkey)) == 0); + + session_pro_backend_to_json_free(&request_json); + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + } + + // Get revocation list + { + // Build request + session_pro_backend_get_pro_revocations_request request = {}; + request.version = 0; + + session_pro_backend_to_json request_json = + session_pro_backend_get_pro_revocations_request_to_json(&request); + + // Do curl request + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + "http://127.0.0.1:5000/get_pro_revocations", + std::string_view(request_json.json.data, request_json.json.size)); + + // Parse response + session_pro_backend_get_pro_revocations_response response = + session_pro_backend_get_pro_revocations_response_parse( + response_json.data(), response_json.size()); + + // Verify response + for (size_t index = 0; index < response.header.errors_count; index++) { + string8 error = response.header.errors[index]; + fprintf(stderr, "error: %s\n", error.data); + } + + // Verify the response + REQUIRE(response.header.errors_count == 0); + REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(response.ticket > 0); + REQUIRE(response.items_count > 0); + + // The last revocation added should be the first pro proof we generated from a "payment" + // in the test-suite + REQUIRE(std::memcmp( + response.items[response.items_count - 1].gen_index_hash.data, + first_pro_proof.gen_index_hash.data, + sizeof(first_pro_proof.gen_index_hash)) == 0); + + REQUIRE(response.items[response.items_count - 1].expiry_unix_ts_s == + first_pro_proof.expiry_unix_ts_s); + + session_pro_backend_to_json_free(&request_json); + session_pro_backend_get_pro_revocations_response_free(&response); + } + // Cleanup CURL curl_slist_free_all(curl_headers); curl_easy_cleanup(curl); From 8d881d069331cc8e5cb7e49eedabfcc20b4cd856 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 14:38:46 +1000 Subject: [PATCH 071/171] Update readme with new instructions for pro backend dev mode tests --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index d4229b9d..da474771 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,31 @@ # 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 to be running at 127.0.0.1:5000 +# 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. +# +cmake -G Ninja -S . -B Build + +# Build +cmake --build Build --parallel --verbose +``` + ## Docs C Library: https://api.oxen.io/libsession-util-c/#/ From 58f84289442d1601831586c822d6f2540a325c78 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 15:00:17 +1000 Subject: [PATCH 072/171] Add more notes on role/usage of protocol.hpp --- include/session/session_protocol.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 1e9ce19c..ca49df6d 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -12,6 +12,24 @@ /// A complimentary file to session encrypt (which has the low level encryption function for Session /// protocol types). This file contains high-level helper functions for decoding payloads on the /// Session protocol. Prefer functions here before resorting to the lower-level cryptography. +/// +/// The general overview is that this file introduces functionality to abstract away protobufs types +/// on the Session Protocol from client implementations by wrapping the data structures where +/// necessary in libsession. In general clients will use the functions in this file as follows: +/// +/// - Derive Session Pro feature flags from a message for populating the new Pro fields for messages +/// +/// - Wrap and/or encrypt a plaintext content message into an Envelope or Websocket message +/// (depending on the configured namespace and destination) ready to be sent on the wire with +/// `encrypt_for_destination`. +/// +/// - Decrypt an incoming message in its websocket wrapped, and or encrypted envelope form with +/// `decrypt_envelope` +/// +/// TODO: In future the goal is to begin abstracting more protobuf types away from client +/// implementations such that the only dependency clients need to encode and decode Session Protocol +/// messages is libsession itself and that it will provide wrapper/proxy types for and handle +/// converting those into the wire format. // NOTE: In the CPP file we use C-style enums for bitfields and CPP-style enums for non-bitfield // enums where we can to benefit from the type-safety of strong enums. From deb2ba4fa7ff857d9a363ef3ff491f653ba1d679 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 17:23:23 +1000 Subject: [PATCH 073/171] Add payment provider to the pro payments items --- include/session/pro_backend.h | 10 ++++++++++ include/session/pro_backend.hpp | 11 ++++++++--- src/pro_backend.cpp | 18 +++++++++++++----- tests/test_pro_backend.cpp | 4 ++++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 367762b8..58696170 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -16,6 +16,15 @@ enum { SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR = 1, }; +/// Store front that a Session Pro payment came from. Must match: +/// https://github.com/Doy-lee/session-pro-backend/blob/3a1bdf2bfdc83487280e9b1d9a40aac8fd168dd6/base.py#L14 +typedef enum SESSION_PRO_PAYMENT_PROVIDER { + SESSION_PRO_PAYMENT_PROVIDER_NIL = 0, + SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE = 1, + SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE = 2, + SESSION_PRO_PAYMENT_PROVIDER_LAST = SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE + 1, +} SESSION_PRO_PAYMENT_PROVIDER; + typedef struct session_pro_backend_response_header { uint32_t status; /// Array of error messages (NULL if no errors), with errors_count elements @@ -98,6 +107,7 @@ typedef struct session_pro_backend_pro_payment_item { uint64_t archive_unix_ts_s; uint64_t creation_unix_ts_s; uint64_t subscription_duration; + SESSION_PRO_PAYMENT_PROVIDER payment_provider; bytes32 payment_token_hash; } session_pro_backend_pro_payment_item; diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index a6e84080..5fb099e4 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -1,11 +1,12 @@ #pragma once +#include + #include +#include #include #include #include -#include -#include /// Helper functions to construct payloads to communicate with the Session Pro Backend. The data /// structures here are largely bindings to the endpoints exposed on the Session Pro Backend: @@ -19,7 +20,8 @@ /// /// Server responds JSON to be parsed with `GetProPaymentsRequest::parse`. Clients should /// validate the response and update their `UserProfile` by constructing a `ProConfig` with the -/// proof from the response filling in the remaining fields appropriately in `ProConfig` +/// proof from the response by using `ProProof::from_pro_backend_response()` and filling in the +/// relevant private key that the proof was authorised for. /// /// The server will only respond successfully if it can also independently verify the purchase /// otherwise an error is returned and can be read from the `ResponseHeader` after parsing the @@ -306,6 +308,9 @@ struct ProPaymentItem { /// Subscription duration in seconds std::chrono::seconds subscription_duration; + /// Store front that this particular payment came from + SESSION_PRO_PAYMENT_PROVIDER payment_provider; + /// 32-byte hash of the payment token array_uc32 payment_token_hash; }; diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 3fe8a48a..a5271bfe 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -442,11 +442,12 @@ bool GetProPaymentsResponse::parse(std::string_view json) { } // Parse payment item - auto obj = it.get(); - auto activation_ts = json_require(obj, "activation_unix_ts_s", errors); - auto archive_ts = json_require(obj, "archive_unix_ts_s", errors); - auto creation_ts = json_require(obj, "creation_unix_ts_s", errors); - auto sub_duration_s = json_require(obj, "subscription_duration_s", errors); + auto obj = it.get(); + auto activation_ts = json_require(obj, "activation_unix_ts_s", errors); + auto archive_ts = json_require(obj, "archive_unix_ts_s", errors); + auto creation_ts = json_require(obj, "creation_unix_ts_s", errors); + auto sub_duration_s = json_require(obj, "subscription_duration_s", errors); + auto payment_provider = json_require(obj, "payment_provider", errors); ProPaymentItem item = {}; item.activation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activation_ts)); @@ -454,6 +455,12 @@ bool GetProPaymentsResponse::parse(std::string_view json) { item.creation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(creation_ts)); item.subscription_duration = std::chrono::seconds(sub_duration_s); json_require_fixed_bytes_from_hex(obj, "payment_token_hash", errors, item.payment_token_hash); + if (payment_provider > SESSION_PRO_PAYMENT_PROVIDER_NIL && + payment_provider < SESSION_PRO_PAYMENT_PROVIDER_LAST) { + item.payment_provider = static_cast(payment_provider); + } else { + errors.push_back(fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); + } // Handle parsing result if (errors.size()) @@ -900,6 +907,7 @@ LIBSESSION_C_API session_pro_backend_get_pro_payments_response session_pro_backe .count(); dest.subscription_duration = std::chrono::duration_cast(src.subscription_duration).count(); + dest.payment_provider = src.payment_provider; std::memcpy( dest.payment_token_hash.data, src.payment_token_hash.data(), diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 1dd0bde7..ca7928a6 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -31,6 +31,7 @@ static bool string8_equals(string8 s8, std::string_view str) { fprintf(stderr, "item.archive_unix_ts_s: %zu\n", item.archive_unix_ts_s); fprintf(stderr, "item.creation_unix_ts_s: %zu\n", item.creation_unix_ts_s); fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration); + fprintf(stderr, "item.payment_provider: %u\n", item.payment_provider); fprintf(stderr, "item.payment_token_hash: %s\n", oxenc::to_hex(item.payment_token_hash.data).c_str()); } @@ -470,6 +471,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"archive_unix_ts_s", unix_ts_s + 3600}, {"creation_unix_ts_s", unix_ts_s - 3600}, {"subscription_duration_s", 86400}, + {"payment_provider", SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, {"payment_token_hash", oxenc::to_hex(payment_token_hash.data)} } })} @@ -488,6 +490,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.items_count == 1); REQUIRE(result.items != nullptr); REQUIRE(result.items[0].activation_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].payment_provider > SESSION_PRO_PAYMENT_PROVIDER_NIL); + REQUIRE(result.items[0].payment_provider < SESSION_PRO_PAYMENT_PROVIDER_LAST); REQUIRE(result.items[0].archive_unix_ts_s == unix_ts_s + 3600); REQUIRE(result.items[0].creation_unix_ts_s == unix_ts_s - 3600); REQUIRE(result.items[0].subscription_duration == 86400); From be48a6fd6c65ca5fded005f3edfe5c5b4a7381f0 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 17:41:09 +1000 Subject: [PATCH 074/171] Add Session Pro payment provider metadata, e.g. links to support pages --- include/session/pro_backend.h | 32 +++++++++++++++++++++++++++----- include/session/pro_backend.hpp | 5 ++++- include/session/types.h | 2 ++ src/pro_backend.cpp | 2 +- tests/test_pro_backend.cpp | 2 +- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 58696170..ac410d0a 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -1,9 +1,9 @@ #pragma once +#include #include #include #include -#include #include "export.h" @@ -19,12 +19,34 @@ enum { /// Store front that a Session Pro payment came from. Must match: /// https://github.com/Doy-lee/session-pro-backend/blob/3a1bdf2bfdc83487280e9b1d9a40aac8fd168dd6/base.py#L14 typedef enum SESSION_PRO_PAYMENT_PROVIDER { - SESSION_PRO_PAYMENT_PROVIDER_NIL = 0, - SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE = 1, - SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE = 2, - SESSION_PRO_PAYMENT_PROVIDER_LAST = SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE + 1, + SESSION_PRO_PAYMENT_PROVIDER_NIL, + SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE, + SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE, + SESSION_PRO_PAYMENT_PROVIDER_COUNT, } SESSION_PRO_PAYMENT_PROVIDER; +typedef struct session_pro_payment_provider_metadata { + string8 request_refund_support_url; + string8 subscription_page_url; +} session_pro_payment_provider_metadata; + +/// The centralised list of common URLs and properties for handling payment provider specific +/// integrations. Especially useful for cross-device management of Session Pro subscriptions. +const session_pro_payment_provider_metadata PAYMENT_PROVIDER_METADATA[SESSION_PRO_PAYMENT_PROVIDER_COUNT] = { + /*SESSION_PRO_PAYMENT_PROVIDER_NIL*/ { + .request_refund_support_url = string8_literal(""), + .subscription_page_url = string8_literal(""), + }, + /*SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE*/ { + .request_refund_support_url = string8_literal("https://support.google.com/googleplay/workflow/9813244"), + .subscription_page_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger"), + }, + /*SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE*/ { + .request_refund_support_url = string8_literal("https://support.apple.com/118223"), + .subscription_page_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions") + } +}; + typedef struct session_pro_backend_response_header { uint32_t status; /// Array of error messages (NULL if no errors), with errors_count elements diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 5fb099e4..dd04f8a2 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -45,7 +45,10 @@ /// Server responds JSON to be parsed with `GetProPaymentsResponse::parse` which they can use to /// populate their client's payment history. /// -/// See the unit tests for examples of the API. +/// 5. Get a list of per-payment provider URLs, such as links to the support page for refunds and +/// subscription via the `PAYMENT_PROVIDER_METADATA` global variable defined in the C header. +/// +/// See the unit tests for examples of using the APIs mentioned. namespace session::pro_backend { diff --git a/include/session/types.h b/include/session/types.h index f5e1f91d..2f15889e 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -18,6 +18,8 @@ struct string8 { size_t size; }; +#define string8_literal(literal) {(char *)literal, sizeof(literal) - 1} + struct bytes32 { uint8_t data[32]; }; diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index a5271bfe..55dc3f5a 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -456,7 +456,7 @@ bool GetProPaymentsResponse::parse(std::string_view json) { item.subscription_duration = std::chrono::seconds(sub_duration_s); json_require_fixed_bytes_from_hex(obj, "payment_token_hash", errors, item.payment_token_hash); if (payment_provider > SESSION_PRO_PAYMENT_PROVIDER_NIL && - payment_provider < SESSION_PRO_PAYMENT_PROVIDER_LAST) { + payment_provider < SESSION_PRO_PAYMENT_PROVIDER_COUNT) { item.payment_provider = static_cast(payment_provider); } else { errors.push_back(fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index ca7928a6..81737d10 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -491,7 +491,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.items != nullptr); REQUIRE(result.items[0].activation_unix_ts_s == unix_ts_s); REQUIRE(result.items[0].payment_provider > SESSION_PRO_PAYMENT_PROVIDER_NIL); - REQUIRE(result.items[0].payment_provider < SESSION_PRO_PAYMENT_PROVIDER_LAST); + REQUIRE(result.items[0].payment_provider < SESSION_PRO_PAYMENT_PROVIDER_COUNT); REQUIRE(result.items[0].archive_unix_ts_s == unix_ts_s + 3600); REQUIRE(result.items[0].creation_unix_ts_s == unix_ts_s - 3600); REQUIRE(result.items[0].subscription_duration == 86400); From 4875beeaf7a141ae38e366c56d2bf3d34af9c8a8 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 27 Aug 2025 17:55:40 +1000 Subject: [PATCH 075/171] Fix formatting --- include/session/pro_backend.h | 40 ++++--- include/session/pro_backend.hpp | 4 +- include/session/types.h | 7 +- src/config/pro.cpp | 2 +- src/pro_backend.cpp | 186 ++++++++++++++------------------ src/types.cpp | 6 +- tests/test_pro_backend.cpp | 60 ++++++----- 7 files changed, 135 insertions(+), 170 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index ac410d0a..b08af6c0 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -18,21 +18,22 @@ enum { /// Store front that a Session Pro payment came from. Must match: /// https://github.com/Doy-lee/session-pro-backend/blob/3a1bdf2bfdc83487280e9b1d9a40aac8fd168dd6/base.py#L14 -typedef enum SESSION_PRO_PAYMENT_PROVIDER { - SESSION_PRO_PAYMENT_PROVIDER_NIL, - SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE, - SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE, - SESSION_PRO_PAYMENT_PROVIDER_COUNT, -} SESSION_PRO_PAYMENT_PROVIDER; - -typedef struct session_pro_payment_provider_metadata { +typedef enum SESSION_PRO_BACKEND_PAYMENT_PROVIDER { + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT, +} SESSION_PRO_BACKEND_PAYMENT_PROVIDER; + +typedef struct session_pro_backend_payment_provider_metadata { string8 request_refund_support_url; string8 subscription_page_url; -} session_pro_payment_provider_metadata; +} session_pro_backend_payment_provider_metadata; /// The centralised list of common URLs and properties for handling payment provider specific /// integrations. Especially useful for cross-device management of Session Pro subscriptions. -const session_pro_payment_provider_metadata PAYMENT_PROVIDER_METADATA[SESSION_PRO_PAYMENT_PROVIDER_COUNT] = { +// clang-format off +const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA[SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT] = { /*SESSION_PRO_PAYMENT_PROVIDER_NIL*/ { .request_refund_support_url = string8_literal(""), .subscription_page_url = string8_literal(""), @@ -46,6 +47,7 @@ const session_pro_payment_provider_metadata PAYMENT_PROVIDER_METADATA[SESSION_PR .subscription_page_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions") } }; +// clang-format on typedef struct session_pro_backend_response_header { uint32_t status; @@ -129,7 +131,7 @@ typedef struct session_pro_backend_pro_payment_item { uint64_t archive_unix_ts_s; uint64_t creation_unix_ts_s; uint64_t subscription_duration; - SESSION_PRO_PAYMENT_PROVIDER payment_provider; + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; bytes32 payment_token_hash; } session_pro_backend_pro_payment_item; @@ -195,8 +197,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( /// - `master_sig` - Master signature /// - `rotating_sig` - Rotating signature LIBSESSION_EXPORT -session_pro_backend_master_rotating_signatures -session_pro_backend_get_pro_proof_request_build_sigs( +session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof_request_build_sigs( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -280,8 +281,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_payments_request_to_json LIBSESSION_EXPORT session_pro_backend_add_pro_payment_or_get_pro_proof_response session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( - const char* json, - size_t json_len); + const char* json, size_t json_len); /// API: session_pro_backend/get_pro_revocations_response_parse /// @@ -293,9 +293,7 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( /// - `json_len` -- Length of the JSON string. LIBSESSION_EXPORT session_pro_backend_get_pro_revocations_response -session_pro_backend_get_pro_revocations_response_parse( - const char* json, - size_t json_len); +session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t json_len); /// API: session_pro_backend/get_pro_payments_response_parse /// @@ -306,10 +304,8 @@ session_pro_backend_get_pro_revocations_response_parse( /// - `json` -- JSON string to parse. /// - `json_len` -- Length of the JSON string. LIBSESSION_EXPORT -session_pro_backend_get_pro_payments_response -session_pro_backend_get_pro_payments_response_parse( - const char* json, - size_t json_len); +session_pro_backend_get_pro_payments_response session_pro_backend_get_pro_payments_response_parse( + const char* json, size_t json_len); /// API: session_pro_backend/to_json_free /// diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index dd04f8a2..1dec7bd4 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -312,7 +312,7 @@ struct ProPaymentItem { std::chrono::seconds subscription_duration; /// Store front that this particular payment came from - SESSION_PRO_PAYMENT_PROVIDER payment_provider; + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; /// 32-byte hash of the payment token array_uc32 payment_token_hash; @@ -340,5 +340,5 @@ struct GetProPaymentsResponse : public ResponseHeader { bool parse(std::string_view json); }; -void make_blake2b32_hasher(struct crypto_generichash_blake2b_state *hasher); +void make_blake2b32_hasher(struct crypto_generichash_blake2b_state* hasher); } // namespace session::pro_backend diff --git a/include/session/types.h b/include/session/types.h index 2f15889e..aaf72e26 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -18,7 +18,7 @@ struct string8 { size_t size; }; -#define string8_literal(literal) {(char *)literal, sizeof(literal) - 1} +#define string8_literal(literal) {(char*)literal, sizeof(literal) - 1} struct bytes32 { uint8_t data[32]; @@ -33,9 +33,8 @@ struct bytes64 { }; /// Basic bump allocating arena -struct arena_t -{ - uint8_t *data; +struct arena_t { + uint8_t* data; size_t size; size_t max; }; diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 2970c112..92787935 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -1,7 +1,7 @@ #include +#include #include #include -#include #include #include diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 55dc3f5a..f24fc140 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -2,13 +2,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include "SessionProtos.pb.h" @@ -18,7 +18,8 @@ namespace { // NOTE: Personalization data must match // https://github.com/Doy-lee/session-pro-backend/blob/2afe310adad52f211e3b2cfcbdfc9eda6ff1778e/backend.py#L156 constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALIZATION = "SeshProBackend__"; -static_assert(PRO_BACKEND_BLAKE2B_PERSONALIZATION.size() == crypto_generichash_blake2b_PERSONALBYTES); +static_assert( + PRO_BACKEND_BLAKE2B_PERSONALIZATION.size() == crypto_generichash_blake2b_PERSONALBYTES); const nlohmann::json json_parse(std::string_view json, std::vector& errors) { nlohmann::json result; @@ -33,7 +34,8 @@ const nlohmann::json json_parse(std::string_view json, std::vector& template const T json_require( const nlohmann::json& j, std::string_view key, std::vector& errors) { - T result = {};; + T result = {}; + ; auto it = j.find(key); if (it == j.end()) { errors.push_back(fmt::format("Key '{}' is missing", key)); @@ -66,8 +68,7 @@ const T json_require( return result; } -void parse_json_response_errors(const nlohmann::json& j, std::vector& errors) -{ +void parse_json_response_errors(const nlohmann::json& j, std::vector& errors) { const auto& array = json_require(j, "errors", errors); errors.reserve(errors.size() + array.size()); for (size_t index = 0; index < array.size(); index++) { @@ -75,12 +76,11 @@ void parse_json_response_errors(const nlohmann::json& j, std::vector()); } else { - errors.push_back( - fmt::format( - "Aborting parse, 'result.errors[{}]' was not a string " - "error: '{}'", - index, - it.dump(1))); + errors.push_back(fmt::format( + "Aborting parse, 'result.errors[{}]' was not a string " + "error: '{}'", + index, + it.dump(1))); break; } } @@ -97,13 +97,12 @@ bool json_require_fixed_bytes_from_hex( size_t hex_avail = dest.size() * 2; if (hex.size() != hex_avail) { - errors.push_back( - fmt::format( - "Hex -> bytes failed ({}, {}). {} hex chars capacity (requires {})", - key, - hex, - hex_avail, - hex.size())); + errors.push_back(fmt::format( + "Hex -> bytes failed ({}, {}). {} hex chars capacity (requires {})", + key, + hex, + hex_avail, + hex.size())); return false; } @@ -164,9 +163,13 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( make_blake2b32_hasher(&state); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( - &state, master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); + &state, + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( - &state, rotating_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); + &state, + rotating_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update(&state, payment_token_hash.data(), payment_token_hash.size()); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); @@ -326,11 +329,8 @@ bool GetProRevocationsResponse::parse(std::string_view json) { for (size_t index = 0; index < array.size(); index++) { const auto& it = array[index]; if (!it.is_object()) { - errors.push_back( - fmt::format( - "Aborting parse, 'items[{}]' was not an object: {}", - index, - it.dump(1))); + errors.push_back(fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", index, it.dump(1))); break; } @@ -340,8 +340,7 @@ bool GetProRevocationsResponse::parse(std::string_view json) { ProRevocationItem item = {}; item.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts)); - json_require_fixed_bytes_from_hex( - obj, "gen_index_hash", errors, item.gen_index_hash); + json_require_fixed_bytes_from_hex(obj, "gen_index_hash", errors, item.gen_index_hash); // Handle parsing result if (errors.size()) @@ -386,7 +385,9 @@ array_uc64 GetProPaymentsRequest::build_sig( make_blake2b32_hasher(&state); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( - &state, master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); + &state, + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); crypto_generichash_blake2b_update( @@ -433,33 +434,33 @@ bool GetProPaymentsResponse::parse(std::string_view json) { for (size_t index = 0; index < array.size(); index++) { const auto& it = array[index]; if (!it.is_object()) { - errors.push_back( - fmt::format( - "Aborting parse, 'items[{}]' was not an object: {}", - index, - it.dump(1))); + errors.push_back(fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", index, it.dump(1))); break; } // Parse payment item - auto obj = it.get(); - auto activation_ts = json_require(obj, "activation_unix_ts_s", errors); - auto archive_ts = json_require(obj, "archive_unix_ts_s", errors); - auto creation_ts = json_require(obj, "creation_unix_ts_s", errors); - auto sub_duration_s = json_require(obj, "subscription_duration_s", errors); + auto obj = it.get(); + auto activation_ts = json_require(obj, "activation_unix_ts_s", errors); + auto archive_ts = json_require(obj, "archive_unix_ts_s", errors); + auto creation_ts = json_require(obj, "creation_unix_ts_s", errors); + auto sub_duration_s = json_require(obj, "subscription_duration_s", errors); auto payment_provider = json_require(obj, "payment_provider", errors); - ProPaymentItem item = {}; - item.activation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activation_ts)); - item.archive_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(archive_ts)); - item.creation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(creation_ts)); + ProPaymentItem item = {}; + item.activation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activation_ts)); + item.archive_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(archive_ts)); + item.creation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(creation_ts)); item.subscription_duration = std::chrono::seconds(sub_duration_s); - json_require_fixed_bytes_from_hex(obj, "payment_token_hash", errors, item.payment_token_hash); - if (payment_provider > SESSION_PRO_PAYMENT_PROVIDER_NIL && - payment_provider < SESSION_PRO_PAYMENT_PROVIDER_COUNT) { - item.payment_provider = static_cast(payment_provider); + json_require_fixed_bytes_from_hex( + obj, "payment_token_hash", errors, item.payment_token_hash); + if (payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL && + payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { + item.payment_provider = + static_cast(payment_provider); } else { - errors.push_back(fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); + errors.push_back( + fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); } // Handle parsing result @@ -471,8 +472,7 @@ bool GetProPaymentsResponse::parse(std::string_view json) { return errors.empty(); } -void make_blake2b32_hasher(crypto_generichash_blake2b_state *hasher) -{ +void make_blake2b32_hasher(crypto_generichash_blake2b_state* hasher) { crypto_generichash_blake2b_init_salt_personal( hasher, /*key*/ nullptr, @@ -490,7 +490,7 @@ using namespace session::pro_backend; #define STRING8_LIT(val) {(char*)val, sizeof(val) - 1} static string8 C_PARSE_ERROR_OUT_OF_MEMORY = STRING8_LIT("Ran out-of-memory creating C response"); -static string8 C_PARSE_ERROR_INVALID_ARGS = STRING8_LIT("One or more C arguments were NULL"); +static string8 C_PARSE_ERROR_INVALID_ARGS = STRING8_LIT("One or more C arguments were NULL"); LIBSESSION_C_API session_pro_backend_master_rotating_signatures session_pro_backend_add_pro_payment_request_build_sigs( @@ -564,8 +564,7 @@ session_pro_backend_get_pro_payments_request_build_sig( const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_s, - uint32_t page) -{ + uint32_t page) { // Convert C inputs to C++ types std::span master_span{master_privkey, master_privkey_len}; std::chrono::sys_seconds ts{std::chrono::seconds(unix_ts_s)}; @@ -596,24 +595,11 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment // Construct C++ struct AddProPaymentRequest cpp = {}; cpp.version = request->version; - std::memcpy( - cpp.master_pkey.data(), - request->master_pkey.data, - cpp.master_pkey.size()); - std::memcpy( - cpp.rotating_pkey.data(), - request->rotating_pkey.data, - cpp.rotating_pkey.size()); - std::memcpy( - cpp.payment_token.data(), - request->payment_token.data, - cpp.payment_token.size()); - std::memcpy( - cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); - std::memcpy( - cpp.rotating_sig.data(), - request->rotating_sig.data, - cpp.rotating_sig.size()); + std::memcpy(cpp.master_pkey.data(), request->master_pkey.data, cpp.master_pkey.size()); + std::memcpy(cpp.rotating_pkey.data(), request->rotating_pkey.data, cpp.rotating_pkey.size()); + std::memcpy(cpp.payment_token.data(), request->payment_token.data, cpp.payment_token.size()); + std::memcpy(cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); + std::memcpy(cpp.rotating_sig.data(), request->rotating_sig.data, cpp.rotating_sig.size()); try { std::string json = cpp.to_json(); @@ -634,23 +620,11 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_r // Construct C++ struct GetProProofRequest cpp; cpp.version = request->version; - std::memcpy( - cpp.master_pkey.data(), - request->master_pkey.data, - cpp.master_pkey.size()); - std::memcpy( - cpp.rotating_pkey.data(), - request->rotating_pkey.data, - cpp.rotating_pkey.size()); + std::memcpy(cpp.master_pkey.data(), request->master_pkey.data, cpp.master_pkey.size()); + std::memcpy(cpp.rotating_pkey.data(), request->rotating_pkey.data, cpp.rotating_pkey.size()); cpp.unix_ts = std::chrono::seconds{request->unix_ts_s}; - std::memcpy( - cpp.master_sig.data(), - request->master_sig.data, - cpp.master_sig.size()); - std::memcpy( - cpp.rotating_sig.data(), - request->rotating_sig.data, - cpp.rotating_sig.size()); + std::memcpy(cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); + std::memcpy(cpp.rotating_sig.data(), request->rotating_sig.data, cpp.rotating_sig.size()); try { std::string json = cpp.to_json(); @@ -662,7 +636,8 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_r return result; } -LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_json( +LIBSESSION_C_API session_pro_backend_to_json +session_pro_backend_get_pro_revocations_request_to_json( const session_pro_backend_get_pro_revocations_request* request) { session_pro_backend_to_json result = {}; if (!request) @@ -693,13 +668,8 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_payment GetProPaymentsRequest cpp = {}; cpp.version = request->version; std::memcpy( - cpp.master_pkey.data(), - request->master_pkey.data, - sizeof(request->master_pkey.data)); - std::memcpy( - cpp.master_sig.data(), - request->master_sig.data, - sizeof(request->master_sig.data)); + cpp.master_pkey.data(), request->master_pkey.data, sizeof(request->master_pkey.data)); + std::memcpy(cpp.master_sig.data(), request->master_sig.data, sizeof(request->master_sig.data)); cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{request->unix_ts_s}}; cpp.page = request->page; @@ -749,8 +719,8 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( } // Copy to C struct, this is guaranteed not to fail because we pre-allocated memory upfront. - // Note that a response error and success case folds into the same code path. A success and error - // response returns the same struct just with different fields populated. + // Note that a response error and success case folds into the same code path. A success and + // error response returns the same struct just with different fields populated. result.header.status = cpp.status; result.proof.version = cpp.proof.version; result.proof.expiry_unix_ts_s = @@ -822,8 +792,8 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t // Copy errors result.header.errors_count = cpp.errors.size(); - result.header.errors = - (string8*)arena_alloc(&arena, result.header.errors_count * sizeof(*result.header.errors)); + result.header.errors = (string8*)arena_alloc( + &arena, result.header.errors_count * sizeof(*result.header.errors)); for (size_t index = 0; index < cpp.errors.size(); index++) { const std::string& it = cpp.errors[index]; result.header.errors[index] = arena_alloc_to_string8(&arena, it.data(), it.size()); @@ -845,8 +815,8 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t return result; } -LIBSESSION_C_API session_pro_backend_get_pro_payments_response session_pro_backend_get_pro_payments_response_parse( - const char* json, size_t json_len) { +LIBSESSION_C_API session_pro_backend_get_pro_payments_response +session_pro_backend_get_pro_payments_response_parse(const char* json, size_t json_len) { session_pro_backend_get_pro_payments_response result = {}; if (!json) { result.header.status = 1; @@ -897,14 +867,14 @@ LIBSESSION_C_API session_pro_backend_get_pro_payments_response session_pro_backe const ProPaymentItem& src = cpp.items[index]; session_pro_backend_pro_payment_item& dest = result.items[index]; dest.activation_unix_ts_s = std::chrono::duration_cast( - src.activation_unix_ts.time_since_epoch()) - .count(); + src.activation_unix_ts.time_since_epoch()) + .count(); dest.archive_unix_ts_s = std::chrono::duration_cast( - src.archive_unix_ts.time_since_epoch()) - .count(); + src.archive_unix_ts.time_since_epoch()) + .count(); dest.creation_unix_ts_s = std::chrono::duration_cast( - src.creation_unix_ts.time_since_epoch()) - .count(); + src.creation_unix_ts.time_since_epoch()) + .count(); dest.subscription_duration = std::chrono::duration_cast(src.subscription_duration).count(); dest.payment_provider = src.payment_provider; @@ -916,8 +886,8 @@ LIBSESSION_C_API session_pro_backend_get_pro_payments_response session_pro_backe // Copy errors result.header.errors_count = cpp.errors.size(); - result.header.errors = - (string8*)arena_alloc(&arena, result.header.errors_count * sizeof(*result.header.errors)); + result.header.errors = (string8*)arena_alloc( + &arena, result.header.errors_count * sizeof(*result.header.errors)); for (size_t index = 0; index < cpp.errors.size(); index++) { const std::string& it = cpp.errors[index]; result.header.errors[index] = arena_alloc_to_string8(&arena, it.data(), it.size()); diff --git a/src/types.cpp b/src/types.cpp index c48f18a3..ea1f2bad 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -31,8 +31,7 @@ int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, . return result; } -string8 string8_alloc_or_throw(size_t size) -{ +string8 string8_alloc_or_throw(size_t size) { string8 result = {}; result.size = size; result.data = static_cast(malloc(size + 1 /*null-terminator*/)); @@ -43,8 +42,7 @@ string8 string8_alloc_or_throw(size_t size) return result; } -string8 string8_copy_or_throw(const void *data, size_t size) -{ +string8 string8_copy_or_throw(const void* data, size_t size) { string8 result = string8_alloc_or_throw(size); std::memcpy(result.data, data, result.size); result.data[result.size] = 0; diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 81737d10..cc595038 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -26,21 +26,24 @@ static bool string8_equals(string8 s8, std::string_view str) { fprintf(stderr, "proof.sig: %s\n", oxenc::to_hex(proof.sig.data).c_str()); } -[[maybe_unused]] static void dump_pro_payment_item(const session_pro_backend_pro_payment_item& item) { +[[maybe_unused]] static void dump_pro_payment_item( + const session_pro_backend_pro_payment_item& item) { fprintf(stderr, "item.activation_unix_ts_s: %zu\n", item.activation_unix_ts_s); fprintf(stderr, "item.archive_unix_ts_s: %zu\n", item.archive_unix_ts_s); fprintf(stderr, "item.creation_unix_ts_s: %zu\n", item.creation_unix_ts_s); fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration); fprintf(stderr, "item.payment_provider: %u\n", item.payment_provider); - fprintf(stderr, "item.payment_token_hash: %s\n", oxenc::to_hex(item.payment_token_hash.data).c_str()); + fprintf(stderr, + "item.payment_token_hash: %s\n", + oxenc::to_hex(item.payment_token_hash.data).c_str()); } -[[maybe_unused]] static void dump_pro_revocation(const session_pro_backend_pro_revocation_item& item) { +[[maybe_unused]] static void dump_pro_revocation( + const session_pro_backend_pro_revocation_item& item) { fprintf(stderr, "item.expiry_unix_ts: %zu\n", item.expiry_unix_ts_s); fprintf(stderr, "item.gen_index_hash: %s\n", oxenc::to_hex(item.gen_index_hash.data).c_str()); } - #if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) #include @@ -87,7 +90,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { bytes32 payment_token_hash; randombytes_buf(payment_token_hash.data, sizeof(payment_token_hash.data)); - uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp + uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp SECTION("session_pro_backend_add_pro_payment_request_build_sigs") { // Valid inputs @@ -292,7 +295,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_payments_request request = {}; request.version = 0; request.master_pkey = master_pubkey; - request.master_sig = master_privkey; // Write some junk + request.master_sig = master_privkey; // Write some junk request.unix_ts_s = unix_ts_s; request.page = 1; @@ -328,12 +331,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { nlohmann::json j; j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { - {"version", 0}, - {"expiry_unix_ts_s", unix_ts_s}, - {"gen_index_hash", oxenc::to_hex(payment_token_hash.data)}, - {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, - {"sig", oxenc::to_hex(master_privkey.data)} - }; + {"version", 0}, + {"expiry_unix_ts_s", unix_ts_s}, + {"gen_index_hash", oxenc::to_hex(payment_token_hash.data)}, + {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, + {"sig", oxenc::to_hex(master_privkey.data)}}; std::string json = j.dump(); // Valid JSON @@ -389,7 +391,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Invalid JSON json = "{invalid}"; - result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(json.data(), json.size()); + result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + json.data(), json.size()); REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count > 0); REQUIRE(result.header.errors != nullptr); @@ -420,7 +423,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string json = j.dump(); // Valid JSON - auto result = session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); + auto result = + session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); for (size_t index = 0; index < result.header.errors_count; index++) INFO(result.header.errors[index].data); REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); @@ -463,19 +467,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { nlohmann::json j; j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { - {"pages", 2}, - {"payments", 10}, - {"items", nlohmann::json::array({ - { - {"activation_unix_ts_s", unix_ts_s}, - {"archive_unix_ts_s", unix_ts_s + 3600}, - {"creation_unix_ts_s", unix_ts_s - 3600}, - {"subscription_duration_s", 86400}, - {"payment_provider", SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, - {"payment_token_hash", oxenc::to_hex(payment_token_hash.data)} - } - })} - }; + {"pages", 2}, + {"payments", 10}, + {"items", + nlohmann::json::array( + {{{"activation_unix_ts_s", unix_ts_s}, + {"archive_unix_ts_s", unix_ts_s + 3600}, + {"creation_unix_ts_s", unix_ts_s - 3600}, + {"subscription_duration_s", 86400}, + {"payment_provider", + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, + {"payment_token_hash", oxenc::to_hex(payment_token_hash.data)}}})}}; std::string json = j.dump(); // Valid JSON @@ -490,8 +492,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.items_count == 1); REQUIRE(result.items != nullptr); REQUIRE(result.items[0].activation_unix_ts_s == unix_ts_s); - REQUIRE(result.items[0].payment_provider > SESSION_PRO_PAYMENT_PROVIDER_NIL); - REQUIRE(result.items[0].payment_provider < SESSION_PRO_PAYMENT_PROVIDER_COUNT); + REQUIRE(result.items[0].payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL); + REQUIRE(result.items[0].payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT); REQUIRE(result.items[0].archive_unix_ts_s == unix_ts_s + 3600); REQUIRE(result.items[0].creation_unix_ts_s == unix_ts_s - 3600); REQUIRE(result.items[0].subscription_duration == 86400); From 7fcbc19df92cf258091e7635dd8deded2b05824c Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 28 Aug 2025 16:12:40 +1000 Subject: [PATCH 076/171] Make parsing a static function --- include/session/pro_backend.hpp | 6 +- src/pro_backend.cpp | 160 ++++++++++++++++---------------- tests/test_pro_backend.cpp | 3 +- 3 files changed, 86 insertions(+), 83 deletions(-) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 1dec7bd4..6aaed377 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -145,7 +145,7 @@ struct AddProPaymentOrGetProProofResponse : public ResponseHeader { /// /// Outputs: /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. - bool parse(std::string_view json); + static AddProPaymentOrGetProProofResponse parse(std::string_view json); }; /// Request a new Session Pro proof from the backend. The specified `master_pkey` must have @@ -248,7 +248,7 @@ struct GetProRevocationsResponse : public ResponseHeader { /// /// Outputs: /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. - bool parse(std::string_view json); + static GetProRevocationsResponse parse(std::string_view json); }; struct GetProPaymentsRequest { @@ -337,7 +337,7 @@ struct GetProPaymentsResponse : public ResponseHeader { /// /// Outputs: /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. - bool parse(std::string_view json); + static GetProPaymentsResponse parse(std::string_view json); }; void make_blake2b32_hasher(struct crypto_generichash_blake2b_state* hasher); diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index f24fc140..af90585d 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -190,36 +190,36 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( return result; } -bool AddProPaymentOrGetProProofResponse::parse(std::string_view json) { +AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse(std::string_view json) { // Parse basics - *this = {}; - nlohmann::json j = json_parse(json, errors); - status = json_require(j, "status", errors); - if (errors.size()) { - status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; - return errors.empty(); + AddProPaymentOrGetProProofResponse result = {}; + nlohmann::json j = json_parse(json, result.errors); + result.status = json_require(j, "status", result.errors); + if (result.errors.size()) { + result.status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return result; } // Parse errors - if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { - parse_json_response_errors(j, errors); - return false; + if (result.status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, result.errors); + return result; } - auto result_obj = json_require(j, "result", errors); - if (errors.size()) - return errors.empty(); + auto result_obj = json_require(j, "result", result.errors); + if (result.errors.size()) + return result; // Parse payload - proof.version = json_require(result_obj, "version", errors); - auto expiry_unix_ts_s = json_require(result_obj, "expiry_unix_ts_s", errors); - proof.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); + result.proof.version = json_require(result_obj, "version", result.errors); + auto expiry_unix_ts_s = json_require(result_obj, "expiry_unix_ts_s", result.errors); + result.proof.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); json_require_fixed_bytes_from_hex( - result_obj, "gen_index_hash", errors, proof.gen_index_hash); + result_obj, "gen_index_hash", result.errors, result.proof.gen_index_hash); json_require_fixed_bytes_from_hex( - result_obj, "rotating_pkey", errors, proof.rotating_pubkey); - json_require_fixed_bytes_from_hex(result_obj, "sig", errors, proof.sig); - return errors.empty(); + result_obj, "rotating_pkey", result.errors, result.proof.rotating_pubkey); + json_require_fixed_bytes_from_hex(result_obj, "sig", result.errors, result.proof.sig); + return result; } std::string GetProProofRequest::to_json() const { @@ -301,54 +301,58 @@ std::string GetProRevocationsRequest::to_json() const { return result; } -bool GetProRevocationsResponse::parse(std::string_view json) { +GetProRevocationsResponse GetProRevocationsResponse::parse(std::string_view json) { // Parse basics - *this = {}; - nlohmann::json j = json_parse(json, errors); - status = json_require(j, "status", errors); - if (errors.size()) { - status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; - return errors.empty(); + GetProRevocationsResponse result = {}; + nlohmann::json j = json_parse(json, result.errors); + result.status = json_require(j, "status", result.errors); + if (result.errors.size()) { + result.status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return result; } // Parse errors - if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { - parse_json_response_errors(j, errors); - return false; + if (result.status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, result.errors); + return result; } - auto result_obj = json_require(j, "result", errors); - if (errors.size()) - return errors.empty(); + auto result_obj = json_require(j, "result", result.errors); + if (result.errors.size()) + return result; // Parse payload - ticket = json_require(result_obj, "ticket", errors); + result.ticket = json_require(result_obj, "ticket", result.errors); - auto array = json_require(result_obj, "items", errors); - items.reserve(array.size()); + auto array = json_require(result_obj, "items", result.errors); + result.items.reserve(array.size()); for (size_t index = 0; index < array.size(); index++) { const auto& it = array[index]; if (!it.is_object()) { - errors.push_back(fmt::format( - "Aborting parse, 'items[{}]' was not an object: {}", index, it.dump(1))); + result.errors.push_back( + fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", + index, + it.dump(1))); break; } // Parse revocation item auto obj = it.get(); - auto expiry_unix_ts = json_require(obj, "expiry_unix_ts_s", errors); + auto expiry_unix_ts = json_require(obj, "expiry_unix_ts_s", result.errors); ProRevocationItem item = {}; item.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts)); - json_require_fixed_bytes_from_hex(obj, "gen_index_hash", errors, item.gen_index_hash); + json_require_fixed_bytes_from_hex( + obj, "gen_index_hash", result.errors, item.gen_index_hash); // Handle parsing result - if (errors.size()) + if (result.errors.size()) break; - items.emplace_back(std::move(item)); + result.items.emplace_back(std::move(item)); } - return errors.empty(); + return result; } std::string GetProPaymentsRequest::to_json() const { @@ -405,47 +409,50 @@ array_uc64 GetProPaymentsRequest::build_sig( return result; } -bool GetProPaymentsResponse::parse(std::string_view json) { +GetProPaymentsResponse GetProPaymentsResponse::parse(std::string_view json) { // Parse basics - *this = {}; - nlohmann::json j = json_parse(json, errors); - status = json_require(j, "status", errors); - if (errors.size()) { - status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; - return errors.empty(); + GetProPaymentsResponse result = {}; + nlohmann::json j = json_parse(json, result.errors); + result.status = json_require(j, "status", result.errors); + if (result.errors.size()) { + result.status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return result; } // Parse errors - if (status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { - parse_json_response_errors(j, errors); - return false; + if (result.status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, result.errors); + return result; } - auto result_obj = json_require(j, "result", errors); - if (errors.size()) - return errors.empty(); + auto result_obj = json_require(j, "result", result.errors); + if (result.errors.size()) + return result; // Parse payload - pages = json_require(result_obj, "pages", errors); - payments = json_require(result_obj, "payments", errors); + result.pages = json_require(result_obj, "pages", result.errors); + result.payments = json_require(result_obj, "payments", result.errors); - auto array = json_require(result_obj, "items", errors); - items.reserve(array.size()); + auto array = json_require(result_obj, "items", result.errors); + result.items.reserve(array.size()); for (size_t index = 0; index < array.size(); index++) { const auto& it = array[index]; if (!it.is_object()) { - errors.push_back(fmt::format( - "Aborting parse, 'items[{}]' was not an object: {}", index, it.dump(1))); + result.errors.push_back( + fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", + index, + it.dump(1))); break; } // Parse payment item auto obj = it.get(); - auto activation_ts = json_require(obj, "activation_unix_ts_s", errors); - auto archive_ts = json_require(obj, "archive_unix_ts_s", errors); - auto creation_ts = json_require(obj, "creation_unix_ts_s", errors); - auto sub_duration_s = json_require(obj, "subscription_duration_s", errors); - auto payment_provider = json_require(obj, "payment_provider", errors); + auto activation_ts = json_require(obj, "activation_unix_ts_s", result.errors); + auto archive_ts = json_require(obj, "archive_unix_ts_s", result.errors); + auto creation_ts = json_require(obj, "creation_unix_ts_s", result.errors); + auto sub_duration_s = json_require(obj, "subscription_duration_s", result.errors); + auto payment_provider = json_require(obj, "payment_provider", result.errors); ProPaymentItem item = {}; item.activation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activation_ts)); @@ -453,23 +460,23 @@ bool GetProPaymentsResponse::parse(std::string_view json) { item.creation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(creation_ts)); item.subscription_duration = std::chrono::seconds(sub_duration_s); json_require_fixed_bytes_from_hex( - obj, "payment_token_hash", errors, item.payment_token_hash); + obj, "payment_token_hash", result.errors, item.payment_token_hash); if (payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL && payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { item.payment_provider = static_cast(payment_provider); } else { - errors.push_back( + result.errors.push_back( fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); } // Handle parsing result - if (errors.size()) + if (result.errors.size()) break; - items.emplace_back(std::move(item)); + result.items.emplace_back(std::move(item)); } - return errors.empty(); + return result; } void make_blake2b32_hasher(crypto_generichash_blake2b_state* hasher) { @@ -695,8 +702,7 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( } // Note, parse is written to not throw so we can safely read without try-catch crap - AddProPaymentOrGetProProofResponse cpp = {}; - cpp.parse({json, json_len}); + auto cpp = AddProPaymentOrGetProProofResponse::parse({json, json_len}); // Calculate how much memory we need and create an arena arena_t arena = {}; @@ -758,8 +764,7 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t } // Note, parse is written to not throw so we can safely read without try-catch crap - GetProRevocationsResponse cpp = {}; - cpp.parse({json, json_len}); + GetProRevocationsResponse cpp = GetProRevocationsResponse::parse({json, json_len}); // Calculate how much memory we need and create an arena arena_t arena = {}; @@ -826,8 +831,7 @@ session_pro_backend_get_pro_payments_response_parse(const char* json, size_t jso } // Note, parse is written to not throw so we can safely read without try-catch crap - GetProPaymentsResponse cpp = {}; - cpp.parse({json, json_len}); + auto cpp = GetProPaymentsResponse::parse({json, json_len}); // Calculate how much memory we need and create an arena arena_t arena = {}; diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index cc595038..13d85e0e 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -363,8 +363,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Here we also create the CPP version, we will run the conversion functions into pro proofs // (both C and CPP variants) and then compare the two structures to make sure the conversion // functions are sound. - AddProPaymentOrGetProProofResponse result_cpp = {}; - REQUIRE(result_cpp.parse(json)); + auto result_cpp = AddProPaymentOrGetProProofResponse::parse(json); // Validate C and CPP variants REQUIRE(result.proof.version == result_cpp.proof.version); From 686eb0a0edc0f6c5267c96184d7f85ca011b2fb7 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 13:40:43 +1000 Subject: [PATCH 077/171] Remove duplicated recipient pubkey field --- include/session/session_protocol.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index ca49df6d..1cbbec5d 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -188,10 +188,6 @@ struct Destination { // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; - // - // When type => (CommunityInbox || SyncMessage || Contact): set to the recipient's Session - // public key - array_uc33 recipient_pubkey; // When type => CommunityInbox: set this pubkey to the server's key array_uc32 community_inbox_server_pubkey; From 2b2ee15f4b306503e4d6f05b96672afc00261dba Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 15:16:41 +1000 Subject: [PATCH 078/171] Add UTF8/UTF16 codepoint count via new simdutf submodule --- .gitmodules | 3 ++ external/CMakeLists.txt | 11 ++++ external/simdutf | 1 + include/session/session_protocol.h | 62 +++++++++++++++++------ include/session/session_protocol.hpp | 11 ++++ src/CMakeLists.txt | 1 + src/pro_backend.cpp | 17 +++---- src/session_protocol.cpp | 75 +++++++++++++++++++++++----- tests/test_session_protocol.cpp | 57 +++++++++++++++------ 9 files changed, 185 insertions(+), 53 deletions(-) create mode 160000 external/simdutf diff --git a/.gitmodules b/.gitmodules index e3b3ed5e..8d314998 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 = git@github.com:simdutf/simdutf.git diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 5506fd41..56268c77 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -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() diff --git a/external/simdutf b/external/simdutf new file mode 160000 index 00000000..7b3f5afc --- /dev/null +++ b/external/simdutf @@ -0,0 +1 @@ +Subproject commit 7b3f5afcae322391a03736809ef6eea0c2934388 diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index b4bf8f9d..47bd9638 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -13,17 +13,12 @@ extern "C" { #endif enum { - /// TODO: This comment needs to be updated to be _codepoints_ once libsession implements the - /// character count for the platforms. Currently they use code units but it should be - /// codepoints. This allows the platforms to use their native text representation up until the - /// API boundary where they will convert to UTF8 to have it managed by libsession. - - /// Maximum number of UTF16 code units that a standard message can use. If the message exceeds + /// Maximum number of UTF16 code points that a standard message can use. If the message exceeds /// this then the message must activate the higher character limit feature provided by Session /// Pro which allows messages up to 10k characters. PRO_STANDARD_CHARACTER_LIMIT = 2'000, - /// Maximum number of UTF16 code units that a Session Pro entitled user can send in a message. + /// Maximum number of UTF16 code points that a Session Pro entitled user can send in a message. /// This is not used in the codebase, but is provided for convenience to centralise protocol /// definitions for users of the library to consume. PRO_HIGHER_CHARACTER_LIMIT = 10'000, @@ -237,20 +232,58 @@ LIBSESSION_EXPORT PRO_STATUS pro_proof_status( const pro_signed_message* signed_msg); /// API: session_protocol/session_protocol_get_pro_features_for_msg +typedef struct session_protocol_pro_features_for_msg { + bool success; + string8 error; + PRO_FEATURES features; + size_t codepoint_count; +} session_protocol_pro_features_for_msg; + +/// API: session_protocol/session_protocol_get_pro_features_for_utf8 +/// +/// Determine the Pro features that are used in a given UTF8 message. +/// +/// Inputs: +/// - `utf8` -- the utf8 string to count the number of codepoints in to determine if it needs the +/// higher character limit available in Session Pro +/// - `utf8_size` -- the number of code units (aka. bytes) the string has +/// - `flags` -- extra pro features that are known by clients that they wish to be activated on +/// this message +/// +/// Outputs: +/// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. +/// When false, all fields except for `error` should be ignored from the result object. +/// - `error` -- If `success` is false, this is populated with an error code describing the error, +// otherwise it's empty. +/// - `features` -- Session Pro feature flags suitable for writing directly into the protobuf +/// `ProMessage` in `Content` +/// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. +LIBSESSION_EXPORT +session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( + char const* utf8, size_t utf8_size, PRO_EXTRA_FEATURES extra); + +/// API: session_protocol/session_protocol_get_pro_features_for_utf16 /// -/// Determine the Pro features that are used in a given conversation message. +/// Determine the Pro features that are used in a given UTF16 message. /// /// Inputs: -/// - `msg_size` -- the size of the message in UTF16 code units to determine if the message requires -/// access to the higher character limit available in Session Pro +/// - `utf8` -- the utf16 string to count the number of codepoints in to determine if it needs the +/// higher character limit available in Session Pro +/// - `utf16_size` -- the number of code units (aka. bytes) the string has /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// /// Outputs: -/// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in -/// `Content` +/// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. +/// When false, all fields except for `error` should be ignored from the result object. +/// - `error` -- If `success` is false, this is populated with an error code describing the error, +// otherwise it's empty. +/// - `features` -- Session Pro feature flags suitable for writing directly into the protobuf +/// `ProMessage` in `Content` +/// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT -PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); +session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( + uint16_t const* utf16, size_t utf16_size, PRO_EXTRA_FEATURES extra); /// API: session_protocol_encrypt_for_1o1 /// @@ -391,8 +424,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit /// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. /// - `group_ed25519_pubkey` -- The group's public key (33 bytes) for encryption with a 0x03 prefix. /// - `group_ed25519_privkey` -- The group's private key (32 bytes) for groups v2 messages, -/// typically -/// the latest encryption key for the group (e.g., Keys::group_enc_key). +/// typically the latest encryption key for the group (e.g., Keys::group_enc_key). /// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro /// rotating public key, if using Session Pro features. If provided, the corresponding proof must /// be set in the Content protobuf. Pass NULL if not using Session Pro features. diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 1cbbec5d..1f020cac 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -168,6 +168,13 @@ class ProProof { array_uc32 hash() const; }; +struct ProFeaturesForMsg { + bool success; + std::string_view error; + PRO_FEATURES features; + size_t codepoint_count; +}; + enum class DestinationType { ContactOrSyncMessage = DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE, /// Both legacy and non-legacy groups are to be identified as `Group`. A non-legacy @@ -189,6 +196,10 @@ struct Destination { // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; + // When type => (CommunityInbox || SyncMessage || Contact): set to the recipient's Session + // public key + array_uc33 recipient_pubkey; + // When type => CommunityInbox: set this pubkey to the server's key array_uc32 community_inbox_server_pubkey; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cddcbe04..af9bd4bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,6 +95,7 @@ target_link_libraries(crypto libsodium::sodium-internal nlohmann_json::nlohmann_json libsession::protos + simdutf ) target_link_libraries(config diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index af90585d..55608609 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -190,7 +190,8 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( return result; } -AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse(std::string_view json) { +AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse( + std::string_view json) { // Parse basics AddProPaymentOrGetProProofResponse result = {}; nlohmann::json j = json_parse(json, result.errors); @@ -329,11 +330,8 @@ GetProRevocationsResponse GetProRevocationsResponse::parse(std::string_view json for (size_t index = 0; index < array.size(); index++) { const auto& it = array[index]; if (!it.is_object()) { - result.errors.push_back( - fmt::format( - "Aborting parse, 'items[{}]' was not an object: {}", - index, - it.dump(1))); + result.errors.push_back(fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", index, it.dump(1))); break; } @@ -438,11 +436,8 @@ GetProPaymentsResponse GetProPaymentsResponse::parse(std::string_view json) { for (size_t index = 0; index < array.size(); index++) { const auto& it = array[index]; if (!it.is_object()) { - result.errors.push_back( - fmt::format( - "Aborting parse, 'items[{}]' was not an object: {}", - index, - it.dump(1))); + result.errors.push_back(fmt::format( + "Aborting parse, 'items[{}]' was not an object: {}", index, it.dump(1))); break; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 5169e0c7..f64c02d2 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include @@ -132,19 +134,46 @@ array_uc32 ProProof::hash() const { return result; } -PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES extra) { - PRO_FEATURES result = PRO_FEATURES_NIL; - - if (msg_size > PRO_STANDARD_CHARACTER_LIMIT) - result |= PRO_FEATURES_10K_CHARACTER_LIMIT; +session::ProFeaturesForMsg pro_features_for_utf8_or_16( + const void* utf, size_t utf_size, PRO_EXTRA_FEATURES extra, bool is_utf8) { + session::ProFeaturesForMsg result = {}; + simdutf::result validate = is_utf8 ? simdutf::validate_utf8_with_errors( + reinterpret_cast(utf), utf_size) + : simdutf::validate_utf16_with_errors( + reinterpret_cast(utf), utf_size); + if (validate.is_ok()) { + result.success = true; + result.codepoint_count = + is_utf8 ? simdutf::count_utf8(reinterpret_cast(utf), utf_size) + : simdutf::count_utf16(reinterpret_cast(utf), utf_size); + if (result.codepoint_count > PRO_STANDARD_CHARACTER_LIMIT) + result.features |= PRO_FEATURES_10K_CHARACTER_LIMIT; + + if (extra & PRO_EXTRA_FEATURES_ANIMATED_AVATAR) + result.features |= PRO_FEATURES_ANIMATED_AVATAR; + + if (extra & PRO_EXTRA_FEATURES_PRO_BADGE) + result.features |= PRO_FEATURES_PRO_BADGE; + + assert((result.features & ~PRO_FEATURES_ALL) == 0); + } else { + result.error = simdutf::error_to_string(validate.error); + } + return result; +} +}; // namespace - if (extra & PRO_EXTRA_FEATURES_ANIMATED_AVATAR) - result |= PRO_FEATURES_ANIMATED_AVATAR; +namespace session { - if (extra & PRO_EXTRA_FEATURES_PRO_BADGE) - result |= PRO_FEATURES_PRO_BADGE; +ProFeaturesForMsg pro_features_for_utf8( + const char* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); + return result; +} - assert((result & ~PRO_FEATURES_ALL) == 0); +ProFeaturesForMsg pro_features_for_utf16( + const uint16_t* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); return result; } @@ -735,8 +764,30 @@ LIBSESSION_C_API PRO_STATUS pro_proof_status( } LIBSESSION_C_API -PRO_FEATURES session_protocol_get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags) { - PRO_FEATURES result = get_pro_features_for_msg(msg_size, flags); +session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( + const char* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + ProFeaturesForMsg result_cpp = + pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); + session_protocol_pro_features_for_msg result = { + .success = result_cpp.success, + .error = {const_cast(result_cpp.error.data()), result_cpp.error.size()}, + .features = result_cpp.features, + .codepoint_count = result_cpp.codepoint_count, + }; + return result; +} + +LIBSESSION_C_API +session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( + const uint16_t* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + ProFeaturesForMsg result_cpp = + pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); + session_protocol_pro_features_for_msg result = { + .success = result_cpp.success, + .error = {const_cast(result_cpp.error.data()), result_cpp.error.size()}, + .features = result_cpp.features, + .codepoint_count = result_cpp.codepoint_count, + }; return result; } diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 5e3e2bec..79346f39 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -91,21 +91,48 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Do tests that require no setup SECTION("Ensure get pro fetaures detects large message") { // Try a message below the size threshold - PRO_FEATURES features = session_protocol_get_pro_features_for_msg( - PRO_STANDARD_CHARACTER_LIMIT, - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); + { + auto msg = std::string(PRO_STANDARD_CHARACTER_LIMIT, 'a'); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), + msg.size(), + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(pro_msg.success); + REQUIRE(pro_msg.features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); + REQUIRE(pro_msg.codepoint_count == msg.size()); + } + + // Try an invalid message + { + std::string_view msg = "\xFF"; + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), msg.size(), PRO_FEATURES_NIL); + REQUIRE(!pro_msg.success); + REQUIRE(pro_msg.error.size); + } // Try a message exceeding the size threshold - features = session_protocol_get_pro_features_for_msg( - PRO_STANDARD_CHARACTER_LIMIT + 1, - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | - PRO_FEATURES_ANIMATED_AVATAR)); + { + auto msg = std::string(PRO_STANDARD_CHARACTER_LIMIT + 1, 'a'); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), + msg.size(), + PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(pro_msg.success); + REQUIRE(pro_msg.features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | + PRO_FEATURES_ANIMATED_AVATAR)); + REQUIRE(pro_msg.codepoint_count == msg.size()); + } // Try asking for just one extra feature - features = session_protocol_get_pro_features_for_msg(100, PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(features == PRO_FEATURES_PRO_BADGE); + { + auto msg = std::string(PRO_STANDARD_CHARACTER_LIMIT, 'a'); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), msg.size(), PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(pro_msg.success); + REQUIRE(pro_msg.features == PRO_FEATURES_PRO_BADGE); + REQUIRE(pro_msg.codepoint_count == msg.size()); + } } // Tests that require some setup code @@ -363,9 +390,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { std::string large_message; large_message.resize(PRO_STANDARD_CHARACTER_LIMIT + 1); - PRO_FEATURES features = - get_pro_features_for_msg(large_message.size(), PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + large_message.data(), large_message.size(), PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(pro_msg.features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); SerialisedProtobufContentWithProForTesting protobuf_content_with_pro_and_features = build_protobuf_content_with_session_pro( @@ -373,7 +400,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { /*user_rotating_privkey*/ user_pro_ed_sk, /*pro_backend_privkey*/ pro_backend_ed_sk, /*pro_expiry_unix_ts*/ timestamp_s, - features); + pro_msg.features); // Encrypt content session_protocol_encrypted_for_destination encrypt_result = From fb969ac83e1c60b5c769bf9d73bc30ac53dd4f1e Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 29 Aug 2025 15:48:40 +1000 Subject: [PATCH 079/171] Add type annotations in the C interface --- include/session/config/pro.h | 3 ++- include/session/pro_backend.h | 6 +++--- include/session/session_protocol.h | 28 ++++++++++++++-------------- include/session/types.h | 7 +++++++ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 8a65e0f8..8b6a5fa2 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -31,7 +31,8 @@ typedef struct pro_config { /// 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); + pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len) + NON_NULL_ARG(1, 2); #ifdef __cplusplus } // extern "C" diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index b08af6c0..2ca29eb9 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -174,7 +174,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( const uint8_t* rotating_privkey, size_t rotating_privkey_len, const uint8_t* payment_token_hash, - size_t payment_token_hash_len); + size_t payment_token_hash_len) NON_NULL_ARG(2, 4, 6); /// API: session_pro_backend/get_pro_proof_request_build_sigs /// @@ -203,7 +203,7 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof size_t master_privkey_len, const uint8_t* rotating_privkey, size_t rotating_privkey_len, - uint64_t unix_ts_s); + uint64_t unix_ts_s) NON_NULL_ARG(2, 4); /// API: session_pro_backend/get_pro_payments_request_build_sig /// @@ -229,7 +229,7 @@ session_pro_backend_signature session_pro_backend_get_pro_payments_request_build const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_s, - uint32_t page); + uint32_t page) NON_NULL_ARG(2); /// API: session_pro_backend/add_pro_payment_request_to_json /// diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 47bd9638..54f77f0a 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -260,7 +260,7 @@ typedef struct session_protocol_pro_features_for_msg { /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( - char const* utf8, size_t utf8_size, PRO_EXTRA_FEATURES extra); + char const* utf8, size_t utf8_size, PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); /// API: session_protocol/session_protocol_get_pro_features_for_utf16 /// @@ -283,7 +283,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( - uint16_t const* utf16, size_t utf16_size, PRO_EXTRA_FEATURES extra); + uint16_t const* utf16, size_t utf16_size, PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); /// API: session_protocol_encrypt_for_1o1 /// @@ -337,9 +337,9 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* recipient_pubkey, - const bytes64* pro_sig, - char* error, - size_t error_len); + OPTIONAL const bytes64* pro_sig, + OPTIONAL char* error, + size_t error_len) NON_NULL_ARG(1, 3, 6); /// API: session_protocol_encrypt_for_community_inbox /// @@ -398,9 +398,9 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit uint64_t sent_timestamp_ms, const bytes33* recipient_pubkey, const bytes32* community_pubkey, - const bytes64* pro_sig, - char* error, - size_t error_len); + OPTIONAL const bytes64* pro_sig, + OPTIONAL char* error, + size_t error_len) NON_NULL_ARG(1, 3, 6, 7); /// API: session_protocol_encrypt_for_group /// @@ -460,8 +460,8 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( const bytes33* group_ed25519_pubkey, const bytes32* group_ed25519_privkey, const bytes64* pro_sig, - char* error, - size_t error_len); + OPTIONAL char* error, + size_t error_len) NON_NULL_ARG(1, 3, 6, 7, 8); /// API: session_protocol/session_protocol_encrypt_for_destination /// @@ -510,8 +510,8 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, - char* error, - size_t error_len); + OPTIONAL char* error, + size_t error_len) NON_NULL_ARG(1, 3, 5); /// API: session_protocol/session_protocol_encrypt_for_destination_free /// @@ -604,8 +604,8 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( uint64_t unix_ts, const void* pro_backend_pubkey, size_t pro_backend_pubkey_len, - char* error, - size_t error_len); + OPTIONAL char* error, + size_t error_len) NON_NULL_ARG(1, 2, 5); /// API: session_protocol/session_protocol_decrypt_envelope_free /// diff --git a/include/session/types.h b/include/session/types.h index aaf72e26..0ba9ecc2 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -7,6 +7,13 @@ extern "C" { #endif +#define OPTIONAL +#if defined(_MSC_VER) + #define NON_NULL_ARG(...) +#else + #define NON_NULL_ARG(...) __attribute__((nonnull(__VA_ARGS__))) +#endif + /// C friendly buffer structure that is a pointer and length to a span of bytes. struct span_u8 { uint8_t* data; From f21850980097934f162221f4cea5ec636d385e46 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 3 Sep 2025 11:49:38 +1000 Subject: [PATCH 080/171] Update pro_features_for_utf* naming scheme, add read-only note on error string --- include/session/config/pro.h | 2 -- include/session/session_protocol.h | 16 +++++++------ include/session/session_protocol.hpp | 35 ++++++++++++++++++++++++---- include/session/types.h | 4 ++-- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 8b6a5fa2..896d1922 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -16,8 +16,6 @@ typedef struct pro_config { pro_proof proof; } pro_pro_config; -/// API: pro/pro_config_verify_signature -/// /// 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. /// diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 54f77f0a..8fc1602c 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -144,7 +144,7 @@ typedef struct session_protocol_encrypted_for_destination { /// /// Outputs: /// - `bytes32` -- The 32 byte hash calculated from the proof -LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); +LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof) NON_NULL_ARG(1); /// API: pro/pro_proof_verify_signature /// @@ -160,7 +160,8 @@ LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof); /// Outputs: /// - `bool` -- True if verified, false otherwise LIBSESSION_EXPORT bool pro_proof_verify_signature( - pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len); + pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) + NON_NULL_ARG(1, 2); /// API: pro/pro_proof_verify_message /// @@ -183,7 +184,7 @@ LIBSESSION_EXPORT bool pro_proof_verify_message( uint8_t const* sig, size_t sig_len, uint8_t const* msg, - size_t msg_len); + size_t msg_len) NON_NULL_ARG(1, 2, 4); /// API: pro/pro_proof_is_active /// @@ -196,7 +197,8 @@ LIBSESSION_EXPORT bool pro_proof_verify_message( /// /// Outputs: /// - `bool` -- True if expired, false otherwise -LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s); +LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) + NON_NULL_ARG(1); /// API: pro/pro_proof_status /// @@ -229,7 +231,7 @@ LIBSESSION_EXPORT PRO_STATUS pro_proof_status( const uint8_t* verify_pubkey, size_t verify_pubkey_len, uint64_t unix_ts_s, - const pro_signed_message* signed_msg); + OPTIONAL const pro_signed_message* signed_msg) NON_NULL_ARG(1, 2); /// API: session_protocol/session_protocol_get_pro_features_for_msg typedef struct session_protocol_pro_features_for_msg { @@ -254,7 +256,7 @@ typedef struct session_protocol_pro_features_for_msg { /// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. /// When false, all fields except for `error` should be ignored from the result object. /// - `error` -- If `success` is false, this is populated with an error code describing the error, -// otherwise it's empty. +/// otherwise it's empty. This string is read-only and should not be modified. /// - `features` -- Session Pro feature flags suitable for writing directly into the protobuf /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. @@ -277,7 +279,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. /// When false, all fields except for `error` should be ignored from the result object. /// - `error` -- If `success` is false, this is populated with an error code describing the error, -// otherwise it's empty. +/// otherwise it's empty. /// - `features` -- Session Pro feature flags suitable for writing directly into the protobuf /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 1f020cac..e2d124a0 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -283,7 +283,28 @@ struct DecryptEnvelopeKey { std::span> ed25519_privkeys; }; -/// API: session_protocol/get_pro_features_for_msg +/// API: session_protocol/pro_features_for_utf8 +/// +/// Determine the Pro features that are used in a given conversation message. +/// +/// Inputs: +/// - `msg_size` -- the size of the message in UTF8 code units to determine if the message requires +/// access to the higher character limit available in Session Pro +/// - `flags` -- extra pro features that are known by clients that they wish to be activated on +/// this message +/// +/// Outputs: +/// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. +/// When false, all fields except for `error` should be ignored from the result object. +/// - `error` -- If `success` is false, this is populated with an error code describing the error, +/// otherwise it's empty. This string is read-only and should not be modified. +/// - `features` -- Session Pro feature flags suitable for writing directly into the protobuf +/// `ProMessage` in `Content` +/// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. +ProFeaturesForMsg pro_features_for_utf8( + char const* utf8, size_t utf8_size, PRO_EXTRA_FEATURES flags); + +/// API: session_protocol/pro_features_for_utf16 /// /// Determine the Pro features that are used in a given conversation message. /// @@ -294,9 +315,15 @@ struct DecryptEnvelopeKey { /// this message /// /// Outputs: -/// - Session Pro feature flags suitable for writing directly into the protobuf `ProMessage` in -/// `Content` -PRO_FEATURES get_pro_features_for_msg(size_t msg_size, PRO_EXTRA_FEATURES flags); +/// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. +/// When false, all fields except for `error` should be ignored from the result object. +/// - `error` -- If `success` is false, this is populated with an error code describing the error, +/// otherwise it's empty. This string is read-only and should not be modified. +/// - `features` -- Session Pro feature flags suitable for writing directly into the protobuf +/// `ProMessage` in `Content` +/// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. +ProFeaturesForMsg pro_features_for_utf16( + char16_t const* utf16, size_t utf8_size, PRO_EXTRA_FEATURES flags); /// API: session_protocol/encrypt_for_1o1 /// diff --git a/include/session/types.h b/include/session/types.h index 0ba9ecc2..cf333794 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -9,9 +9,9 @@ extern "C" { #define OPTIONAL #if defined(_MSC_VER) - #define NON_NULL_ARG(...) +#define NON_NULL_ARG(...) #else - #define NON_NULL_ARG(...) __attribute__((nonnull(__VA_ARGS__))) +#define NON_NULL_ARG(...) __attribute__((nonnull(__VA_ARGS__))) #endif /// C friendly buffer structure that is a pointer and length to a span of bytes. From c819da42faf8a4b5f9d0c9f91932603e8dbfa9ea Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 17 Sep 2025 14:30:05 +1000 Subject: [PATCH 081/171] Update pro backend layer with changes to API --- include/session/pro_backend.h | 44 ++- include/session/pro_backend.hpp | 45 ++- src/pro_backend.cpp | 150 +++++++--- tests/test_pro_backend.cpp | 513 +++++++++++++++++++------------- 4 files changed, 482 insertions(+), 270 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 2ca29eb9..d2e4fa0b 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -25,6 +25,18 @@ typedef enum SESSION_PRO_BACKEND_PAYMENT_PROVIDER { SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT, } SESSION_PRO_BACKEND_PAYMENT_PROVIDER; +/// Store front that a Session Pro payment came from. Must match: +/// https://github.com/Doy-lee/session-pro-backend/blob/f4e2c84794470e7932ba1a1968fdb49117bb5870/backend.py#L18 +typedef enum SESSION_PRO_BACKEND_PAYMENT_STATUS { + SESSION_PRO_BACKEND_PAYMENT_STATUS_NIL, + SESSION_PRO_BACKEND_PAYMENT_STATUS_UNREDEEMED, + SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED, + SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED, + SESSION_PRO_BACKEND_PAYMENT_STATUS_EXPIRED, + SESSION_PRO_BACKEND_PAYMENT_STATUS_REFUNDED, + SESSION_PRO_BACKEND_PAYMENT_STATUS_COUNT, +} SESSION_PRO_BACKEND_PAYMENT_STATUS; + typedef struct session_pro_backend_payment_provider_metadata { string8 request_refund_support_url; string8 subscription_page_url; @@ -77,11 +89,17 @@ typedef struct session_pro_backend_signature { bytes64 sig; } session_pro_backend_signature; +typedef struct session_pro_backend_add_pro_payment_user_transaction { + SESSION_PRO_BACKEND_PAYMENT_PROVIDER provider; + char payment_id[128]; + size_t payment_id_count; +} session_pro_backend_add_pro_payment_user_transaction; + typedef struct session_pro_backend_add_pro_payment_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; - bytes32 payment_token; + session_pro_backend_add_pro_payment_user_transaction payment_tx; bytes64 master_sig; bytes64 rotating_sig; } session_pro_backend_add_pro_payment_request; @@ -127,12 +145,21 @@ typedef struct session_pro_backend_get_pro_payments_request { } session_pro_backend_get_pro_payments_request; typedef struct session_pro_backend_pro_payment_item { - uint64_t activation_unix_ts_s; - uint64_t archive_unix_ts_s; - uint64_t creation_unix_ts_s; - uint64_t subscription_duration; + SESSION_PRO_BACKEND_PAYMENT_STATUS status; + uint64_t subscription_duration_s; + uint64_t activated_unix_ts_s; + uint64_t expired_unix_ts_s; + uint64_t refunded_unix_ts_s; + uint64_t redeemed_unix_ts_s; SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; - bytes32 payment_token_hash; + char google_payment_token[128]; + size_t google_payment_token_count; + char apple_original_tx_id[128]; + size_t apple_original_tx_id_count; + char apple_tx_id[128]; + size_t apple_tx_id_count; + char apple_web_line_order_id[128]; + size_t apple_web_line_order_id_count; } session_pro_backend_pro_payment_item; typedef struct session_pro_backend_get_pro_payments_response { @@ -173,8 +200,9 @@ session_pro_backend_add_pro_payment_request_build_sigs( size_t master_privkey_len, const uint8_t* rotating_privkey, size_t rotating_privkey_len, - const uint8_t* payment_token_hash, - size_t payment_token_hash_len) NON_NULL_ARG(2, 4, 6); + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len) NON_NULL_ARG(2, 4, 7); /// API: session_pro_backend/get_pro_proof_request_build_sigs /// diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 6aaed377..d8730fc3 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -73,6 +73,11 @@ struct MasterRotatingSignatures { array_uc64 rotating_sig; }; +struct AddProPaymentUserTransaction { + SESSION_PRO_BACKEND_PAYMENT_PROVIDER provider; + std::string payment_id; +}; + /// Register a new Session Pro proof to the backend. The payment is registered under the /// `master_pkey` and authorises the `rotating_pkey` to use the proof. In practice this means that /// the caller will receive a Session Pro Proof that can be attached to messages that have to be @@ -92,8 +97,8 @@ struct AddProPaymentRequest { /// Pro proof array_uc32 rotating_pkey; - /// 32-byte payment token hash from a third-party store proving purchase of a subscription - array_uc32 payment_token; + /// Transaction containing the payment details to register on the Session Pro backend + AddProPaymentUserTransaction payment_tx; /// 64-byte signature proving knowledge of the master key's secret component array_uc64 master_sig; @@ -127,7 +132,8 @@ struct AddProPaymentRequest { std::uint8_t request_version, std::span master_privkey, std::span rotating_privkey, - std::span payment_token_hash); + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id); }; /// The generated proof from the Session Pro backend that has been parsed from JSON. This structure @@ -297,16 +303,21 @@ struct GetProPaymentsRequest { }; struct ProPaymentItem { + /// Describes the current status of the consumption of the payment for Session Pro entitlement + SESSION_PRO_BACKEND_PAYMENT_STATUS status; + /// Unix timestamp (seconds) when the payment was activated for Session Pro. /// 0 if not activated (e.g., another active subscription or refunded). - std::chrono::sys_seconds activation_unix_ts; + std::chrono::sys_seconds activated_unix_ts; + + /// Unix timestamp (seconds) when the payment was expired. 0 if not activated + std::chrono::sys_seconds expired_unix_ts; - /// Unix timestamp (seconds) when the payment was archived (e.g., refunded or revoked). - /// 0 if not archived. - std::chrono::sys_seconds archive_unix_ts; + /// Unix timestamp (seconds) when the payment was redeemed. 0 if not activated + std::chrono::sys_seconds redeemed_unix_ts; - /// Unix timestamp (seconds) of payment registration, rounded to the next day - std::chrono::sys_seconds creation_unix_ts; + /// Unix timestamp (seconds) when the payment was refunded. 0 if not activated + std::chrono::sys_seconds refunded_unix_ts; /// Subscription duration in seconds std::chrono::seconds subscription_duration; @@ -314,8 +325,20 @@ struct ProPaymentItem { /// Store front that this particular payment came from SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; - /// 32-byte hash of the payment token - array_uc32 payment_token_hash; + /// When payment provider is set to Google Play Store, this is the platform-specific purchase + /// token + std::string google_payment_token; + + /// When payment provider is set to iOS App Store, this is the platform-specific original + /// transaction ID + std::string apple_original_tx_id; + + /// When payment provider is set to iOS App Store, this is the platform-specific transaction ID + std::string apple_tx_id; + + /// When payment provider is set to iOS App Store, this is the platform-specific web line order + /// ID + std::string apple_web_line_order_id; }; struct GetProPaymentsResponse : public ResponseHeader { diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 55608609..da61a9d3 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -121,7 +121,17 @@ std::string AddProPaymentRequest::to_json() const { j["version"] = version; j["master_pkey"] = oxenc::to_hex(master_pkey); j["rotating_pkey"] = oxenc::to_hex(rotating_pkey); - j["payment_token"] = oxenc::to_hex(payment_token); + j["payment_tx"]["provider"] = payment_tx.provider; + switch (payment_tx.provider) { + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE: { + j["payment_tx"]["google_payment_token"] = payment_tx.payment_id; + } break; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { + j["payment_tx"]["apple_tx_id"] = payment_tx.payment_id; + } break; + } j["master_sig"] = oxenc::to_hex(master_sig); j["rotating_sig"] = oxenc::to_hex(rotating_sig); std::string result = j.dump(); @@ -132,10 +142,8 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( std::uint8_t version, std::span master_privkey, std::span rotating_privkey, - std::span payment_token_hash) { - if (payment_token_hash.size() != 32) - throw std::invalid_argument{"Invalid payment_token_hash: expected 32 bytes"}; - + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; @@ -170,7 +178,13 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( &state, rotating_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); - crypto_generichash_blake2b_update(&state, payment_token_hash.data(), payment_token_hash.size()); + + uint8_t provider_u8 = payment_tx_provider; + crypto_generichash_blake2b_update(&state, &provider_u8, sizeof(provider_u8)); + crypto_generichash_blake2b_update( + &state, + reinterpret_cast(payment_tx_payment_id.data()), + payment_tx_payment_id.size()); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash with both keys @@ -443,19 +457,27 @@ GetProPaymentsResponse GetProPaymentsResponse::parse(std::string_view json) { // Parse payment item auto obj = it.get(); - auto activation_ts = json_require(obj, "activation_unix_ts_s", result.errors); - auto archive_ts = json_require(obj, "archive_unix_ts_s", result.errors); - auto creation_ts = json_require(obj, "creation_unix_ts_s", result.errors); + auto status = json_require(obj, "status", result.errors); + auto activated_ts = json_require(obj, "activated_unix_ts_s", result.errors); + auto expired_ts = json_require(obj, "expired_unix_ts_s", result.errors); + auto redeemed_ts = json_require(obj, "redeemed_unix_ts_s", result.errors); + auto refunded_ts = json_require(obj, "refunded_unix_ts_s", result.errors); auto sub_duration_s = json_require(obj, "subscription_duration_s", result.errors); auto payment_provider = json_require(obj, "payment_provider", result.errors); ProPaymentItem item = {}; - item.activation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activation_ts)); - item.archive_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(archive_ts)); - item.creation_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(creation_ts)); + if (status > SESSION_PRO_BACKEND_PAYMENT_STATUS_NIL && + status < SESSION_PRO_BACKEND_PAYMENT_STATUS_COUNT) { + item.status = static_cast(status); + } else { + result.errors.push_back(fmt::format("Status value was out-of-bounds: {}", status)); + } + + item.activated_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activated_ts)); + item.expired_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expired_ts)); + item.redeemed_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(redeemed_ts)); + item.refunded_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(refunded_ts)); item.subscription_duration = std::chrono::seconds(sub_duration_s); - json_require_fixed_bytes_from_hex( - obj, "payment_token_hash", result.errors, item.payment_token_hash); if (payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL && payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { item.payment_provider = @@ -465,6 +487,33 @@ GetProPaymentsResponse GetProPaymentsResponse::parse(std::string_view json) { fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); } + switch (item.payment_provider) { + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: [[fallthrough]]; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: { + } break; + + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE: { + item.google_payment_token = + json_require(obj, "google_payment_token", result.errors); + assert(item.google_payment_token.size() < + sizeof(((session_pro_backend_pro_payment_item*)0)->google_payment_token)); + } break; + + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { + item.apple_original_tx_id = + json_require(obj, "apple_original_tx_id", result.errors); + item.apple_tx_id = json_require(obj, "apple_tx_id", result.errors); + item.apple_web_line_order_id = + json_require(obj, "apple_web_line_order_id", result.errors); + assert(item.apple_original_tx_id.size() < + sizeof(((session_pro_backend_pro_payment_item*)0)->apple_original_tx_id)); + assert(item.apple_tx_id.size() < + sizeof(((session_pro_backend_pro_payment_item*)0)->apple_tx_id)); + assert(item.apple_web_line_order_id.size() < + sizeof(((session_pro_backend_pro_payment_item*)0)->apple_web_line_order_id)); + } break; + } + // Handle parsing result if (result.errors.size()) break; @@ -501,18 +550,24 @@ session_pro_backend_add_pro_payment_request_build_sigs( size_t master_privkey_len, const uint8_t* rotating_privkey, size_t rotating_privkey_len, - const uint8_t* payment_token_hash, - size_t payment_token_hash_len) { + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len) { // Convert C inputs to C++ types std::span master_span(master_privkey, master_privkey_len); std::span rotating_span(rotating_privkey, rotating_privkey_len); - std::span token_span(payment_token_hash, payment_token_hash_len); + std::span payment_tx_payment_id_span( + payment_tx_payment_id, payment_tx_payment_id_len); session_pro_backend_master_rotating_signatures result = {}; try { auto sigs = AddProPaymentRequest::build_sigs( - request_version, master_span, rotating_span, token_span); + request_version, + master_span, + rotating_span, + payment_tx_provider, + payment_tx_payment_id_span); std::memcpy(result.master_sig.data, sigs.master_sig.data(), sigs.master_sig.size()); std::memcpy(result.rotating_sig.data, sigs.rotating_sig.data(), sigs.rotating_sig.size()); result.success = true; @@ -599,7 +654,9 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment cpp.version = request->version; std::memcpy(cpp.master_pkey.data(), request->master_pkey.data, cpp.master_pkey.size()); std::memcpy(cpp.rotating_pkey.data(), request->rotating_pkey.data, cpp.rotating_pkey.size()); - std::memcpy(cpp.payment_token.data(), request->payment_token.data, cpp.payment_token.size()); + cpp.payment_tx.provider = request->payment_tx.provider; + cpp.payment_tx.payment_id = + std::string(request->payment_tx.payment_id, request->payment_tx.payment_id_count); std::memcpy(cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); std::memcpy(cpp.rotating_sig.data(), request->rotating_sig.data, cpp.rotating_sig.size()); @@ -832,11 +889,6 @@ session_pro_backend_get_pro_payments_response_parse(const char* json, size_t jso arena_t arena = {}; { arena.max += cpp.items.size() * sizeof(*result.items); - static_assert( - sizeof(cpp.items[0]) >= sizeof(*result.items), - "Ensure we allocate enough memory. We might slightly over-allocate but that's not " - "a big deal"); - for (auto it : cpp.errors) arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); @@ -865,22 +917,46 @@ session_pro_backend_get_pro_payments_response_parse(const char* json, size_t jso for (size_t index = 0; index < result.items_count; ++index) { const ProPaymentItem& src = cpp.items[index]; session_pro_backend_pro_payment_item& dest = result.items[index]; - dest.activation_unix_ts_s = std::chrono::duration_cast( - src.activation_unix_ts.time_since_epoch()) - .count(); - dest.archive_unix_ts_s = std::chrono::duration_cast( - src.archive_unix_ts.time_since_epoch()) + dest.status = src.status; + dest.subscription_duration_s = + std::chrono::duration_cast(src.subscription_duration).count(); + dest.activated_unix_ts_s = std::chrono::duration_cast( + src.activated_unix_ts.time_since_epoch()) + .count(); + dest.expired_unix_ts_s = std::chrono::duration_cast( + src.expired_unix_ts.time_since_epoch()) .count(); - dest.creation_unix_ts_s = std::chrono::duration_cast( - src.creation_unix_ts.time_since_epoch()) + dest.refunded_unix_ts_s = std::chrono::duration_cast( + src.refunded_unix_ts.time_since_epoch()) + .count(); + dest.redeemed_unix_ts_s = std::chrono::duration_cast( + src.redeemed_unix_ts.time_since_epoch()) .count(); - dest.subscription_duration = - std::chrono::duration_cast(src.subscription_duration).count(); dest.payment_provider = src.payment_provider; - std::memcpy( - dest.payment_token_hash.data, - src.payment_token_hash.data(), - src.payment_token_hash.size()); + switch (dest.payment_provider) { + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; + + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE: { + dest.google_payment_token_count = snprintf_bytes_written_clamped( + dest.google_payment_token, + sizeof(dest.google_payment_token), + src.google_payment_token.data()); + } break; + + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { + dest.apple_original_tx_id_count = snprintf_bytes_written_clamped( + dest.apple_original_tx_id, + sizeof(dest.apple_original_tx_id), + src.apple_original_tx_id.data()); + dest.apple_tx_id_count = snprintf_bytes_written_clamped( + dest.apple_tx_id, sizeof(dest.apple_tx_id), src.apple_tx_id.data()); + dest.apple_web_line_order_id_count = snprintf_bytes_written_clamped( + dest.apple_web_line_order_id, + sizeof(dest.apple_web_line_order_id), + src.apple_web_line_order_id.data()); + } break; + } } // Copy errors diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 13d85e0e..ff2721df 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -11,6 +11,15 @@ #include "utils.hpp" +struct scope_exit { + explicit scope_exit(std::function func) : cleanup(func) {} + std::function cleanup; + ~scope_exit() { + if (cleanup) + cleanup(); + } +}; + using namespace session::pro_backend; static bool string8_equals(string8 s8, std::string_view str) { @@ -28,14 +37,25 @@ static bool string8_equals(string8 s8, std::string_view str) { [[maybe_unused]] static void dump_pro_payment_item( const session_pro_backend_pro_payment_item& item) { - fprintf(stderr, "item.activation_unix_ts_s: %zu\n", item.activation_unix_ts_s); - fprintf(stderr, "item.archive_unix_ts_s: %zu\n", item.archive_unix_ts_s); - fprintf(stderr, "item.creation_unix_ts_s: %zu\n", item.creation_unix_ts_s); - fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration); + fprintf(stderr, "item.activated_unix_ts_s: %zu\n", item.activated_unix_ts_s); + fprintf(stderr, "item.expired_unix_ts_s: %zu\n", item.expired_unix_ts_s); + fprintf(stderr, "item.redeemed_unix_ts_s: %zu\n", item.redeemed_unix_ts_s); + fprintf(stderr, "item.refunded_unix_ts_s: %zu\n", item.refunded_unix_ts_s); + fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration_s); fprintf(stderr, "item.payment_provider: %u\n", item.payment_provider); fprintf(stderr, - "item.payment_token_hash: %s\n", - oxenc::to_hex(item.payment_token_hash.data).c_str()); + "item.google_payment_token: %.*s\n", + (int)item.google_payment_token_count, + item.google_payment_token); + fprintf(stderr, + "item.apple_original_tx_id: %.*s\n", + (int)item.apple_original_tx_id_count, + item.apple_original_tx_id); + fprintf(stderr, "item.apple_tx_id: %.*s\n", (int)item.apple_tx_id_count, item.apple_tx_id); + fprintf(stderr, + "item.apple_web_line_order_id: %.*s\n", + (int)item.apple_web_line_order_id_count, + item.apple_web_line_order_id); } [[maybe_unused]] static void dump_pro_revocation( @@ -73,7 +93,10 @@ std::string curl_do_basic_blocking_post_request( } CURLcode res = curl_easy_perform(curl); - REQUIRE(res == CURLE_OK); + if (res != CURLE_OK) { + INFO("ERROR: Post to " << url << " with " << post_body << ": " << curl_easy_strerror(res)); + REQUIRE(res == CURLE_OK); + } return result; } #endif @@ -88,8 +111,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { bytes64 rotating_privkey = {}; crypto_sign_ed25519_keypair(rotating_pubkey.data, rotating_privkey.data); - bytes32 payment_token_hash; - randombytes_buf(payment_token_hash.data, sizeof(payment_token_hash.data)); + session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; + payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; + payment_tx.payment_id_count = + snprintf(payment_tx.payment_id, sizeof(payment_tx.payment_id), "fake_transaction_id"); uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp SECTION("session_pro_backend_add_pro_payment_request_build_sigs") { @@ -101,14 +126,22 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey), - payment_token_hash.data, - sizeof(payment_token_hash)); + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); REQUIRE(result.success); REQUIRE(result.error_count == 0); // Verify signatures match C++ implementation auto cpp = AddProPaymentRequest::build_sigs( - 0, master_privkey.data, rotating_privkey.data, payment_token_hash.data); + 0, + master_privkey.data, + rotating_privkey.data, + payment_tx.provider, + std::span( + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count)); + REQUIRE(std::memcmp( result.master_sig.data, cpp.master_sig.data(), @@ -125,20 +158,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey) - 1, rotating_privkey.data, sizeof(rotating_privkey), - payment_token_hash.data, - sizeof(payment_token_hash.data)); - REQUIRE(!result.success); - REQUIRE(result.error_count > 0); - - // Invalid payment token hash size - result = session_pro_backend_add_pro_payment_request_build_sigs( - 0, - master_privkey.data, - sizeof(master_privkey), - rotating_privkey.data, - sizeof(rotating_privkey), - payment_token_hash.data, - sizeof(payment_token_hash) - 1); + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); REQUIRE(!result.success); REQUIRE(result.error_count > 0); } @@ -186,7 +208,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; - request.payment_token = payment_token_hash; + request.payment_tx = payment_tx; // Note just write some junk to the request request.master_sig = master_privkey; @@ -194,23 +216,27 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Valid request auto result = session_pro_backend_add_pro_payment_request_to_json(&request); - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - AddProPaymentRequest cpp = {}; - cpp.version = request.version; - std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); - std::memcpy(cpp.payment_token.data(), payment_token_hash.data, sizeof(payment_token_hash)); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); - - // Free memory - session_pro_backend_to_json_free(&result); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + AddProPaymentRequest cpp = {}; + cpp.version = request.version; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); + cpp.payment_tx.provider = payment_tx.provider; + cpp.payment_tx.payment_id = + std::string(payment_tx.payment_id, payment_tx.payment_id_count); + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } + + // After freeing REQUIRE(result.json.data == nullptr); REQUIRE(result.json.size == 0); @@ -234,23 +260,25 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Valid request auto result = session_pro_backend_get_pro_proof_request_to_json(&request); - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - GetProProofRequest cpp = {}; - cpp.version = request.version; - std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); - cpp.unix_ts = std::chrono::seconds{unix_ts_s}; - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); - - // Free memory - session_pro_backend_to_json_free(&result); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProProofRequest cpp = {}; + cpp.version = request.version; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); + cpp.unix_ts = std::chrono::seconds{unix_ts_s}; + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } + + // After freeing REQUIRE(result.json.data == nullptr); REQUIRE(result.json.size == 0); @@ -268,19 +296,21 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Valid request auto result = session_pro_backend_get_pro_revocations_request_to_json(&request); - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - GetProRevocationsRequest cpp = {}; - cpp.version = request.version; - cpp.ticket = request.ticket; - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); - - // Free memory - session_pro_backend_to_json_free(&result); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProRevocationsRequest cpp = {}; + cpp.version = request.version; + cpp.ticket = request.ticket; + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } + + // After freeing REQUIRE(result.json.data == nullptr); REQUIRE(result.json.size == 0); @@ -301,22 +331,24 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Valid request auto result = session_pro_backend_get_pro_payments_request_to_json(&request); - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - GetProPaymentsRequest cpp = {}; - cpp.version = 0; - std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}; - cpp.page = request.page; - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); - - // Free memory - session_pro_backend_to_json_free(&result); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProPaymentsRequest cpp = {}; + cpp.version = 0; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}; + cpp.page = request.page; + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } + + // After freeing REQUIRE(result.json.data == nullptr); REQUIRE(result.json.size == 0); @@ -328,12 +360,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { } SECTION("session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse") { + char fake_gen_index_hash[32]; + randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); + nlohmann::json j; j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { {"version", 0}, {"expiry_unix_ts_s", unix_ts_s}, - {"gen_index_hash", oxenc::to_hex(payment_token_hash.data)}, + {"gen_index_hash", + oxenc::to_hex( + fake_gen_index_hash, fake_gen_index_hash + sizeof(fake_gen_index_hash))}, {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, {"sig", oxenc::to_hex(master_privkey.data)}}; std::string json = j.dump(); @@ -342,48 +379,52 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_add_pro_payment_or_get_pro_proof_response result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( json.data(), json.size()); + { + scope_exit result_free{[&]() { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + }}; + + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.proof.expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp( + result.proof.gen_index_hash.data, + fake_gen_index_hash, + sizeof(fake_gen_index_hash)) == 0); + REQUIRE(std::memcmp( + result.proof.rotating_pubkey.data, + rotating_pubkey.data, + sizeof(rotating_pubkey)) == 0); + REQUIRE(std::memcmp(result.proof.sig.data, master_privkey.data, sizeof(master_privkey)) == + 0); + + // Here we also create the CPP version, we will run the conversion functions into pro + // proofs (both C and CPP variants) and then compare the two structures to make sure the + // conversion functions are sound. + auto result_cpp = AddProPaymentOrGetProProofResponse::parse(json); + + // Validate C and CPP variants + REQUIRE(result.proof.version == result_cpp.proof.version); + REQUIRE(std::memcmp( + result.proof.gen_index_hash.data, + result_cpp.proof.gen_index_hash.data(), + result_cpp.proof.gen_index_hash.size()) == 0); + REQUIRE(std::memcmp( + result.proof.rotating_pubkey.data, + result_cpp.proof.rotating_pubkey.data(), + result_cpp.proof.rotating_pubkey.size()) == 0); + REQUIRE(result.proof.expiry_unix_ts_s == + result_cpp.proof.expiry_unix_ts.time_since_epoch().count()); + REQUIRE(std::memcmp( + result.proof.sig.data, + result_cpp.proof.sig.data(), + result_cpp.proof.sig.size()) == 0); + } - for (size_t index = 0; index < result.header.errors_count; index++) - INFO(result.header.errors[index].data); - REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 0); - REQUIRE(result.header.errors == nullptr); - REQUIRE(result.proof.expiry_unix_ts_s == unix_ts_s); - REQUIRE(std::memcmp( - result.proof.gen_index_hash.data, - payment_token_hash.data, - sizeof(payment_token_hash)) == 0); - REQUIRE(std::memcmp( - result.proof.rotating_pubkey.data, - rotating_pubkey.data, - sizeof(rotating_pubkey)) == 0); - REQUIRE(std::memcmp(result.proof.sig.data, master_privkey.data, sizeof(master_privkey)) == - 0); - - // Here we also create the CPP version, we will run the conversion functions into pro proofs - // (both C and CPP variants) and then compare the two structures to make sure the conversion - // functions are sound. - auto result_cpp = AddProPaymentOrGetProProofResponse::parse(json); - - // Validate C and CPP variants - REQUIRE(result.proof.version == result_cpp.proof.version); - REQUIRE(std::memcmp( - result.proof.gen_index_hash.data, - result_cpp.proof.gen_index_hash.data(), - result_cpp.proof.gen_index_hash.size()) == 0); - REQUIRE(std::memcmp( - result.proof.rotating_pubkey.data, - result_cpp.proof.rotating_pubkey.data(), - result_cpp.proof.rotating_pubkey.size()) == 0); - REQUIRE(result.proof.expiry_unix_ts_s == - result_cpp.proof.expiry_unix_ts.time_since_epoch().count()); - REQUIRE(std::memcmp( - result.proof.sig.data, - result_cpp.proof.sig.data(), - result_cpp.proof.sig.size()) == 0); - - // Free memory - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + // After freeing REQUIRE(result.header.internal_arena_buf_ == nullptr); REQUIRE(result.header.errors == nullptr); REQUIRE(result.header.errors_count == 0); @@ -392,11 +433,16 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { json = "{invalid}"; result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( json.data(), json.size()); - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count > 0); - REQUIRE(result.header.errors != nullptr); + { + scope_exit result_free{[&]() { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + }}; + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } - // Free memory + // After freeing session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); REQUIRE(result.header.internal_arena_buf_ == nullptr); @@ -414,9 +460,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = {{"ticket", 123}, {"items", nlohmann::json::array()}}; + char fake_gen_index_hash[32]; + randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); + auto obj = nlohmann::json::object(); obj["expiry_unix_ts_s"] = unix_ts_s; - obj["gen_index_hash"] = oxenc::to_hex(payment_token_hash.data); + obj["gen_index_hash"] = oxenc::to_hex( + fake_gen_index_hash, fake_gen_index_hash + sizeof(fake_gen_index_hash)); j["result"]["items"].push_back(obj); std::string json = j.dump(); @@ -424,35 +474,43 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Valid JSON auto result = session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); - for (size_t index = 0; index < result.header.errors_count; index++) - INFO(result.header.errors[index].data); - REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 0); - REQUIRE(result.header.errors == nullptr); - REQUIRE(result.ticket == 123); - REQUIRE(result.items_count == 1); - REQUIRE(result.items != nullptr); - REQUIRE(result.items[0].expiry_unix_ts_s == unix_ts_s); - REQUIRE(std::memcmp( - result.items[0].gen_index_hash.data, - payment_token_hash.data, - sizeof(payment_token_hash)) == 0); + { + scope_exit result_free{ + [&]() { session_pro_backend_get_pro_revocations_response_free(&result); }}; + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.ticket == 123); + REQUIRE(result.items_count == 1); + REQUIRE(result.items != nullptr); + REQUIRE(result.items[0].expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp( + result.items[0].gen_index_hash.data, + fake_gen_index_hash, + sizeof(fake_gen_index_hash)) == 0); + } - // Free memory - session_pro_backend_get_pro_revocations_response_free(&result); + // After freeeing REQUIRE(result.header.internal_arena_buf_ == nullptr); REQUIRE(result.items == nullptr); REQUIRE(result.items_count == 0); // Invalid JSON json = "{invalid}"; - result = session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count > 0); - REQUIRE(result.header.errors != nullptr); + { + result = session_pro_backend_get_pro_revocations_response_parse( + json.data(), json.size()); + scope_exit result_free{ + [&]() { session_pro_backend_get_pro_revocations_response_free(&result); }}; + for (size_t index = 0; index < result.header.errors_count; index++) + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } - // Free memory - session_pro_backend_get_pro_revocations_response_free(&result); + // After freeing REQUIRE(result.header.internal_arena_buf_ == nullptr); // Null JSON @@ -470,39 +528,48 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"payments", 10}, {"items", nlohmann::json::array( - {{{"activation_unix_ts_s", unix_ts_s}, - {"archive_unix_ts_s", unix_ts_s + 3600}, - {"creation_unix_ts_s", unix_ts_s - 3600}, + {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED}, {"subscription_duration_s", 86400}, + {"activated_unix_ts_s", unix_ts_s}, + {"expired_unix_ts_s", unix_ts_s}, + {"refunded_unix_ts_s", unix_ts_s + 3600}, + {"redeemed_unix_ts_s", unix_ts_s - 3600}, {"payment_provider", SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, - {"payment_token_hash", oxenc::to_hex(payment_token_hash.data)}}})}}; + {"google_payment_token", + std::string(payment_tx.payment_id, payment_tx.payment_id_count)}}})}}; std::string json = j.dump(); // Valid JSON auto result = session_pro_backend_get_pro_payments_response_parse(json.data(), json.size()); - for (size_t index = 0; index < result.header.errors_count; index++) - INFO(result.header.errors[index].data); - REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 0); - REQUIRE(result.header.errors == nullptr); - REQUIRE(result.pages == 2); - REQUIRE(result.payments == 10); - REQUIRE(result.items_count == 1); - REQUIRE(result.items != nullptr); - REQUIRE(result.items[0].activation_unix_ts_s == unix_ts_s); - REQUIRE(result.items[0].payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL); - REQUIRE(result.items[0].payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT); - REQUIRE(result.items[0].archive_unix_ts_s == unix_ts_s + 3600); - REQUIRE(result.items[0].creation_unix_ts_s == unix_ts_s - 3600); - REQUIRE(result.items[0].subscription_duration == 86400); - REQUIRE(std::memcmp( - result.items[0].payment_token_hash.data, - payment_token_hash.data, - sizeof(payment_token_hash)) == 0); + { + scope_exit result_free{ + [&]() { session_pro_backend_get_pro_payments_response_free(&result); }}; + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.pages == 2); + REQUIRE(result.payments == 10); + REQUIRE(result.items_count == 1); + REQUIRE(result.items != nullptr); + REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED); + REQUIRE(result.items[0].subscription_duration_s == 86400); + REQUIRE(result.items[0].activated_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].expired_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].refunded_unix_ts_s == unix_ts_s + 3600); + REQUIRE(result.items[0].redeemed_unix_ts_s == unix_ts_s - 3600); + REQUIRE(result.items[0].payment_provider == + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE); + REQUIRE(result.items[0].google_payment_token_count == payment_tx.payment_id_count); + REQUIRE(std::memcmp( + result.items[0].google_payment_token, + payment_tx.payment_id, + payment_tx.payment_id_count) == 0); + } - // Free memory - session_pro_backend_get_pro_payments_response_free(&result); + // After freeing REQUIRE(result.header.internal_arena_buf_ == nullptr); REQUIRE(result.items == nullptr); REQUIRE(result.items_count == 0); @@ -510,11 +577,16 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Invalid JSON json = "{invalid}"; result = session_pro_backend_get_pro_payments_response_parse(json.data(), json.size()); - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count > 0); - REQUIRE(result.header.errors != nullptr); + { + std::unique_ptr> esult_free(nullptr, [&](void*) { + session_pro_backend_get_pro_payments_response_free(&result); + }); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } - // Free memory + // After freeing session_pro_backend_get_pro_payments_response_free(&result); REQUIRE(result.header.internal_arena_buf_ == nullptr); @@ -552,13 +624,16 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Setup CURL curl_global_init(CURL_GLOBAL_DEFAULT); + scope_exit curl_cleanup{[&]() { curl_global_cleanup(); }}; CURL* curl = curl_easy_init(); REQUIRE(curl); + scope_exit curl_free{[&]() { curl_easy_cleanup(curl); }}; struct curl_slist* curl_headers = curl_slist_append(curl_headers, "Content-Type: application/json"); REQUIRE(curl_headers); + scope_exit curl_headers_free{[&]() { curl_slist_free_all(curl_headers); }}; // Add pro payment pro_proof first_pro_proof = {}; @@ -571,19 +646,22 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey), - payment_token_hash.data, - sizeof(payment_token_hash)); + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); session_pro_backend_add_pro_payment_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; - request.payment_token = payment_token_hash; + request.payment_tx = payment_tx; request.master_sig = add_pro_sigs.master_sig; request.rotating_sig = add_pro_sigs.rotating_sig; session_pro_backend_to_json request_json = session_pro_backend_add_pro_payment_request_to_json(&request); + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; // Do curl request std::string response_json = curl_do_basic_blocking_post_request( @@ -596,10 +674,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_add_pro_payment_or_get_pro_proof_response response = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( response_json.data(), response_json.size()); + scope_exit response_free{[&]() { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + }}; for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; - INFO("error: " << error.data); + INFO("ERROR: " << error.data); } // Verify response @@ -610,9 +691,6 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { response.proof.rotating_pubkey.data, request.rotating_pkey.data, sizeof(request.rotating_pkey)) == 0); - - session_pro_backend_to_json_free(&request_json); - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); } // Authorise new key @@ -638,6 +716,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_to_json request_json = session_pro_backend_get_pro_proof_request_to_json(&request); + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; // Do CURL request std::string response_json = curl_do_basic_blocking_post_request( @@ -650,9 +730,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_add_pro_payment_or_get_pro_proof_response response = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( response_json.data(), response_json.size()); + std::unique_ptr> response_free(nullptr, [&](void*) { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + }); + for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; - fprintf(stderr, "error: %s\n", error.data); + fprintf(stderr, "ERROR: %s\n", error.data); } REQUIRE(response.header.errors_count == 0); REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); @@ -692,6 +776,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Do CURL request session_pro_backend_to_json request_json = session_pro_backend_get_pro_payments_request_to_json(&request); + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; std::string response_json = curl_do_basic_blocking_post_request( curl, @@ -703,9 +789,12 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_payments_response response = session_pro_backend_get_pro_payments_response_parse( response_json.data(), response_json.size()); + scope_exit response_free{ + [&]() { session_pro_backend_get_pro_payments_response_free(&response); }}; + for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; - fprintf(stderr, "error: %s\n", error.data); + fprintf(stderr, "ERROR: %s\n", error.data); } // Verify the response @@ -714,9 +803,6 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.pages == 0); REQUIRE(response.payments > 0); REQUIRE(response.items_count > 0); - - session_pro_backend_to_json_free(&request_json); - session_pro_backend_get_pro_payments_response_free(&response); } // Add _another_ payment, same details. This creates a revocation for @@ -731,19 +817,22 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey), - payment_token_hash.data, - sizeof(payment_token_hash)); + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); session_pro_backend_add_pro_payment_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; - request.payment_token = payment_token_hash; + request.payment_tx = payment_tx; request.master_sig = add_pro_sigs.master_sig; request.rotating_sig = add_pro_sigs.rotating_sig; session_pro_backend_to_json request_json = session_pro_backend_add_pro_payment_request_to_json(&request); + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; // Do curl request std::string response_json = curl_do_basic_blocking_post_request( @@ -756,6 +845,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_add_pro_payment_or_get_pro_proof_response response = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( response_json.data(), response_json.size()); + scope_exit response_free{[&]() { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + }}; // Verify response pro_proof proof = response.proof; @@ -765,9 +857,6 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { response.proof.rotating_pubkey.data, request.rotating_pkey.data, sizeof(request.rotating_pkey)) == 0); - - session_pro_backend_to_json_free(&request_json); - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); } // Get revocation list @@ -778,6 +867,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_to_json request_json = session_pro_backend_get_pro_revocations_request_to_json(&request); + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; // Do curl request std::string response_json = curl_do_basic_blocking_post_request( @@ -790,11 +881,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_revocations_response response = session_pro_backend_get_pro_revocations_response_parse( response_json.data(), response_json.size()); + scope_exit response_free{ + [&]() { session_pro_backend_get_pro_revocations_response_free(&response); }}; // Verify response for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; - fprintf(stderr, "error: %s\n", error.data); + fprintf(stderr, "ERROR: %s\n", error.data); } // Verify the response @@ -812,15 +905,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.items[response.items_count - 1].expiry_unix_ts_s == first_pro_proof.expiry_unix_ts_s); - - session_pro_backend_to_json_free(&request_json); - session_pro_backend_get_pro_revocations_response_free(&response); } - - // Cleanup CURL - curl_slist_free_all(curl_headers); - curl_easy_cleanup(curl); - curl_global_cleanup(); } #endif } From 125940042a1d2cd0699360dd39de3fbf519c43f7 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 18 Sep 2025 14:11:20 +1000 Subject: [PATCH 082/171] Update pro payments to pro status endpoint --- include/session/pro_backend.h | 46 +- include/session/pro_backend.hpp | 27 +- src/pro_backend.cpp | 50 +- tests/test_pro_backend.cpp | 1022 +++++++++++++++++-------------- 4 files changed, 624 insertions(+), 521 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index d2e4fa0b..d8fdcbe9 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -25,7 +25,7 @@ typedef enum SESSION_PRO_BACKEND_PAYMENT_PROVIDER { SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT, } SESSION_PRO_BACKEND_PAYMENT_PROVIDER; -/// Store front that a Session Pro payment came from. Must match: +/// Must match: /// https://github.com/Doy-lee/session-pro-backend/blob/f4e2c84794470e7932ba1a1968fdb49117bb5870/backend.py#L18 typedef enum SESSION_PRO_BACKEND_PAYMENT_STATUS { SESSION_PRO_BACKEND_PAYMENT_STATUS_NIL, @@ -37,6 +37,15 @@ typedef enum SESSION_PRO_BACKEND_PAYMENT_STATUS { SESSION_PRO_BACKEND_PAYMENT_STATUS_COUNT, } SESSION_PRO_BACKEND_PAYMENT_STATUS; +/// Must match: +/// https://github.com/Doy-lee/session-pro-backend/blob/a0e0ba24bc4ab3a062465d861aa57df2269b6dde/server.py#L373 +typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { + SESSION_PRO_BACKEND_USER_PRO_STATUS_NEVER_BEEN_PRO, + SESSION_PRO_BACKEND_USER_PRO_STATUS_ACTIVE, + SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED, + SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT, +} SESSION_PRO_BACKEND_USER_PRO_STATUS; + typedef struct session_pro_backend_payment_provider_metadata { string8 request_refund_support_url; string8 subscription_page_url; @@ -136,13 +145,13 @@ typedef struct session_pro_backend_get_pro_revocations_response { size_t items_count; } session_pro_backend_get_pro_revocations_response; -typedef struct session_pro_backend_get_pro_payments_request { +typedef struct session_pro_backend_get_pro_status_request { uint8_t version; bytes32 master_pkey; bytes64 master_sig; uint64_t unix_ts_s; - uint32_t page; -} session_pro_backend_get_pro_payments_request; + bool history; +} session_pro_backend_get_pro_status_request; typedef struct session_pro_backend_pro_payment_item { SESSION_PRO_BACKEND_PAYMENT_STATUS status; @@ -162,14 +171,13 @@ typedef struct session_pro_backend_pro_payment_item { size_t apple_web_line_order_id_count; } session_pro_backend_pro_payment_item; -typedef struct session_pro_backend_get_pro_payments_response { +typedef struct session_pro_backend_get_pro_status_response { session_pro_backend_response_header header; /// Array of payment items, with items_count elements session_pro_backend_pro_payment_item* items; size_t items_count; - uint32_t pages; - uint32_t payments; -} session_pro_backend_get_pro_payments_response; + SESSION_PRO_BACKEND_USER_PRO_STATUS status; +} session_pro_backend_get_pro_status_response; /// API: session_pro_backend/add_pro_payment_request_build_sigs /// @@ -233,7 +241,7 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof size_t rotating_privkey_len, uint64_t unix_ts_s) NON_NULL_ARG(2, 4); -/// API: session_pro_backend/get_pro_payments_request_build_sig +/// API: session_pro_backend/get_pro_status_request_build_sig /// /// Builds the signature for GetProPaymentsRequest /// Returns false if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. @@ -252,7 +260,7 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof /// - `errors_count` - length of the error if `success` is false /// - `sig` - 64 byte signature LIBSESSION_EXPORT -session_pro_backend_signature session_pro_backend_get_pro_payments_request_build_sig( +session_pro_backend_signature session_pro_backend_get_pro_status_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -289,13 +297,13 @@ LIBSESSION_EXPORT session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_json( const session_pro_backend_get_pro_revocations_request* request); -/// API: session_pro_backend/get_pro_payments_request_to_json +/// API: session_pro_backend/get_pro_status_request_to_json /// /// Serializes a `GetProPaymentsRequest` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. LIBSESSION_EXPORT -session_pro_backend_to_json session_pro_backend_get_pro_payments_request_to_json( - const session_pro_backend_get_pro_payments_request* request); +session_pro_backend_to_json session_pro_backend_get_pro_status_request_to_json( + const session_pro_backend_get_pro_status_request* request); /// API: session_pro_backend/add_pro_payment_or_get_pro_proof_response_parse /// @@ -323,16 +331,16 @@ LIBSESSION_EXPORT session_pro_backend_get_pro_revocations_response session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t json_len); -/// API: session_pro_backend/get_pro_payments_response_parse +/// API: session_pro_backend/get_pro_status_response_parse /// /// Parses a JSON string into a GetProPaymentsResponse struct. -/// The caller must free the response using session_pro_backend_get_pro_payments_response_free. +/// The caller must free the response using session_pro_backend_get_pro_status_response_free. /// /// Inputs: /// - `json` -- JSON string to parse. /// - `json_len` -- Length of the JSON string. LIBSESSION_EXPORT -session_pro_backend_get_pro_payments_response session_pro_backend_get_pro_payments_response_parse( +session_pro_backend_get_pro_status_response session_pro_backend_get_pro_status_response_parse( const char* json, size_t json_len); /// API: session_pro_backend/to_json_free @@ -355,12 +363,12 @@ LIBSESSION_EXPORT void session_pro_backend_get_pro_revocations_response_free( session_pro_backend_get_pro_revocations_response* response); -/// API: session_pro_backend/get_pro_payments_response_free +/// API: session_pro_backend/get_pro_status_response_free /// /// Frees the respone LIBSESSION_EXPORT -void session_pro_backend_get_pro_payments_response_free( - session_pro_backend_get_pro_payments_response* response); +void session_pro_backend_get_pro_status_response_free( + session_pro_backend_get_pro_status_response* response); #ifdef __cplusplus } // extern "C" diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index d8730fc3..dbfb7da8 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -39,10 +39,10 @@ /// list that clients should cache. Any incoming messages with a Pro proof that is in the list of /// revoked proofs will not be entitled to Pro features. /// -/// 4. Query the list of historical payments that the master Ed25519 key has registered by building -/// a `GetProPaymentsRequest::to_json` query and submitting it. +/// 4. Query the status (and optionally payment history) of a user's Session Pro Master Ed25519 key +/// has registered by building a `GetProStatusRequest::to_json` query and submitting it. /// -/// Server responds JSON to be parsed with `GetProPaymentsResponse::parse` which they can use to +/// Server responds JSON to be parsed with `GetProStatusResponse::parse` which they can use to /// populate their client's payment history. /// /// 5. Get a list of per-payment provider URLs, such as links to the support page for refunds and @@ -257,7 +257,7 @@ struct GetProRevocationsResponse : public ResponseHeader { static GetProRevocationsResponse parse(std::string_view json); }; -struct GetProPaymentsRequest { +struct GetProStatusRequest { /// Request version for the API std::uint8_t version; @@ -270,8 +270,8 @@ struct GetProPaymentsRequest { /// Unix timestamp (seconds) of the request std::chrono::sys_seconds unix_ts; - /// Page number for paginated API requests - std::uint32_t page; + /// Flag to request payment history from the backend + bool history; /// API: pro/AddProPaymentRequest::build_sigs /// @@ -283,7 +283,7 @@ struct GetProPaymentsRequest { /// - `request_version` -- Version of the request to build a hash for /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key /// - `unix_ts` -- Unix timestamp (seconds) for the request. - /// - `page` -- The page in the paginated list of historical payments to request + /// - `history` -- Flag to request payment history from the backend /// /// Outputs: /// - `array_uc64` - the 64-byte signature @@ -291,7 +291,7 @@ struct GetProPaymentsRequest { uint8_t version, std::span master_privkey, std::chrono::sys_seconds unix_ts, - uint32_t page); + bool history); /// API: pro/GetProProofRequest::to_json /// @@ -341,15 +341,12 @@ struct ProPaymentItem { std::string apple_web_line_order_id; }; -struct GetProPaymentsResponse : public ResponseHeader { +struct GetProStatusResponse : public ResponseHeader { /// List of payment items for the master public key std::vector items; - /// Total pages available in the paginated API - std::uint32_t pages; - - /// Total payments for the user (active, refunded, or non-active) - std::uint32_t payments; + /// Current Session Pro entitlement status for the master public key + SESSION_PRO_BACKEND_USER_PRO_STATUS user_status; /// API: pro/GetProPaymentsResponse::parse /// @@ -360,7 +357,7 @@ struct GetProPaymentsResponse : public ResponseHeader { /// /// Outputs: /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. - static GetProPaymentsResponse parse(std::string_view json); + static GetProStatusResponse parse(std::string_view json); }; void make_blake2b32_hasher(struct crypto_generichash_blake2b_state* hasher); diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index da61a9d3..37b6d508 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -367,22 +367,22 @@ GetProRevocationsResponse GetProRevocationsResponse::parse(std::string_view json return result; } -std::string GetProPaymentsRequest::to_json() const { +std::string GetProStatusRequest::to_json() const { nlohmann::json j; j["version"] = version; j["master_pkey"] = oxenc::to_hex(master_pkey); j["master_sig"] = oxenc::to_hex(master_sig); j["unix_ts_s"] = unix_ts.time_since_epoch().count(); - j["page"] = page; + j["history"] = history; std::string result = j.dump(); return result; } -array_uc64 GetProPaymentsRequest::build_sig( +array_uc64 GetProStatusRequest::build_sig( uint8_t version, std::span master_privkey, std::chrono::sys_seconds unix_ts, - uint32_t page) { + bool history) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; @@ -406,8 +406,9 @@ array_uc64 GetProPaymentsRequest::build_sig( crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + uint8_t history_u8 = history; crypto_generichash_blake2b_update( - &state, reinterpret_cast(&page), sizeof(page)); + &state, reinterpret_cast(&history_u8), sizeof(history_u8)); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash @@ -421,9 +422,9 @@ array_uc64 GetProPaymentsRequest::build_sig( return result; } -GetProPaymentsResponse GetProPaymentsResponse::parse(std::string_view json) { +GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { // Parse basics - GetProPaymentsResponse result = {}; + GetProStatusResponse result = {}; nlohmann::json j = json_parse(json, result.errors); result.status = json_require(j, "status", result.errors); if (result.errors.size()) { @@ -442,8 +443,12 @@ GetProPaymentsResponse GetProPaymentsResponse::parse(std::string_view json) { return result; // Parse payload - result.pages = json_require(result_obj, "pages", result.errors); - result.payments = json_require(result_obj, "payments", result.errors); + uint32_t user_status = json_require(result_obj, "status", result.errors); + if (user_status >= SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT) { + result.errors.push_back(fmt::format("User pro status value was out-of-bounds: {}", user_status)); + return result; + } + result.user_status = static_cast(user_status); auto array = json_require(result_obj, "items", result.errors); result.items.reserve(array.size()); @@ -616,7 +621,7 @@ session_pro_backend_get_pro_proof_request_build_sigs( } LIBSESSION_C_API session_pro_backend_signature -session_pro_backend_get_pro_payments_request_build_sig( +session_pro_backend_get_pro_status_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -628,7 +633,7 @@ session_pro_backend_get_pro_payments_request_build_sig( session_pro_backend_signature result = {}; try { - auto sig = GetProPaymentsRequest::build_sig(request_version, master_span, ts, page); + auto sig = GetProStatusRequest::build_sig(request_version, master_span, ts, page); std::memcpy(result.sig.data, sig.data(), sig.size()); result.success = true; } catch (const std::exception& e) { @@ -717,20 +722,20 @@ session_pro_backend_get_pro_revocations_request_to_json( return result; } -LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_payments_request_to_json( - const session_pro_backend_get_pro_payments_request* request) { +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_request_to_json( + const session_pro_backend_get_pro_status_request* request) { session_pro_backend_to_json result = {}; if (!request) return result; // Construct C++ struct - GetProPaymentsRequest cpp = {}; + GetProStatusRequest cpp = {}; cpp.version = request->version; std::memcpy( cpp.master_pkey.data(), request->master_pkey.data, sizeof(request->master_pkey.data)); std::memcpy(cpp.master_sig.data(), request->master_sig.data, sizeof(request->master_sig.data)); cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{request->unix_ts_s}}; - cpp.page = request->page; + cpp.history = request->history; try { std::string json = cpp.to_json(); @@ -872,9 +877,9 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t return result; } -LIBSESSION_C_API session_pro_backend_get_pro_payments_response -session_pro_backend_get_pro_payments_response_parse(const char* json, size_t json_len) { - session_pro_backend_get_pro_payments_response result = {}; +LIBSESSION_C_API session_pro_backend_get_pro_status_response +session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_len) { + session_pro_backend_get_pro_status_response result = {}; if (!json) { result.header.status = 1; result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; @@ -883,7 +888,7 @@ session_pro_backend_get_pro_payments_response_parse(const char* json, size_t jso } // Note, parse is written to not throw so we can safely read without try-catch crap - auto cpp = GetProPaymentsResponse::parse({json, json_len}); + auto cpp = GetProStatusResponse::parse({json, json_len}); // Calculate how much memory we need and create an arena arena_t arena = {}; @@ -908,8 +913,7 @@ session_pro_backend_get_pro_payments_response_parse(const char* json, size_t jso // Copy to C struct, this is guaranteed not to fail because we pre-allocated memory upfront. result.header.status = cpp.status; - result.pages = cpp.pages; - result.payments = cpp.payments; + result.status = cpp.user_status; result.items_count = cpp.items.size(); result.items = (session_pro_backend_pro_payment_item*)arena_alloc( &arena, result.items_count * sizeof(*result.items)); @@ -994,8 +998,8 @@ LIBSESSION_C_API void session_pro_backend_get_pro_revocations_response_free( } } -LIBSESSION_C_API void session_pro_backend_get_pro_payments_response_free( - session_pro_backend_get_pro_payments_response* response) { +LIBSESSION_C_API void session_pro_backend_get_pro_status_response_free( + session_pro_backend_get_pro_status_response* response) { if (response) { free(response->header.internal_arena_buf_); *response = {}; diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index ff2721df..5bfea953 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -111,510 +111,528 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { bytes64 rotating_privkey = {}; crypto_sign_ed25519_keypair(rotating_pubkey.data, rotating_privkey.data); - session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; - payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; - payment_tx.payment_id_count = - snprintf(payment_tx.payment_id, sizeof(payment_tx.payment_id), "fake_transaction_id"); - uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp - - SECTION("session_pro_backend_add_pro_payment_request_build_sigs") { - // Valid inputs - session_pro_backend_master_rotating_signatures result = - session_pro_backend_add_pro_payment_request_build_sigs( - /*version*/ 0, - master_privkey.data, - sizeof(master_privkey), - rotating_privkey.data, - sizeof(rotating_privkey), - payment_tx.provider, - reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count); - REQUIRE(result.success); - REQUIRE(result.error_count == 0); - - // Verify signatures match C++ implementation - auto cpp = AddProPaymentRequest::build_sigs( - 0, - master_privkey.data, - rotating_privkey.data, - payment_tx.provider, - std::span( - reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count)); - - REQUIRE(std::memcmp( - result.master_sig.data, - cpp.master_sig.data(), - sizeof(result.master_sig.data)) == 0); - REQUIRE(std::memcmp( - result.rotating_sig.data, - cpp.rotating_sig.data(), - sizeof(result.rotating_sig.data)) == 0); - - // Invalid master key size - result = session_pro_backend_add_pro_payment_request_build_sigs( - 0, - master_privkey.data, - sizeof(master_privkey) - 1, - rotating_privkey.data, - sizeof(rotating_privkey), - payment_tx.provider, - reinterpret_cast(payment_tx.payment_id), + { + bytes32 fake_google_payment_token; + randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); + std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token.data); + + session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; + payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; + payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + std::memcpy( + payment_tx.payment_id, + fake_google_payment_token_hex.data(), payment_tx.payment_id_count); - REQUIRE(!result.success); - REQUIRE(result.error_count > 0); - } - SECTION("session_pro_backend_get_pro_proof_request_build_sigs") { - session_pro_backend_master_rotating_signatures result = {}; - - // Valid inputs - result = session_pro_backend_get_pro_proof_request_build_sigs( - 0, - master_privkey.data, - sizeof(master_privkey), - rotating_privkey.data, - sizeof(rotating_privkey), - unix_ts_s); - REQUIRE(result.success); - REQUIRE(result.error_count == 0); - - // Verify signatures match C++ implementation - auto cpp_sigs = GetProProofRequest::build_sigs( - 0, master_privkey.data, rotating_privkey.data, std::chrono::seconds{unix_ts_s}); - REQUIRE(std::memcmp( - result.master_sig.data, - cpp_sigs.master_sig.data(), - sizeof(result.master_sig)) == 0); - REQUIRE(std::memcmp( - result.rotating_sig.data, - cpp_sigs.rotating_sig.data(), - sizeof(result.rotating_sig)) == 0); - - // Invalid rotating key size - result = session_pro_backend_get_pro_proof_request_build_sigs( - 0, - master_privkey.data, - sizeof(master_privkey), - rotating_privkey.data, - sizeof(rotating_privkey) - 1, - unix_ts_s); - REQUIRE(!result.success); - REQUIRE(result.error_count > 0); - } + uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp - SECTION("session_pro_backend_add_pro_payment_request_to_json") { - session_pro_backend_add_pro_payment_request request = {}; - request.version = 0; - request.master_pkey = master_pubkey; - request.rotating_pkey = rotating_pubkey; - request.payment_tx = payment_tx; + SECTION("session_pro_backend_add_pro_payment_request_build_sigs") { + // Valid inputs + session_pro_backend_master_rotating_signatures result = + session_pro_backend_add_pro_payment_request_build_sigs( + /*version*/ 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); + REQUIRE(result.success); + REQUIRE(result.error_count == 0); + + // Verify signatures match C++ implementation + auto cpp = AddProPaymentRequest::build_sigs( + 0, + master_privkey.data, + rotating_privkey.data, + payment_tx.provider, + std::span( + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count)); - // Note just write some junk to the request - request.master_sig = master_privkey; - request.rotating_sig = rotating_privkey; + REQUIRE(std::memcmp( + result.master_sig.data, + cpp.master_sig.data(), + sizeof(result.master_sig.data)) == 0); + REQUIRE(std::memcmp( + result.rotating_sig.data, + cpp.rotating_sig.data(), + sizeof(result.rotating_sig.data)) == 0); + + // Invalid master key size + result = session_pro_backend_add_pro_payment_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey) - 1, + rotating_privkey.data, + sizeof(rotating_privkey), + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); + REQUIRE(!result.success); + REQUIRE(result.error_count > 0); + } - // Valid request - auto result = session_pro_backend_add_pro_payment_request_to_json(&request); - { - scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + SECTION("session_pro_backend_get_pro_proof_request_build_sigs") { + session_pro_backend_master_rotating_signatures result = {}; + + // Valid inputs + result = session_pro_backend_get_pro_proof_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey), + unix_ts_s); REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - AddProPaymentRequest cpp = {}; - cpp.version = request.version; - std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); - cpp.payment_tx.provider = payment_tx.provider; - cpp.payment_tx.payment_id = - std::string(payment_tx.payment_id, payment_tx.payment_id_count); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); - } + REQUIRE(result.error_count == 0); - // After freeing - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); + // Verify signatures match C++ implementation + auto cpp_sigs = GetProProofRequest::build_sigs( + 0, master_privkey.data, rotating_privkey.data, std::chrono::seconds{unix_ts_s}); + REQUIRE(std::memcmp( + result.master_sig.data, + cpp_sigs.master_sig.data(), + sizeof(result.master_sig)) == 0); + REQUIRE(std::memcmp( + result.rotating_sig.data, + cpp_sigs.rotating_sig.data(), + sizeof(result.rotating_sig)) == 0); + + // Invalid rotating key size + result = session_pro_backend_get_pro_proof_request_build_sigs( + 0, + master_privkey.data, + sizeof(master_privkey), + rotating_privkey.data, + sizeof(rotating_privkey) - 1, + unix_ts_s); + REQUIRE(!result.success); + REQUIRE(result.error_count > 0); + } - // Null request - result = session_pro_backend_add_pro_payment_request_to_json(nullptr); - REQUIRE(!result.success); - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); - } + SECTION("session_pro_backend_add_pro_payment_request_to_json") { + session_pro_backend_add_pro_payment_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.payment_tx = payment_tx; - SECTION("session_pro_backend_get_pro_proof_request_to_json") { - session_pro_backend_get_pro_proof_request request = {}; - request.version = 0; - request.master_pkey = master_pubkey; - request.rotating_pkey = rotating_pubkey; - request.unix_ts_s = unix_ts_s; + // Note just write some junk to the request + request.master_sig = master_privkey; + request.rotating_sig = rotating_privkey; + + // Valid request + auto result = session_pro_backend_add_pro_payment_request_to_json(&request); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + AddProPaymentRequest cpp = {}; + cpp.version = request.version; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy( + cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); + cpp.payment_tx.provider = payment_tx.provider; + cpp.payment_tx.payment_id = + std::string(payment_tx.payment_id, payment_tx.payment_id_count); + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy( + cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } - // Note just write some junk to the request - request.master_sig = master_privkey; - request.rotating_sig = rotating_privkey; + // After freeing + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); - // Valid request - auto result = session_pro_backend_get_pro_proof_request_to_json(&request); - { - scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - GetProProofRequest cpp = {}; - cpp.version = request.version; - std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); - cpp.unix_ts = std::chrono::seconds{unix_ts_s}; - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - std::memcpy(cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); + // Null request + result = session_pro_backend_add_pro_payment_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); } - // After freeing - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); - - // Null request - result = session_pro_backend_get_pro_proof_request_to_json(nullptr); - REQUIRE(!result.success); - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); - } + SECTION("session_pro_backend_get_pro_proof_request_to_json") { + session_pro_backend_get_pro_proof_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.rotating_pkey = rotating_pubkey; + request.unix_ts_s = unix_ts_s; + + // Note just write some junk to the request + request.master_sig = master_privkey; + request.rotating_sig = rotating_privkey; + + // Valid request + auto result = session_pro_backend_get_pro_proof_request_to_json(&request); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProProofRequest cpp = {}; + cpp.version = request.version; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy( + cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); + cpp.unix_ts = std::chrono::seconds{unix_ts_s}; + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy( + cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } - SECTION("session_pro_backend_get_pro_revocations_request_to_json") { - session_pro_backend_get_pro_revocations_request request = {}; - request.version = 0; - request.ticket = 123; + // After freeing + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); - // Valid request - auto result = session_pro_backend_get_pro_revocations_request_to_json(&request); - { - scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - GetProRevocationsRequest cpp = {}; - cpp.version = request.version; - cpp.ticket = request.ticket; - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); + // Null request + result = session_pro_backend_get_pro_proof_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); } - // After freeing - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); - - // Null request - result = session_pro_backend_get_pro_revocations_request_to_json(nullptr); - REQUIRE(!result.success); - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); - } + SECTION("session_pro_backend_get_pro_revocations_request_to_json") { + session_pro_backend_get_pro_revocations_request request = {}; + request.version = 0; + request.ticket = 123; + + // Valid request + auto result = session_pro_backend_get_pro_revocations_request_to_json(&request); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProRevocationsRequest cpp = {}; + cpp.version = request.version; + cpp.ticket = request.ticket; + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } - SECTION("session_pro_backend_get_pro_payments_request_to_json") { - session_pro_backend_get_pro_payments_request request = {}; - request.version = 0; - request.master_pkey = master_pubkey; - request.master_sig = master_privkey; // Write some junk - request.unix_ts_s = unix_ts_s; - request.page = 1; + // After freeing + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); - // Valid request - auto result = session_pro_backend_get_pro_payments_request_to_json(&request); - { - scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; - REQUIRE(result.success); - REQUIRE(result.json.data != nullptr); - REQUIRE(result.json.size > 0); - - // Verify JSON matches C++ implementation - GetProPaymentsRequest cpp = {}; - cpp.version = 0; - std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}; - cpp.page = request.page; - std::string cpp_json = cpp.to_json(); - REQUIRE(string8_equals(result.json, cpp_json)); + // Null request + result = session_pro_backend_get_pro_revocations_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); } - // After freeing - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); + SECTION("session_pro_backend_get_pro_status_request_to_json") { + session_pro_backend_get_pro_status_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.master_sig = master_privkey; // Write some junk + request.unix_ts_s = unix_ts_s; + request.history = true; + + // Valid request + auto result = session_pro_backend_get_pro_status_request_to_json(&request); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + GetProStatusRequest cpp = {}; + cpp.version = 0; + std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); + std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}; + cpp.history = request.history; + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } - // Null request - result = session_pro_backend_get_pro_payments_request_to_json(nullptr); - REQUIRE(!result.success); - REQUIRE(result.json.data == nullptr); - REQUIRE(result.json.size == 0); - } + // After freeing + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); - SECTION("session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse") { - char fake_gen_index_hash[32]; - randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); - - nlohmann::json j; - j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; - j["result"] = { - {"version", 0}, - {"expiry_unix_ts_s", unix_ts_s}, - {"gen_index_hash", - oxenc::to_hex( - fake_gen_index_hash, fake_gen_index_hash + sizeof(fake_gen_index_hash))}, - {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, - {"sig", oxenc::to_hex(master_privkey.data)}}; - std::string json = j.dump(); - - // Valid JSON - session_pro_backend_add_pro_payment_or_get_pro_proof_response result = - session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( - json.data(), json.size()); - { - scope_exit result_free{[&]() { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); - }}; + // Null request + result = session_pro_backend_get_pro_status_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + } - for (size_t index = 0; index < result.header.errors_count; index++) - INFO(result.header.errors[index].data); - REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 0); + SECTION("session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse") { + char fake_gen_index_hash[32]; + randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); + + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = { + {"version", 0}, + {"expiry_unix_ts_s", unix_ts_s}, + {"gen_index_hash", + oxenc::to_hex( + fake_gen_index_hash, + fake_gen_index_hash + sizeof(fake_gen_index_hash))}, + {"rotating_pkey", oxenc::to_hex(rotating_pubkey.data)}, + {"sig", oxenc::to_hex(master_privkey.data)}}; + std::string json = j.dump(); + + // Valid JSON + session_pro_backend_add_pro_payment_or_get_pro_proof_response result = + session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + json.data(), json.size()); + { + scope_exit result_free{[&]() { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + }}; + + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.proof.expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp( + result.proof.gen_index_hash.data, + fake_gen_index_hash, + sizeof(fake_gen_index_hash)) == 0); + REQUIRE(std::memcmp( + result.proof.rotating_pubkey.data, + rotating_pubkey.data, + sizeof(rotating_pubkey)) == 0); + REQUIRE(std::memcmp( + result.proof.sig.data, + master_privkey.data, + sizeof(master_privkey)) == 0); + + // Here we also create the CPP version, we will run the conversion functions into + // pro proofs (both C and CPP variants) and then compare the two structures to make + // sure the conversion functions are sound. + auto result_cpp = AddProPaymentOrGetProProofResponse::parse(json); + + // Validate C and CPP variants + REQUIRE(result.proof.version == result_cpp.proof.version); + REQUIRE(std::memcmp( + result.proof.gen_index_hash.data, + result_cpp.proof.gen_index_hash.data(), + result_cpp.proof.gen_index_hash.size()) == 0); + REQUIRE(std::memcmp( + result.proof.rotating_pubkey.data, + result_cpp.proof.rotating_pubkey.data(), + result_cpp.proof.rotating_pubkey.size()) == 0); + REQUIRE(result.proof.expiry_unix_ts_s == + result_cpp.proof.expiry_unix_ts.time_since_epoch().count()); + REQUIRE(std::memcmp( + result.proof.sig.data, + result_cpp.proof.sig.data(), + result_cpp.proof.sig.size()) == 0); + } + + // After freeing + REQUIRE(result.header.internal_arena_buf_ == nullptr); REQUIRE(result.header.errors == nullptr); - REQUIRE(result.proof.expiry_unix_ts_s == unix_ts_s); - REQUIRE(std::memcmp( - result.proof.gen_index_hash.data, - fake_gen_index_hash, - sizeof(fake_gen_index_hash)) == 0); - REQUIRE(std::memcmp( - result.proof.rotating_pubkey.data, - rotating_pubkey.data, - sizeof(rotating_pubkey)) == 0); - REQUIRE(std::memcmp(result.proof.sig.data, master_privkey.data, sizeof(master_privkey)) == - 0); - - // Here we also create the CPP version, we will run the conversion functions into pro - // proofs (both C and CPP variants) and then compare the two structures to make sure the - // conversion functions are sound. - auto result_cpp = AddProPaymentOrGetProProofResponse::parse(json); - - // Validate C and CPP variants - REQUIRE(result.proof.version == result_cpp.proof.version); - REQUIRE(std::memcmp( - result.proof.gen_index_hash.data, - result_cpp.proof.gen_index_hash.data(), - result_cpp.proof.gen_index_hash.size()) == 0); - REQUIRE(std::memcmp( - result.proof.rotating_pubkey.data, - result_cpp.proof.rotating_pubkey.data(), - result_cpp.proof.rotating_pubkey.size()) == 0); - REQUIRE(result.proof.expiry_unix_ts_s == - result_cpp.proof.expiry_unix_ts.time_since_epoch().count()); - REQUIRE(std::memcmp( - result.proof.sig.data, - result_cpp.proof.sig.data(), - result_cpp.proof.sig.size()) == 0); - } + REQUIRE(result.header.errors_count == 0); - // After freeing - REQUIRE(result.header.internal_arena_buf_ == nullptr); - REQUIRE(result.header.errors == nullptr); - REQUIRE(result.header.errors_count == 0); + // Invalid JSON + json = "{invalid}"; + result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + json.data(), json.size()); + { + scope_exit result_free{[&]() { + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + }}; + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } - // Invalid JSON - json = "{invalid}"; - result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( - json.data(), json.size()); - { - scope_exit result_free{[&]() { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); - }}; + // After freeing + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); + + // Null JSON + result = + session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(nullptr, 0); REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors_count == 1); REQUIRE(result.header.errors != nullptr); - } - // After freeing - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); - REQUIRE(result.header.internal_arena_buf_ == nullptr); + // No need to free, as errors point to static memory + } - // Null JSON - result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(nullptr, 0); - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 1); - REQUIRE(result.header.errors != nullptr); + SECTION("session_pro_backend_get_pro_revocations_response_parse") { + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = {{"ticket", 123}, {"items", nlohmann::json::array()}}; - // No need to free, as errors point to static memory - } + char fake_gen_index_hash[32]; + randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); - SECTION("session_pro_backend_get_pro_revocations_response_parse") { - nlohmann::json j; - j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; - j["result"] = {{"ticket", 123}, {"items", nlohmann::json::array()}}; + auto obj = nlohmann::json::object(); + obj["expiry_unix_ts_s"] = unix_ts_s; + obj["gen_index_hash"] = oxenc::to_hex( + fake_gen_index_hash, fake_gen_index_hash + sizeof(fake_gen_index_hash)); + j["result"]["items"].push_back(obj); - char fake_gen_index_hash[32]; - randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); + std::string json = j.dump(); - auto obj = nlohmann::json::object(); - obj["expiry_unix_ts_s"] = unix_ts_s; - obj["gen_index_hash"] = oxenc::to_hex( - fake_gen_index_hash, fake_gen_index_hash + sizeof(fake_gen_index_hash)); - j["result"]["items"].push_back(obj); + // Valid JSON + auto result = session_pro_backend_get_pro_revocations_response_parse( + json.data(), json.size()); + { + scope_exit result_free{ + [&]() { session_pro_backend_get_pro_revocations_response_free(&result); }}; + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.ticket == 123); + REQUIRE(result.items_count == 1); + REQUIRE(result.items != nullptr); + REQUIRE(result.items[0].expiry_unix_ts_s == unix_ts_s); + REQUIRE(std::memcmp( + result.items[0].gen_index_hash.data, + fake_gen_index_hash, + sizeof(fake_gen_index_hash)) == 0); + } - std::string json = j.dump(); + // After freeeing + REQUIRE(result.header.internal_arena_buf_ == nullptr); + REQUIRE(result.items == nullptr); + REQUIRE(result.items_count == 0); - // Valid JSON - auto result = - session_pro_backend_get_pro_revocations_response_parse(json.data(), json.size()); - { - scope_exit result_free{ - [&]() { session_pro_backend_get_pro_revocations_response_free(&result); }}; - for (size_t index = 0; index < result.header.errors_count; index++) - INFO(result.header.errors[index].data); - REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 0); - REQUIRE(result.header.errors == nullptr); - REQUIRE(result.ticket == 123); - REQUIRE(result.items_count == 1); - REQUIRE(result.items != nullptr); - REQUIRE(result.items[0].expiry_unix_ts_s == unix_ts_s); - REQUIRE(std::memcmp( - result.items[0].gen_index_hash.data, - fake_gen_index_hash, - sizeof(fake_gen_index_hash)) == 0); - } + // Invalid JSON + json = "{invalid}"; + { + result = session_pro_backend_get_pro_revocations_response_parse( + json.data(), json.size()); + scope_exit result_free{ + [&]() { session_pro_backend_get_pro_revocations_response_free(&result); }}; + for (size_t index = 0; index < result.header.errors_count; index++) + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } - // After freeeing - REQUIRE(result.header.internal_arena_buf_ == nullptr); - REQUIRE(result.items == nullptr); - REQUIRE(result.items_count == 0); + // After freeing + REQUIRE(result.header.internal_arena_buf_ == nullptr); - // Invalid JSON - json = "{invalid}"; - { - result = session_pro_backend_get_pro_revocations_response_parse( - json.data(), json.size()); - scope_exit result_free{ - [&]() { session_pro_backend_get_pro_revocations_response_free(&result); }}; - for (size_t index = 0; index < result.header.errors_count; index++) - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count > 0); + // Null JSON + result = session_pro_backend_get_pro_revocations_response_parse(nullptr, 0); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 1); REQUIRE(result.header.errors != nullptr); } - // After freeing - REQUIRE(result.header.internal_arena_buf_ == nullptr); - - // Null JSON - result = session_pro_backend_get_pro_revocations_response_parse(nullptr, 0); - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 1); - REQUIRE(result.header.errors != nullptr); - } + SECTION("session_pro_backend_get_pro_status_response_parse") { + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = { + {"status", SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED}, + {"items", + nlohmann::json::array( + {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED}, + {"subscription_duration_s", 86400}, + {"activated_unix_ts_s", unix_ts_s}, + {"expired_unix_ts_s", unix_ts_s}, + {"refunded_unix_ts_s", unix_ts_s + 3600}, + {"redeemed_unix_ts_s", unix_ts_s - 3600}, + {"payment_provider", + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, + {"google_payment_token", + std::string( + payment_tx.payment_id, payment_tx.payment_id_count)}}})}}; + std::string json = j.dump(); + + // Valid JSON + auto result = + session_pro_backend_get_pro_status_response_parse(json.data(), json.size()); + { + scope_exit result_free{ + [&]() { session_pro_backend_get_pro_status_response_free(&result); }}; + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED); + REQUIRE(result.items_count == 1); + REQUIRE(result.items != nullptr); + REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED); + REQUIRE(result.items[0].subscription_duration_s == 86400); + REQUIRE(result.items[0].activated_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].expired_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].refunded_unix_ts_s == unix_ts_s + 3600); + REQUIRE(result.items[0].redeemed_unix_ts_s == unix_ts_s - 3600); + REQUIRE(result.items[0].payment_provider == + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE); + REQUIRE(result.items[0].google_payment_token_count == payment_tx.payment_id_count); + REQUIRE(std::memcmp( + result.items[0].google_payment_token, + payment_tx.payment_id, + payment_tx.payment_id_count) == 0); + } - SECTION("session_pro_backend_get_pro_payments_response_parse") { - nlohmann::json j; - j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; - j["result"] = { - {"pages", 2}, - {"payments", 10}, - {"items", - nlohmann::json::array( - {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED}, - {"subscription_duration_s", 86400}, - {"activated_unix_ts_s", unix_ts_s}, - {"expired_unix_ts_s", unix_ts_s}, - {"refunded_unix_ts_s", unix_ts_s + 3600}, - {"redeemed_unix_ts_s", unix_ts_s - 3600}, - {"payment_provider", - SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, - {"google_payment_token", - std::string(payment_tx.payment_id, payment_tx.payment_id_count)}}})}}; - std::string json = j.dump(); - - // Valid JSON - auto result = session_pro_backend_get_pro_payments_response_parse(json.data(), json.size()); - { - scope_exit result_free{ - [&]() { session_pro_backend_get_pro_payments_response_free(&result); }}; - for (size_t index = 0; index < result.header.errors_count; index++) - INFO(result.header.errors[index].data); - REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 0); - REQUIRE(result.header.errors == nullptr); - REQUIRE(result.pages == 2); - REQUIRE(result.payments == 10); - REQUIRE(result.items_count == 1); - REQUIRE(result.items != nullptr); - REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED); - REQUIRE(result.items[0].subscription_duration_s == 86400); - REQUIRE(result.items[0].activated_unix_ts_s == unix_ts_s); - REQUIRE(result.items[0].expired_unix_ts_s == unix_ts_s); - REQUIRE(result.items[0].refunded_unix_ts_s == unix_ts_s + 3600); - REQUIRE(result.items[0].redeemed_unix_ts_s == unix_ts_s - 3600); - REQUIRE(result.items[0].payment_provider == - SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE); - REQUIRE(result.items[0].google_payment_token_count == payment_tx.payment_id_count); - REQUIRE(std::memcmp( - result.items[0].google_payment_token, - payment_tx.payment_id, - payment_tx.payment_id_count) == 0); - } + // After freeing + REQUIRE(result.header.internal_arena_buf_ == nullptr); + REQUIRE(result.items == nullptr); + REQUIRE(result.items_count == 0); + + // Invalid JSON + json = "{invalid}"; + result = session_pro_backend_get_pro_status_response_parse(json.data(), json.size()); + { + std::unique_ptr> esult_free(nullptr, [&](void*) { + session_pro_backend_get_pro_status_response_free(&result); + }); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } - // After freeing - REQUIRE(result.header.internal_arena_buf_ == nullptr); - REQUIRE(result.items == nullptr); - REQUIRE(result.items_count == 0); + // After freeing + session_pro_backend_get_pro_status_response_free(&result); + REQUIRE(result.header.internal_arena_buf_ == nullptr); - // Invalid JSON - json = "{invalid}"; - result = session_pro_backend_get_pro_payments_response_parse(json.data(), json.size()); - { - std::unique_ptr> esult_free(nullptr, [&](void*) { - session_pro_backend_get_pro_payments_response_free(&result); - }); + // Null JSON + result = session_pro_backend_get_pro_status_response_parse(nullptr, 0); REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors_count == 1); REQUIRE(result.header.errors != nullptr); } - // After freeing - session_pro_backend_get_pro_payments_response_free(&result); - REQUIRE(result.header.internal_arena_buf_ == nullptr); + SECTION("Memory management edge cases") { + // Test freeing null/empty structs + session_pro_backend_to_json to_json = {}; + session_pro_backend_to_json_free(&to_json); + REQUIRE(to_json.json.data == nullptr); + REQUIRE(to_json.json.size == 0); - // Null JSON - result = session_pro_backend_get_pro_payments_response_parse(nullptr, 0); - REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(result.header.errors_count == 1); - REQUIRE(result.header.errors != nullptr); - } - - SECTION("Memory management edge cases") { - // Test freeing null/empty structs - session_pro_backend_to_json to_json = {}; - session_pro_backend_to_json_free(&to_json); - REQUIRE(to_json.json.data == nullptr); - REQUIRE(to_json.json.size == 0); - - session_pro_backend_add_pro_payment_or_get_pro_proof_response proof_response = {}; - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&proof_response); - REQUIRE(proof_response.header.internal_arena_buf_ == nullptr); + session_pro_backend_add_pro_payment_or_get_pro_proof_response proof_response = {}; + session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&proof_response); + REQUIRE(proof_response.header.internal_arena_buf_ == nullptr); - session_pro_backend_get_pro_revocations_response rev_response = {}; - session_pro_backend_get_pro_revocations_response_free(&rev_response); - REQUIRE(rev_response.header.internal_arena_buf_ == nullptr); + session_pro_backend_get_pro_revocations_response rev_response = {}; + session_pro_backend_get_pro_revocations_response_free(&rev_response); + REQUIRE(rev_response.header.internal_arena_buf_ == nullptr); - session_pro_backend_get_pro_payments_response pay_response = {}; - session_pro_backend_get_pro_payments_response_free(&pay_response); - REQUIRE(pay_response.header.internal_arena_buf_ == nullptr); + session_pro_backend_get_pro_status_response pay_response = {}; + session_pro_backend_get_pro_status_response_free(&pay_response); + REQUIRE(pay_response.header.internal_arena_buf_ == nullptr); + } } #if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) @@ -638,6 +656,19 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Add pro payment pro_proof first_pro_proof = {}; { + bytes32 fake_google_payment_token; + randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); + std::string fake_google_payment_token_hex = + oxenc::to_hex(fake_google_payment_token.data); + + session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; + payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; + payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + std::memcpy( + payment_tx.payment_id, + fake_google_payment_token_hex.data(), + payment_tx.payment_id_count); + // Build request session_pro_backend_master_rotating_signatures add_pro_sigs = session_pro_backend_add_pro_payment_request_build_sigs( @@ -685,6 +716,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Verify response first_pro_proof = response.proof; + INFO("Signature: " << oxenc::to_hex(first_pro_proof.sig.data) + << ", backend pubkey: " << oxenc::to_hex(DEV_BACKEND_PUBKEY)); REQUIRE(pro_proof_verify_signature( &first_pro_proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( @@ -754,43 +787,43 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); } - // Get payment history + // Get pro status { // Build request - session_pro_backend_get_pro_payments_request request = {}; + session_pro_backend_get_pro_status_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.unix_ts_s = time(nullptr); - request.page = 0; + request.history = true; session_pro_backend_signature sig = - session_pro_backend_get_pro_payments_request_build_sig( + session_pro_backend_get_pro_status_request_build_sig( request.version, master_privkey.data, sizeof(master_privkey.data), request.unix_ts_s, - request.page); + request.history); REQUIRE(sig.success); request.master_sig = sig.sig; // Do CURL request session_pro_backend_to_json request_json = - session_pro_backend_get_pro_payments_request_to_json(&request); + session_pro_backend_get_pro_status_request_to_json(&request); scope_exit request_json_free{ [&]() { session_pro_backend_to_json_free(&request_json); }}; std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/get_pro_payments", + "http://127.0.0.1:5000/get_pro_status", std::string_view(request_json.json.data, request_json.json.size)); // Parse response - session_pro_backend_get_pro_payments_response response = - session_pro_backend_get_pro_payments_response_parse( + session_pro_backend_get_pro_status_response response = + session_pro_backend_get_pro_status_response_parse( response_json.data(), response_json.size()); scope_exit response_free{ - [&]() { session_pro_backend_get_pro_payments_response_free(&response); }}; + [&]() { session_pro_backend_get_pro_status_response_free(&response); }}; for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; @@ -800,15 +833,76 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Verify the response REQUIRE(response.header.errors_count == 0); REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(response.pages == 0); - REQUIRE(response.payments > 0); + REQUIRE(response.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_ACTIVE); REQUIRE(response.items_count > 0); } + // Get pro status without history + { + // Build request + session_pro_backend_get_pro_status_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.unix_ts_s = time(nullptr); + + session_pro_backend_signature sig = + session_pro_backend_get_pro_status_request_build_sig( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + request.unix_ts_s, + request.history); + REQUIRE(sig.success); + request.master_sig = sig.sig; + + // Do CURL request + session_pro_backend_to_json request_json = + session_pro_backend_get_pro_status_request_to_json(&request); + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; + + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + "http://127.0.0.1:5000/get_pro_status", + std::string_view(request_json.json.data, request_json.json.size)); + + // Parse response + session_pro_backend_get_pro_status_response response = + session_pro_backend_get_pro_status_response_parse( + response_json.data(), response_json.size()); + scope_exit response_free{ + [&]() { session_pro_backend_get_pro_status_response_free(&response); }}; + + for (size_t index = 0; index < response.header.errors_count; index++) { + string8 error = response.header.errors[index]; + fprintf(stderr, "ERROR: %s\n", error.data); + } + + // Verify the response + REQUIRE(response.header.errors_count == 0); + REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(response.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_ACTIVE); + REQUIRE(response.items_count == 0); + } + // Add _another_ payment, same details. This creates a revocation for // the old proof and the subscription duration will stack, all old // proofs invalidated and new ones issued with the combined duration. { + bytes32 fake_google_payment_token; + randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); + std::string fake_google_payment_token_hex = + oxenc::to_hex(fake_google_payment_token.data); + + session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; + payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; + payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + std::memcpy( + payment_tx.payment_id, + fake_google_payment_token_hex.data(), + payment_tx.payment_id_count); + // Build request session_pro_backend_master_rotating_signatures add_pro_sigs = session_pro_backend_add_pro_payment_request_build_sigs( From 6a73637301a7ef7b56655b735bacd8cb94e9eefc Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 19 Sep 2025 11:22:19 +1000 Subject: [PATCH 083/171] Update pro backend to use millisecond timestamps --- include/session/pro_backend.h | 24 ++++--- include/session/pro_backend.hpp | 36 +++++----- include/session/session_protocol.h | 4 +- include/session/session_protocol.hpp | 10 +-- src/config/pro.cpp | 4 +- src/config/user_profile.cpp | 6 +- src/pro_backend.cpp | 100 +++++++++++++++------------ src/session_protocol.cpp | 22 +++--- tests/test_config_pro.cpp | 8 +-- tests/test_pro_backend.cpp | 78 +++++++++++---------- 10 files changed, 157 insertions(+), 135 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index d8fdcbe9..e5501bb9 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -117,7 +117,7 @@ typedef struct session_pro_backend_get_pro_proof_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; - uint64_t unix_ts_s; + uint64_t unix_ts_ms; bytes64 master_sig; bytes64 rotating_sig; } session_pro_backend_get_pro_proof_request; @@ -134,7 +134,7 @@ typedef struct session_pro_backend_get_pro_revocations_request { typedef struct session_pro_backend_pro_revocation_item { bytes32 gen_index_hash; - uint64_t expiry_unix_ts_s; + uint64_t expiry_unix_ts_ms; } session_pro_backend_pro_revocation_item; typedef struct session_pro_backend_get_pro_revocations_response { @@ -149,20 +149,22 @@ typedef struct session_pro_backend_get_pro_status_request { uint8_t version; bytes32 master_pkey; bytes64 master_sig; - uint64_t unix_ts_s; + uint64_t unix_ts_ms; bool history; } session_pro_backend_get_pro_status_request; typedef struct session_pro_backend_pro_payment_item { SESSION_PRO_BACKEND_PAYMENT_STATUS status; uint64_t subscription_duration_s; - uint64_t activated_unix_ts_s; - uint64_t expired_unix_ts_s; - uint64_t refunded_unix_ts_s; - uint64_t redeemed_unix_ts_s; + uint64_t activated_unix_ts_ms; + uint64_t expired_unix_ts_ms; + uint64_t refunded_unix_ts_ms; + uint64_t redeemed_unix_ts_ms; SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; char google_payment_token[128]; size_t google_payment_token_count; + char google_order_id[128]; + size_t google_order_id_count; char apple_original_tx_id[128]; size_t apple_original_tx_id_count; char apple_tx_id[128]; @@ -224,7 +226,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( /// - `master_privkey_len` -- Length of master_privkey. /// - `rotating_privkey` -- Ed25519 rotating private key (32-byte or 64-byte libsodium format). /// - `rotating_privkey_len` -- Length of rotating_privkey. -/// - `unix_ts_s` -- Unix timestamp (seconds) for the request. +/// - `unix_ts_ms` -- Unix timestamp for the request. /// /// Outputs: /// - `bool` - True if signatures are built successfully, false otherwise. @@ -239,7 +241,7 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof size_t master_privkey_len, const uint8_t* rotating_privkey, size_t rotating_privkey_len, - uint64_t unix_ts_s) NON_NULL_ARG(2, 4); + uint64_t unix_ts_ms) NON_NULL_ARG(2, 4); /// API: session_pro_backend/get_pro_status_request_build_sig /// @@ -251,7 +253,7 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof /// - `request_version` -- Version of the request. /// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). /// - `master_privkey_len` -- Length of master_privkey. -/// - `unix_ts_s` -- Unix timestamp (seconds) for the request. +/// - `unix_ts_ms` -- Unix timestamp for the request. /// - `page` -- The page in the paginated list of historical payments to request /// /// Outputs: @@ -264,7 +266,7 @@ session_pro_backend_signature session_pro_backend_get_pro_status_request_build_s uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, - uint64_t unix_ts_s, + uint64_t unix_ts_ms, uint32_t page) NON_NULL_ARG(2); /// API: session_pro_backend/add_pro_payment_request_to_json diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index dbfb7da8..9de0160e 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -170,8 +170,8 @@ struct GetProProofRequest { /// 32-byte Ed25519 Session Pro rotating public key authorized to use the generated proof array_uc32 rotating_pkey; - /// Unix timestamp (seconds) of the request - std::chrono::seconds unix_ts; + /// Unix timestamp of the request + std::chrono::sys_time unix_ts; /// 64-byte signature proving knowledge of the master key's secret component array_uc64 master_sig; @@ -189,7 +189,7 @@ struct GetProProofRequest { /// - `request_version` -- Version of the request to build a hash for /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key - /// - `unix_ts` -- Unix timestamp (seconds) for the request. + /// - `unix_ts` -- Unix timestamp for the request. /// /// Outputs: /// - `MasterRotatingSignatures` - Struct containing the 64-byte master and rotating signatures. @@ -197,7 +197,7 @@ struct GetProProofRequest { std::uint8_t request_version, std::span master_privkey, std::span rotating_privkey, - std::chrono::seconds unix_ts); + std::chrono::sys_time unix_ts); /// API: pro/GetProProofRequest::to_json /// @@ -233,8 +233,8 @@ struct ProRevocationItem { /// 32-byte hash of the generation index, identifying a proof array_uc32 gen_index_hash; - /// Unix timestamp (seconds) when the proof expires - std::chrono::sys_seconds expiry_unix_ts; + /// Unix timestamp when the proof expires + std::chrono::sys_time expiry_unix_ts; }; struct GetProRevocationsResponse : public ResponseHeader { @@ -267,8 +267,8 @@ struct GetProStatusRequest { /// 64-byte signature proving knowledge of the master public key's secret component array_uc64 master_sig; - /// Unix timestamp (seconds) of the request - std::chrono::sys_seconds unix_ts; + /// Unix timestamp of the request + std::chrono::sys_time unix_ts; /// Flag to request payment history from the backend bool history; @@ -282,7 +282,7 @@ struct GetProStatusRequest { /// Inputs: /// - `request_version` -- Version of the request to build a hash for /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key - /// - `unix_ts` -- Unix timestamp (seconds) for the request. + /// - `unix_ts` -- Unix timestamp for the request. /// - `history` -- Flag to request payment history from the backend /// /// Outputs: @@ -290,7 +290,7 @@ struct GetProStatusRequest { static array_uc64 build_sig( uint8_t version, std::span master_privkey, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, bool history); /// API: pro/GetProProofRequest::to_json @@ -306,18 +306,18 @@ struct ProPaymentItem { /// Describes the current status of the consumption of the payment for Session Pro entitlement SESSION_PRO_BACKEND_PAYMENT_STATUS status; - /// Unix timestamp (seconds) when the payment was activated for Session Pro. + /// Unix timestamp when the payment was activated for Session Pro. /// 0 if not activated (e.g., another active subscription or refunded). - std::chrono::sys_seconds activated_unix_ts; + std::chrono::sys_time activated_unix_ts; - /// Unix timestamp (seconds) when the payment was expired. 0 if not activated - std::chrono::sys_seconds expired_unix_ts; + /// Unix timestamp of when the payment was expired. 0 if not activated + std::chrono::sys_time expired_unix_ts; - /// Unix timestamp (seconds) when the payment was redeemed. 0 if not activated - std::chrono::sys_seconds redeemed_unix_ts; + /// Unix timestamp of when the payment was redeemed. 0 if not activated + std::chrono::sys_time redeemed_unix_ts; - /// Unix timestamp (seconds) when the payment was refunded. 0 if not activated - std::chrono::sys_seconds refunded_unix_ts; + /// Unix timestamp of when the payment was refunded. 0 if not activated + std::chrono::sys_time refunded_unix_ts; /// Subscription duration in seconds std::chrono::seconds subscription_duration; diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 8fc1602c..579386c8 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -41,7 +41,7 @@ typedef struct pro_proof { uint8_t version; bytes32 gen_index_hash; bytes32 rotating_pubkey; - uint64_t expiry_unix_ts_s; + uint64_t expiry_unix_ts_ms; bytes64 sig; } pro_proof; @@ -197,7 +197,7 @@ LIBSESSION_EXPORT bool pro_proof_verify_message( /// /// Outputs: /// - `bool` -- True if expired, false otherwise -LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) +LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_ms) NON_NULL_ARG(1); /// API: pro/pro_proof_status diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index e2d124a0..bae0654a 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -84,7 +84,7 @@ class ProProof { array_uc32 rotating_pubkey; /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid to - std::chrono::sys_seconds expiry_unix_ts; + std::chrono::sys_time expiry_unix_ts; /// Signature over the contents of the proof. It is signed by the Session Pro Backend key which /// is the entity responsible for issueing tamper-proof Sesison Pro certificates for Session @@ -128,12 +128,12 @@ class ProProof { /// proof's `expiry_unix_ts` /// /// Inputs: - /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` + /// - `unix_ts` -- Unix timestamp to compare against the embedded `expiry_unix_ts` /// to determine if the proof has expired or not /// /// Outputs: /// - `bool` - True if proof is active (i.e. has not expired), false otherwise. - bool is_active(std::chrono::sys_seconds unix_ts) const; + bool is_active(std::chrono::sys_time unix_ts) const; /// API: pro/Proof::status /// @@ -148,7 +148,7 @@ class ProProof { /// Inputs: /// - `verify_pubkey` -- 32 byte Ed25519 public key of the corresponding secret key to check if /// they are the original signatory of the proof. - /// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` + /// - `unix_ts` -- Unix timestamp to compared against the embedded `expiry_unix_ts` /// to determine if the proof has expired or not /// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if /// the embedded `rotating_pubkey` in the proof signed the given message. @@ -159,7 +159,7 @@ class ProProof { /// possible enum values. Otherwise this funtion can return all possible values. ProStatus status( std::span verify_pubkey, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, const std::optional& signed_msg); /// API: pro/Proof::hash diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 92787935..7cfd0bb4 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -100,8 +100,8 @@ LIBSESSION_C_API bool pro_config_verify_signature( config.proof.rotating_pubkey.data(), pro->proof.rotating_pubkey.data, sizeof pro->proof.rotating_pubkey.data); - config.proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts_s)); + config.proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(pro->proof.expiry_unix_ts_ms)); std::memcpy(config.proof.sig.data(), pro->proof.sig.data, sizeof pro->proof.sig.data); session::array_uc32 verify_pubkey_cpp; diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 3ba12181..28e31182 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -292,7 +292,7 @@ LIBSESSION_C_API bool user_profile_get_pro_config(const config_object* conf, pro pro->proof.rotating_pubkey.data, val->proof.rotating_pubkey.data(), val->proof.rotating_pubkey.size()); - pro->proof.expiry_unix_ts_s = val->proof.expiry_unix_ts.time_since_epoch().count(); + pro->proof.expiry_unix_ts_ms = val->proof.expiry_unix_ts.time_since_epoch().count(); std::memcpy(pro->proof.sig.data, val->proof.sig.data(), val->proof.sig.size()); return true; } @@ -310,8 +310,8 @@ LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro val.proof.rotating_pubkey.data(), pro->proof.rotating_pubkey.data, val.proof.rotating_pubkey.size()); - val.proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(pro->proof.expiry_unix_ts_s)); + val.proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(pro->proof.expiry_unix_ts_ms)); std::memcpy(val.proof.sig.data(), pro->proof.sig.data, val.proof.sig.size()); unbox(conf)->set_pro_config(val); } diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 37b6d508..bf2817d4 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -227,8 +227,9 @@ AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse( // Parse payload result.proof.version = json_require(result_obj, "version", result.errors); - auto expiry_unix_ts_s = json_require(result_obj, "expiry_unix_ts_s", result.errors); - result.proof.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts_s)); + auto expiry_unix_ts_ms = json_require(result_obj, "expiry_unix_ts_ms", result.errors); + result.proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(expiry_unix_ts_ms)); json_require_fixed_bytes_from_hex( result_obj, "gen_index_hash", result.errors, result.proof.gen_index_hash); json_require_fixed_bytes_from_hex( @@ -242,7 +243,7 @@ std::string GetProProofRequest::to_json() const { j["version"] = version; j["master_pkey"] = oxenc::to_hex(master_pkey); j["rotating_pkey"] = oxenc::to_hex(rotating_pkey); - j["unix_ts_s"] = unix_ts.count(); + j["unix_ts_ms"] = unix_ts.time_since_epoch().count(); j["master_sig"] = oxenc::to_hex(master_sig); j["rotating_sig"] = oxenc::to_hex(rotating_sig); std::string result = j.dump(); @@ -253,7 +254,7 @@ MasterRotatingSignatures GetProProofRequest::build_sigs( std::uint8_t request_version, std::span master_privkey, std::span rotating_privkey, - std::chrono::seconds unix_ts) { + std::chrono::sys_time unix_ts) { cleared_uc64 master_from_seed; if (master_privkey.size() == 32) { @@ -278,7 +279,7 @@ MasterRotatingSignatures GetProProofRequest::build_sigs( // Hash components to 32 bytes, must match: // https://github.com/Doy-lee/session-pro-backend/blob/5b66b1a4a64dc8da0225507019cbe21d7642fa78/backend.py#L631 uint8_t version = 0; - uint64_t unix_ts_s = unix_ts.count(); + uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; make_blake2b32_hasher(&state); @@ -288,7 +289,7 @@ MasterRotatingSignatures GetProProofRequest::build_sigs( crypto_generichash_blake2b_update( &state, rotating_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( - &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + &state, reinterpret_cast(&unix_ts_ms), sizeof(unix_ts_ms)); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash with both keys @@ -351,10 +352,11 @@ GetProRevocationsResponse GetProRevocationsResponse::parse(std::string_view json // Parse revocation item auto obj = it.get(); - auto expiry_unix_ts = json_require(obj, "expiry_unix_ts_s", result.errors); + auto expiry_unix_ts = json_require(obj, "expiry_unix_ts_ms", result.errors); ProRevocationItem item = {}; - item.expiry_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expiry_unix_ts)); + item.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(expiry_unix_ts)); json_require_fixed_bytes_from_hex( obj, "gen_index_hash", result.errors, item.gen_index_hash); @@ -372,7 +374,7 @@ std::string GetProStatusRequest::to_json() const { j["version"] = version; j["master_pkey"] = oxenc::to_hex(master_pkey); j["master_sig"] = oxenc::to_hex(master_sig); - j["unix_ts_s"] = unix_ts.time_since_epoch().count(); + j["unix_ts_ms"] = unix_ts.time_since_epoch().count(); j["history"] = history; std::string result = j.dump(); return result; @@ -381,7 +383,7 @@ std::string GetProStatusRequest::to_json() const { array_uc64 GetProStatusRequest::build_sig( uint8_t version, std::span master_privkey, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, bool history) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { @@ -397,7 +399,7 @@ array_uc64 GetProStatusRequest::build_sig( // https://github.com/Doy-lee/session-pro-backend/blob/635b14fc93302658de6c07c017f705673fc7c57f/server.py#L395 array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; - uint64_t unix_ts_s = unix_ts.time_since_epoch().count(); + uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); make_blake2b32_hasher(&state); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( @@ -405,7 +407,7 @@ array_uc64 GetProStatusRequest::build_sig( master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( - &state, reinterpret_cast(&unix_ts_s), sizeof(unix_ts_s)); + &state, reinterpret_cast(&unix_ts_ms), sizeof(unix_ts_ms)); uint8_t history_u8 = history; crypto_generichash_blake2b_update( &state, reinterpret_cast(&history_u8), sizeof(history_u8)); @@ -463,10 +465,10 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { // Parse payment item auto obj = it.get(); auto status = json_require(obj, "status", result.errors); - auto activated_ts = json_require(obj, "activated_unix_ts_s", result.errors); - auto expired_ts = json_require(obj, "expired_unix_ts_s", result.errors); - auto redeemed_ts = json_require(obj, "redeemed_unix_ts_s", result.errors); - auto refunded_ts = json_require(obj, "refunded_unix_ts_s", result.errors); + auto activated_ts = json_require(obj, "activated_unix_ts_ms", result.errors); + auto expired_ts = json_require(obj, "expired_unix_ts_ms", result.errors); + auto redeemed_ts = json_require(obj, "redeemed_unix_ts_ms", result.errors); + auto refunded_ts = json_require(obj, "refunded_unix_ts_ms", result.errors); auto sub_duration_s = json_require(obj, "subscription_duration_s", result.errors); auto payment_provider = json_require(obj, "payment_provider", result.errors); @@ -478,10 +480,14 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { result.errors.push_back(fmt::format("Status value was out-of-bounds: {}", status)); } - item.activated_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(activated_ts)); - item.expired_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(expired_ts)); - item.redeemed_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(redeemed_ts)); - item.refunded_unix_ts = std::chrono::sys_seconds(std::chrono::seconds(refunded_ts)); + item.activated_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(activated_ts)); + item.expired_unix_ts = + std::chrono::sys_time(std::chrono::milliseconds(expired_ts)); + item.redeemed_unix_ts = + std::chrono::sys_time(std::chrono::milliseconds(redeemed_ts)); + item.refunded_unix_ts = + std::chrono::sys_time(std::chrono::milliseconds(refunded_ts)); item.subscription_duration = std::chrono::seconds(sub_duration_s); if (payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL && payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { @@ -595,16 +601,20 @@ session_pro_backend_get_pro_proof_request_build_sigs( size_t master_privkey_len, const uint8_t* rotating_privkey, size_t rotating_privkey_len, - uint64_t unix_ts_s) { + uint64_t unix_ts_ms) { // Convert C inputs to C++ types std::span master_span(master_privkey, master_privkey_len); std::span rotating_span(rotating_privkey, rotating_privkey_len); - std::chrono::seconds ts{unix_ts_s}; + std::chrono::milliseconds ts{unix_ts_ms}; session_pro_backend_master_rotating_signatures result = {}; try { - auto sigs = GetProProofRequest::build_sigs(request_version, master_span, rotating_span, ts); + auto sigs = GetProProofRequest::build_sigs( + request_version, + master_span, + rotating_span, + std::chrono::sys_time(ts)); std::memcpy(result.master_sig.data, sigs.master_sig.data(), sigs.master_sig.size()); std::memcpy(result.rotating_sig.data, sigs.rotating_sig.data(), sigs.rotating_sig.size()); result.success = true; @@ -625,11 +635,11 @@ session_pro_backend_get_pro_status_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, - uint64_t unix_ts_s, + uint64_t unix_ts_ms, uint32_t page) { // Convert C inputs to C++ types std::span master_span{master_privkey, master_privkey_len}; - std::chrono::sys_seconds ts{std::chrono::seconds(unix_ts_s)}; + std::chrono::sys_time ts{std::chrono::milliseconds(unix_ts_ms)}; session_pro_backend_signature result = {}; try { @@ -686,7 +696,8 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_r cpp.version = request->version; std::memcpy(cpp.master_pkey.data(), request->master_pkey.data, cpp.master_pkey.size()); std::memcpy(cpp.rotating_pkey.data(), request->rotating_pkey.data, cpp.rotating_pkey.size()); - cpp.unix_ts = std::chrono::seconds{request->unix_ts_s}; + cpp.unix_ts = std::chrono::sys_time{ + std::chrono::milliseconds(request->unix_ts_ms)}; std::memcpy(cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); std::memcpy(cpp.rotating_sig.data(), request->rotating_sig.data, cpp.rotating_sig.size()); @@ -734,7 +745,8 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_ std::memcpy( cpp.master_pkey.data(), request->master_pkey.data, sizeof(request->master_pkey.data)); std::memcpy(cpp.master_sig.data(), request->master_sig.data, sizeof(request->master_sig.data)); - cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{request->unix_ts_s}}; + cpp.unix_ts = std::chrono::sys_time{ + std::chrono::milliseconds{request->unix_ts_ms}}; cpp.history = request->history; try { @@ -786,9 +798,9 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( // error response returns the same struct just with different fields populated. result.header.status = cpp.status; result.proof.version = cpp.proof.version; - result.proof.expiry_unix_ts_s = - std::chrono::duration_cast(cpp.proof.expiry_unix_ts.time_since_epoch()) - .count(); + result.proof.expiry_unix_ts_ms = std::chrono::duration_cast( + cpp.proof.expiry_unix_ts.time_since_epoch()) + .count(); std::memcpy( result.proof.gen_index_hash.data, cpp.proof.gen_index_hash.data(), @@ -870,9 +882,9 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t const ProRevocationItem& src = cpp.items[index]; session_pro_backend_pro_revocation_item& dest = result.items[index]; std::memcpy(dest.gen_index_hash.data, src.gen_index_hash.data(), src.gen_index_hash.size()); - dest.expiry_unix_ts_s = std::chrono::duration_cast( - src.expiry_unix_ts.time_since_epoch()) - .count(); + dest.expiry_unix_ts_ms = std::chrono::duration_cast( + src.expiry_unix_ts.time_since_epoch()) + .count(); } return result; } @@ -924,18 +936,18 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ dest.status = src.status; dest.subscription_duration_s = std::chrono::duration_cast(src.subscription_duration).count(); - dest.activated_unix_ts_s = std::chrono::duration_cast( - src.activated_unix_ts.time_since_epoch()) - .count(); - dest.expired_unix_ts_s = std::chrono::duration_cast( - src.expired_unix_ts.time_since_epoch()) - .count(); - dest.refunded_unix_ts_s = std::chrono::duration_cast( - src.refunded_unix_ts.time_since_epoch()) - .count(); - dest.redeemed_unix_ts_s = std::chrono::duration_cast( - src.redeemed_unix_ts.time_since_epoch()) + dest.activated_unix_ts_ms = std::chrono::duration_cast( + src.activated_unix_ts.time_since_epoch()) + .count(); + dest.expired_unix_ts_ms = std::chrono::duration_cast( + src.expired_unix_ts.time_since_epoch()) .count(); + dest.refunded_unix_ts_ms = std::chrono::duration_cast( + src.refunded_unix_ts.time_since_epoch()) + .count(); + dest.redeemed_unix_ts_ms = std::chrono::duration_cast( + src.redeemed_unix_ts.time_since_epoch()) + .count(); dest.payment_provider = src.payment_provider; switch (dest.payment_provider) { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index f64c02d2..d4cf11ef 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -69,8 +69,8 @@ bool proof_verify_message_internal( return result; } -bool proof_is_active_internal(uint64_t expiry_unix_ts, uint64_t unix_ts_s) { - bool result = unix_ts_s <= expiry_unix_ts; +bool proof_is_active_internal(uint64_t expiry_unix_ts_ms, uint64_t unix_ts_ms) { + bool result = unix_ts_ms <= expiry_unix_ts_ms; return result; } } // namespace @@ -100,15 +100,17 @@ bool ProProof::verify_message(std::span sig, std::span unix_ts) const { bool result = proof_is_active_internal( - expiry_unix_ts.time_since_epoch().count(), unix_ts.time_since_epoch().count()); + std::chrono::duration_cast(expiry_unix_ts.time_since_epoch()) + .count(), + unix_ts.time_since_epoch().count()); return result; } ProStatus ProProof::status( std::span verify_pubkey, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, const std::optional& signed_msg) { ProStatus result = ProStatus::Valid; // Verify the at the proof is verified by the Session Pro Backend key (e.g.: It was @@ -699,7 +701,7 @@ LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { proof->version, proof->gen_index_hash.data, proof->rotating_pubkey.data, - proof->expiry_unix_ts_s); + proof->expiry_unix_ts_ms); std::memcpy(result.data, hash.data(), hash.size()); } return result; @@ -714,7 +716,7 @@ LIBSESSION_C_API bool pro_proof_verify_signature( proof->version, proof->gen_index_hash.data, proof->rotating_pubkey.data, - proof->expiry_unix_ts_s); + proof->expiry_unix_ts_ms); bool result = proof_verify_signature_internal(hash, proof->sig.data, verify_pubkey_span); return result; } @@ -731,8 +733,8 @@ LIBSESSION_C_API bool pro_proof_verify_message( return result; } -LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_s) { - bool result = proof && proof_is_active_internal(proof->expiry_unix_ts_s, unix_ts_s); +LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_ms) { + bool result = proof && proof_is_active_internal(proof->expiry_unix_ts_ms, unix_ts_ms); return result; } @@ -1024,7 +1026,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const DecryptedPro& pro = *result_cpp.pro; result.pro_status = static_cast(pro.status); result.pro_proof.version = pro.proof.version; - result.pro_proof.expiry_unix_ts_s = + result.pro_proof.expiry_unix_ts_ms = static_cast(pro.proof.expiry_unix_ts.time_since_epoch().count()); result.pro_features = pro.features; diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 21c04bf2..3ef50ede 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -35,7 +35,7 @@ TEST_CASE("Pro", "[config][pro]") { std::memcpy(pro.rotating_privkey.data, rotating_sk.data(), rotating_sk.size()); pro.proof.version = pro_cpp.proof.version; std::memcpy(pro.proof.rotating_pubkey.data, rotating_pk.data(), rotating_pk.size()); - pro.proof.expiry_unix_ts_s = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); + pro.proof.expiry_unix_ts_ms = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); std::memcpy(pro.proof.gen_index_hash.data, gen_index_hash.data(), gen_index_hash.size()); } @@ -80,10 +80,10 @@ TEST_CASE("Pro", "[config][pro]") { // Verify expiry { CHECK(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts)); - CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1s)); + CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1ms)); - CHECK(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_s)); - CHECK_FALSE(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_s + 1)); + CHECK(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms)); + CHECK_FALSE(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms + 1)); } // Verify it can verify messages signed with the rotating public key diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 5bfea953..9ffc4973 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -31,16 +31,16 @@ static bool string8_equals(string8 s8, std::string_view str) { fprintf(stderr, "proof.rotating_pubkey: %s\n", oxenc::to_hex(proof.rotating_pubkey.data).c_str()); - fprintf(stderr, "proof.expiry_unix_ts_s: %zu\n", proof.expiry_unix_ts_s); + fprintf(stderr, "proof.expiry_unix_ts_ms: %zu\n", proof.expiry_unix_ts_ms); fprintf(stderr, "proof.sig: %s\n", oxenc::to_hex(proof.sig.data).c_str()); } [[maybe_unused]] static void dump_pro_payment_item( const session_pro_backend_pro_payment_item& item) { - fprintf(stderr, "item.activated_unix_ts_s: %zu\n", item.activated_unix_ts_s); - fprintf(stderr, "item.expired_unix_ts_s: %zu\n", item.expired_unix_ts_s); - fprintf(stderr, "item.redeemed_unix_ts_s: %zu\n", item.redeemed_unix_ts_s); - fprintf(stderr, "item.refunded_unix_ts_s: %zu\n", item.refunded_unix_ts_s); + fprintf(stderr, "item.activated_unix_ts_ms: %zu\n", item.activated_unix_ts_ms); + fprintf(stderr, "item.expired_unix_ts_ms: %zu\n", item.expired_unix_ts_ms); + fprintf(stderr, "item.redeemed_unix_ts_ms: %zu\n", item.redeemed_unix_ts_ms); + fprintf(stderr, "item.refunded_unix_ts_ms: %zu\n", item.refunded_unix_ts_ms); fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration_s); fprintf(stderr, "item.payment_provider: %u\n", item.payment_provider); fprintf(stderr, @@ -60,7 +60,7 @@ static bool string8_equals(string8 s8, std::string_view str) { [[maybe_unused]] static void dump_pro_revocation( const session_pro_backend_pro_revocation_item& item) { - fprintf(stderr, "item.expiry_unix_ts: %zu\n", item.expiry_unix_ts_s); + fprintf(stderr, "item.expiry_unix_ts: %zu\n", item.expiry_unix_ts_ms); fprintf(stderr, "item.gen_index_hash: %s\n", oxenc::to_hex(item.gen_index_hash.data).c_str()); } @@ -124,7 +124,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { fake_google_payment_token_hex.data(), payment_tx.payment_id_count); - uint64_t unix_ts_s = 1698765432; // Arbitrary timestamp + uint64_t unix_ts_ms = 1698765432ULL * 1000; // Arbitrary timestamp SECTION("session_pro_backend_add_pro_payment_request_build_sigs") { // Valid inputs @@ -184,13 +184,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey), - unix_ts_s); + unix_ts_ms); REQUIRE(result.success); REQUIRE(result.error_count == 0); // Verify signatures match C++ implementation auto cpp_sigs = GetProProofRequest::build_sigs( - 0, master_privkey.data, rotating_privkey.data, std::chrono::seconds{unix_ts_s}); + 0, + master_privkey.data, + rotating_privkey.data, + std::chrono::sys_time( + std::chrono::milliseconds{unix_ts_ms})); REQUIRE(std::memcmp( result.master_sig.data, cpp_sigs.master_sig.data(), @@ -207,7 +211,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey) - 1, - unix_ts_s); + unix_ts_ms); REQUIRE(!result.success); REQUIRE(result.error_count > 0); } @@ -263,7 +267,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; - request.unix_ts_s = unix_ts_s; + request.unix_ts_ms = unix_ts_ms; // Note just write some junk to the request request.master_sig = master_privkey; @@ -283,7 +287,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); std::memcpy( cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); - cpp.unix_ts = std::chrono::seconds{unix_ts_s}; + cpp.unix_ts = std::chrono::sys_time( + std::chrono::milliseconds{unix_ts_ms}); std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); std::memcpy( cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); @@ -339,7 +344,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.version = 0; request.master_pkey = master_pubkey; request.master_sig = master_privkey; // Write some junk - request.unix_ts_s = unix_ts_s; + request.unix_ts_ms = unix_ts_ms; request.history = true; // Valid request @@ -355,7 +360,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { cpp.version = 0; std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); - cpp.unix_ts = std::chrono::sys_seconds{std::chrono::seconds{unix_ts_s}}; + cpp.unix_ts = std::chrono::sys_time{ + std::chrono::milliseconds{unix_ts_ms}}; cpp.history = request.history; std::string cpp_json = cpp.to_json(); REQUIRE(string8_equals(result.json, cpp_json)); @@ -380,7 +386,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { {"version", 0}, - {"expiry_unix_ts_s", unix_ts_s}, + {"expiry_unix_ts_ms", unix_ts_ms}, {"gen_index_hash", oxenc::to_hex( fake_gen_index_hash, @@ -403,7 +409,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count == 0); REQUIRE(result.header.errors == nullptr); - REQUIRE(result.proof.expiry_unix_ts_s == unix_ts_s); + REQUIRE(result.proof.expiry_unix_ts_ms == unix_ts_ms); REQUIRE(std::memcmp( result.proof.gen_index_hash.data, fake_gen_index_hash, @@ -432,7 +438,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { result.proof.rotating_pubkey.data, result_cpp.proof.rotating_pubkey.data(), result_cpp.proof.rotating_pubkey.size()) == 0); - REQUIRE(result.proof.expiry_unix_ts_s == + REQUIRE(result.proof.expiry_unix_ts_ms == result_cpp.proof.expiry_unix_ts.time_since_epoch().count()); REQUIRE(std::memcmp( result.proof.sig.data, @@ -481,7 +487,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); auto obj = nlohmann::json::object(); - obj["expiry_unix_ts_s"] = unix_ts_s; + obj["expiry_unix_ts_ms"] = unix_ts_ms; obj["gen_index_hash"] = oxenc::to_hex( fake_gen_index_hash, fake_gen_index_hash + sizeof(fake_gen_index_hash)); j["result"]["items"].push_back(obj); @@ -502,7 +508,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.ticket == 123); REQUIRE(result.items_count == 1); REQUIRE(result.items != nullptr); - REQUIRE(result.items[0].expiry_unix_ts_s == unix_ts_s); + REQUIRE(result.items[0].expiry_unix_ts_ms == unix_ts_ms); REQUIRE(std::memcmp( result.items[0].gen_index_hash.data, fake_gen_index_hash, @@ -546,10 +552,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { nlohmann::json::array( {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED}, {"subscription_duration_s", 86400}, - {"activated_unix_ts_s", unix_ts_s}, - {"expired_unix_ts_s", unix_ts_s}, - {"refunded_unix_ts_s", unix_ts_s + 3600}, - {"redeemed_unix_ts_s", unix_ts_s - 3600}, + {"activated_unix_ts_ms", unix_ts_ms}, + {"expired_unix_ts_ms", unix_ts_ms}, + {"refunded_unix_ts_ms", unix_ts_ms + 3600}, + {"redeemed_unix_ts_ms", unix_ts_ms - 3600}, {"payment_provider", SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, {"google_payment_token", @@ -573,10 +579,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.items != nullptr); REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED); REQUIRE(result.items[0].subscription_duration_s == 86400); - REQUIRE(result.items[0].activated_unix_ts_s == unix_ts_s); - REQUIRE(result.items[0].expired_unix_ts_s == unix_ts_s); - REQUIRE(result.items[0].refunded_unix_ts_s == unix_ts_s + 3600); - REQUIRE(result.items[0].redeemed_unix_ts_s == unix_ts_s - 3600); + REQUIRE(result.items[0].activated_unix_ts_ms == unix_ts_ms); + REQUIRE(result.items[0].expired_unix_ts_ms == unix_ts_ms); + REQUIRE(result.items[0].refunded_unix_ts_ms == unix_ts_ms + 3600); + REQUIRE(result.items[0].redeemed_unix_ts_ms == unix_ts_ms - 3600); REQUIRE(result.items[0].payment_provider == SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE); REQUIRE(result.items[0].google_payment_token_count == payment_tx.payment_id_count); @@ -728,7 +734,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Authorise new key { - uint64_t now_unix_ts_s = time(nullptr); + uint64_t now_unix_ts_ms = time(nullptr) * 1000; // Build request session_pro_backend_master_rotating_signatures pro_sigs = session_pro_backend_get_pro_proof_request_build_sigs( @@ -737,13 +743,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey), - now_unix_ts_s); + now_unix_ts_ms); session_pro_backend_get_pro_proof_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; - request.unix_ts_s = now_unix_ts_s; + request.unix_ts_ms = now_unix_ts_ms; request.master_sig = pro_sigs.master_sig; request.rotating_sig = pro_sigs.rotating_sig; @@ -793,7 +799,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_status_request request = {}; request.version = 0; request.master_pkey = master_pubkey; - request.unix_ts_s = time(nullptr); + request.unix_ts_ms = time(nullptr) * 1000; request.history = true; session_pro_backend_signature sig = @@ -801,7 +807,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.version, master_privkey.data, sizeof(master_privkey.data), - request.unix_ts_s, + request.unix_ts_ms, request.history); REQUIRE(sig.success); request.master_sig = sig.sig; @@ -843,14 +849,14 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_status_request request = {}; request.version = 0; request.master_pkey = master_pubkey; - request.unix_ts_s = time(nullptr); + request.unix_ts_ms = time(nullptr) * 1000; session_pro_backend_signature sig = session_pro_backend_get_pro_status_request_build_sig( request.version, master_privkey.data, sizeof(master_privkey.data), - request.unix_ts_s, + request.unix_ts_ms, request.history); REQUIRE(sig.success); request.master_sig = sig.sig; @@ -997,8 +1003,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { first_pro_proof.gen_index_hash.data, sizeof(first_pro_proof.gen_index_hash)) == 0); - REQUIRE(response.items[response.items_count - 1].expiry_unix_ts_s == - first_pro_proof.expiry_unix_ts_s); + REQUIRE(response.items[response.items_count - 1].expiry_unix_ts_ms == + first_pro_proof.expiry_unix_ts_ms); } } #endif From 4108213b8adc33fc9fd8507f1fd674f3d1d55295 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 23 Sep 2025 15:22:16 +1000 Subject: [PATCH 084/171] Update pro backend status API to handle new grace ts response --- include/session/pro_backend.h | 7 ++++--- include/session/pro_backend.hpp | 22 ++++++++++++++++------ src/pro_backend.cpp | 31 ++++++++++++++++++++----------- tests/test_pro_backend.cpp | 20 ++++++++++++-------- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index e5501bb9..35ccd036 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -31,7 +31,6 @@ typedef enum SESSION_PRO_BACKEND_PAYMENT_STATUS { SESSION_PRO_BACKEND_PAYMENT_STATUS_NIL, SESSION_PRO_BACKEND_PAYMENT_STATUS_UNREDEEMED, SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED, - SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED, SESSION_PRO_BACKEND_PAYMENT_STATUS_EXPIRED, SESSION_PRO_BACKEND_PAYMENT_STATUS_REFUNDED, SESSION_PRO_BACKEND_PAYMENT_STATUS_COUNT, @@ -156,8 +155,8 @@ typedef struct session_pro_backend_get_pro_status_request { typedef struct session_pro_backend_pro_payment_item { SESSION_PRO_BACKEND_PAYMENT_STATUS status; uint64_t subscription_duration_s; - uint64_t activated_unix_ts_ms; - uint64_t expired_unix_ts_ms; + uint64_t grace_unix_ts_ms; + uint64_t expiry_unix_ts_ms; uint64_t refunded_unix_ts_ms; uint64_t redeemed_unix_ts_ms; SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; @@ -178,6 +177,8 @@ typedef struct session_pro_backend_get_pro_status_response { /// Array of payment items, with items_count elements session_pro_backend_pro_payment_item* items; size_t items_count; + uint64_t latest_expiry_unix_ts_ms; + uint64_t latest_grace_unix_ts_ms; SESSION_PRO_BACKEND_USER_PRO_STATUS status; } session_pro_backend_get_pro_status_response; diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 9de0160e..e8f54630 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -209,7 +209,7 @@ struct GetProProofRequest { }; /// Retrieve the current list of revocations for currently active Session Pro proofs (because of -/// refunds for example). The caller should maintain this list until the revocation has expired and +/// refunds for example). The caller should maintain this list until the revocation has expiry and /// periodically retrieve this list from the backend every hour. struct GetProRevocationsRequest { /// Request version. The latest accepted version is 0 @@ -306,12 +306,13 @@ struct ProPaymentItem { /// Describes the current status of the consumption of the payment for Session Pro entitlement SESSION_PRO_BACKEND_PAYMENT_STATUS status; - /// Unix timestamp when the payment was activated for Session Pro. - /// 0 if not activated (e.g., another active subscription or refunded). - std::chrono::sys_time activated_unix_ts; + /// Unix timestamp of when the payment was expiry. 0 if not activated + std::chrono::sys_time expiry_unix_ts; - /// Unix timestamp of when the payment was expired. 0 if not activated - std::chrono::sys_time expired_unix_ts; + /// Unix timestamp when the payment provider will start to attempt to renew the Session Pro + /// subscription. During the period between [grace_unix_ts, expiry_unix_ts] the user continues + /// to have entitlement to Session Pro. This is set to 0 if auto-renewal is not enabled. + std::chrono::sys_time grace_unix_ts; /// Unix timestamp of when the payment was redeemed. 0 if not activated std::chrono::sys_time redeemed_unix_ts; @@ -348,6 +349,15 @@ struct GetProStatusResponse : public ResponseHeader { /// Current Session Pro entitlement status for the master public key SESSION_PRO_BACKEND_USER_PRO_STATUS user_status; + /// Unix timestamp of when the the latest payment will expire. 0 if no payments are available + /// for the requested Session Pro master public key. + std::chrono::sys_time latest_expiry_unix_ts; + + /// Unix timestamp when the payment provider will start to attempt to renew the Session Pro + /// subscription. During the period between [grace_unix_ts, expiry_unix_ts] the user continues + /// to have entitlement to Session Pro. This is set to 0 if auto-renewal is not enabled. + std::chrono::sys_time latest_grace_unix_ts; + /// API: pro/GetProPaymentsResponse::parse /// /// Parses a JSON string into the response struct. diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index bf2817d4..f38a32db 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -452,6 +452,13 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { } result.user_status = static_cast(user_status); + uint64_t latest_grace_ts = json_require(result_obj, "latest_grace_unix_ts_ms", result.errors); + uint64_t latest_expiry_ts = json_require(result_obj, "latest_expiry_unix_ts_ms", result.errors); + result.latest_grace_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(latest_grace_ts)); + result.latest_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(latest_expiry_ts)); + auto array = json_require(result_obj, "items", result.errors); result.items.reserve(array.size()); for (size_t index = 0; index < array.size(); index++) { @@ -465,8 +472,8 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { // Parse payment item auto obj = it.get(); auto status = json_require(obj, "status", result.errors); - auto activated_ts = json_require(obj, "activated_unix_ts_ms", result.errors); - auto expired_ts = json_require(obj, "expired_unix_ts_ms", result.errors); + auto grace_ts = json_require(obj, "grace_unix_ts_ms", result.errors); + auto expiry_ts = json_require(obj, "expiry_unix_ts_ms", result.errors); auto redeemed_ts = json_require(obj, "redeemed_unix_ts_ms", result.errors); auto refunded_ts = json_require(obj, "refunded_unix_ts_ms", result.errors); auto sub_duration_s = json_require(obj, "subscription_duration_s", result.errors); @@ -480,10 +487,10 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { result.errors.push_back(fmt::format("Status value was out-of-bounds: {}", status)); } - item.activated_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(activated_ts)); - item.expired_unix_ts = - std::chrono::sys_time(std::chrono::milliseconds(expired_ts)); + item.grace_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(grace_ts)); + item.expiry_unix_ts = + std::chrono::sys_time(std::chrono::milliseconds(expiry_ts)); item.redeemed_unix_ts = std::chrono::sys_time(std::chrono::milliseconds(redeemed_ts)); item.refunded_unix_ts = @@ -929,6 +936,8 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ result.items_count = cpp.items.size(); result.items = (session_pro_backend_pro_payment_item*)arena_alloc( &arena, result.items_count * sizeof(*result.items)); + result.latest_expiry_unix_ts_ms = cpp.latest_expiry_unix_ts.time_since_epoch().count(); + result.latest_grace_unix_ts_ms = cpp.latest_grace_unix_ts.time_since_epoch().count(); for (size_t index = 0; index < result.items_count; ++index) { const ProPaymentItem& src = cpp.items[index]; @@ -936,12 +945,12 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ dest.status = src.status; dest.subscription_duration_s = std::chrono::duration_cast(src.subscription_duration).count(); - dest.activated_unix_ts_ms = std::chrono::duration_cast( - src.activated_unix_ts.time_since_epoch()) + dest.grace_unix_ts_ms = std::chrono::duration_cast( + src.grace_unix_ts.time_since_epoch()) .count(); - dest.expired_unix_ts_ms = std::chrono::duration_cast( - src.expired_unix_ts.time_since_epoch()) - .count(); + dest.expiry_unix_ts_ms = std::chrono::duration_cast( + src.expiry_unix_ts.time_since_epoch()) + .count(); dest.refunded_unix_ts_ms = std::chrono::duration_cast( src.refunded_unix_ts.time_since_epoch()) .count(); diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 9ffc4973..8dca629f 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -37,8 +37,8 @@ static bool string8_equals(string8 s8, std::string_view str) { [[maybe_unused]] static void dump_pro_payment_item( const session_pro_backend_pro_payment_item& item) { - fprintf(stderr, "item.activated_unix_ts_ms: %zu\n", item.activated_unix_ts_ms); - fprintf(stderr, "item.expired_unix_ts_ms: %zu\n", item.expired_unix_ts_ms); + fprintf(stderr, "item.expiry_unix_ts_ms: %zu\n", item.expiry_unix_ts_ms); + fprintf(stderr, "item.grace_unix_ts_ms: %zu\n", item.grace_unix_ts_ms); fprintf(stderr, "item.redeemed_unix_ts_ms: %zu\n", item.redeemed_unix_ts_ms); fprintf(stderr, "item.refunded_unix_ts_ms: %zu\n", item.refunded_unix_ts_ms); fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration_s); @@ -548,12 +548,14 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { {"status", SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED}, + {"latest_grace_unix_ts_ms", unix_ts_ms + 1}, + {"latest_expiry_unix_ts_ms", unix_ts_ms + 2}, {"items", nlohmann::json::array( - {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED}, + {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED}, {"subscription_duration_s", 86400}, - {"activated_unix_ts_ms", unix_ts_ms}, - {"expired_unix_ts_ms", unix_ts_ms}, + {"grace_unix_ts_ms", unix_ts_ms}, + {"expiry_unix_ts_ms", unix_ts_ms}, {"refunded_unix_ts_ms", unix_ts_ms + 3600}, {"redeemed_unix_ts_ms", unix_ts_ms - 3600}, {"payment_provider", @@ -576,11 +578,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.header.errors == nullptr); REQUIRE(result.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED); REQUIRE(result.items_count == 1); + REQUIRE(result.latest_grace_unix_ts_ms == unix_ts_ms + 1); + REQUIRE(result.latest_expiry_unix_ts_ms == unix_ts_ms + 2); REQUIRE(result.items != nullptr); - REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_ACTIVATED); + REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED); REQUIRE(result.items[0].subscription_duration_s == 86400); - REQUIRE(result.items[0].activated_unix_ts_ms == unix_ts_ms); - REQUIRE(result.items[0].expired_unix_ts_ms == unix_ts_ms); + REQUIRE(result.items[0].grace_unix_ts_ms == unix_ts_ms); + REQUIRE(result.items[0].expiry_unix_ts_ms == unix_ts_ms); REQUIRE(result.items[0].refunded_unix_ts_ms == unix_ts_ms + 3600); REQUIRE(result.items[0].redeemed_unix_ts_ms == unix_ts_ms - 3600); REQUIRE(result.items[0].payment_provider == From 1a7fde0e19c1a56e5670d4338a11fc17cb0fb526 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 23 Sep 2025 17:46:12 +1000 Subject: [PATCH 085/171] Fix broken tests due to mismatched timestamp magnitude --- tests/test_session_protocol.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 79346f39..6abe0b14 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -59,7 +59,10 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se result.proof.gen_index_hash.data(), result.proof.gen_index_hash.size()); proto_proof->set_rotatingpublickey( result.proof.rotating_pubkey.data(), result.proof.rotating_pubkey.size()); - proto_proof->set_expiryunixts(result.proof.expiry_unix_ts.time_since_epoch().count()); + proto_proof->set_expiryunixts( + std::chrono::duration_cast( + result.proof.expiry_unix_ts.time_since_epoch()) + .count()); proto_proof->set_sig(result.proof.sig.data(), result.proof.sig.size()); // Generate the plaintext @@ -658,7 +661,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &multi_decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count(), + std::chrono::duration_cast( + protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch()) + .count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, From 49df9fe7c71368f463242859fb90da380a8f501b Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 11:04:52 +1000 Subject: [PATCH 086/171] Fix broken tests after rebase --- include/session/config/pro.hpp | 16 +++++++++------- src/config/internal.cpp | 7 +++++++ src/config/internal.hpp | 5 +++++ src/config/pro.cpp | 9 ++++++--- src/session_protocol.cpp | 4 ++-- tests/test_config_pro.cpp | 2 +- tests/test_pro_backend.cpp | 7 ++++--- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 62715a6b..9d195941 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -8,15 +8,17 @@ namespace session::config { /// keys used currently or in the past (so that we don't reuse): /// -/// p + pro data +/// s + session pro data +/// | +/// +-- p + proof +/// | | +/// | +-- @ - version +/// | +-- e - expiry unix timestamp (in milliseconds) +/// | +-- g - gen_index_hash +/// | +-- r - rotating ed25519 privkey +/// | +-- s - proof signature, signed by the Session Pro Backend's ed25519 key /// | -/// +-- @ - version -/// +-- g - gen_index_hash /// +-- r - rotating ed25519 pubkey -/// +-- e - expiry unix timestamp (in seconds) -/// +-- s - proof signature, signed by the Session Pro Backend's ed25519 key -/// +-- r - rotating ed25519 privkey -/// +-- p - proof class ProConfig { public: /// Private key for the public key key specified in the proof. This is synced between clients diff --git a/src/config/internal.cpp b/src/config/internal.cpp index aa802e5c..1f59a85a 100644 --- a/src/config/internal.cpp +++ b/src/config/internal.cpp @@ -127,6 +127,13 @@ std::optional maybe_ts(const session::config::dict& d, return result; } +std::optional> maybe_ts_ms(const session::config::dict& d, const char* key) { + std::optional> result; + if (auto* i = maybe_scalar(d, key)) + result.emplace(std::chrono::milliseconds{*i}); + return result; +} + std::chrono::sys_seconds ts_or_epoch(const session::config::dict& d, const char* key) { if (auto* i = maybe_scalar(d, key)) return std::chrono::sys_seconds{std::chrono::seconds{*i}}; diff --git a/src/config/internal.hpp b/src/config/internal.hpp index 26d02f18..4903a39e 100644 --- a/src/config/internal.hpp +++ b/src/config/internal.hpp @@ -182,6 +182,11 @@ std::chrono::sys_time ts_now() { // wrapped in a std::chrono::sys_seconds. Returns nullopt if not there (or not int). std::optional maybe_ts(const session::config::dict& d, const char* key); +// Digs into a config `dict` to get out an int64_t containing unix timestamp milliseconds, returns +// it wrapped in a std::chrono::sys_time. Returns nullopt if not there +// (or not int). +std::optional> maybe_ts_ms(const session::config::dict& d, const char* key); + // Works like maybe_ts, except that if the value isn't present it returns a default-constructed // sys_seconds (i.e. unix timestamp 0). Equivalent to `maybe_ts(d, // key).value_or(std::chrono::sys_seconds{})`. diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 7cfd0bb4..17f21252 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -29,7 +29,7 @@ bool ProConfig::verify_signature(const array_uc32& verify_pubkey) const { } bool ProConfig::load(const dict& root) { - // Get proof fields sitting in 'p' dictionary + // Get proof fields from session pro data sitting in the 'p' (proof) dictionary auto p_it = root.find("p"); if (p_it == root.end()) return false; @@ -48,7 +48,8 @@ bool ProConfig::load(const dict& root) { std::optional version = maybe_int(*p, "@"); std::optional> maybe_gen_index_hash = maybe_vector(*p, "g"); std::optional> maybe_rotating_pubkey = maybe_vector(*p, "r"); - std::optional maybe_expiry_unix_ts = maybe_ts(*p, "e"); + std::optional> maybe_expiry_unix_ts_ms = + maybe_ts_ms(*p, "e"); std::optional> maybe_sig = maybe_vector(*p, "s"); if (!version) @@ -60,6 +61,8 @@ bool ProConfig::load(const dict& root) { return false; if (!maybe_sig || maybe_sig->size() != proof.sig.max_size()) return false; + if (!maybe_expiry_unix_ts_ms) + return false; version = *version; std::memcpy( @@ -70,7 +73,7 @@ bool ProConfig::load(const dict& root) { proof.rotating_pubkey.data(), maybe_rotating_pubkey->data(), proof.rotating_pubkey.size()); - proof.expiry_unix_ts = *maybe_expiry_unix_ts; + proof.expiry_unix_ts = *maybe_expiry_unix_ts_ms; std::memcpy(proof.sig.data(), maybe_sig->data(), proof.sig.size()); } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index d4cf11ef..48cf9ff6 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -24,8 +24,8 @@ session::array_uc32 proof_hash_internal( // This must match the hashing routine at // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 session::array_uc32 result = {}; - crypto_generichash_blake2b_state state; - crypto_generichash_blake2b_init(&state, /*key*/ nullptr, 0, result.max_size()); + crypto_generichash_blake2b_state state = {}; + session::pro_backend::make_blake2b32_hasher(&state); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 3ef50ede..73682c9f 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -24,7 +24,7 @@ TEST_CASE("Pro", "[config][pro]") { pro_cpp.rotating_privkey = rotating_sk; pro_cpp.proof.version = 0; pro_cpp.proof.rotating_pubkey = rotating_pk; - pro_cpp.proof.expiry_unix_ts = std::chrono::sys_seconds(1s); + pro_cpp.proof.expiry_unix_ts = std::chrono::sys_time(1s); constexpr auto gen_index_hash = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hex_u; static_assert(pro_cpp.proof.gen_index_hash.max_size() == gen_index_hash.size()); diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 8dca629f..f78f8c64 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -658,8 +658,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(curl); scope_exit curl_free{[&]() { curl_easy_cleanup(curl); }}; - struct curl_slist* curl_headers = - curl_slist_append(curl_headers, "Content-Type: application/json"); + struct curl_slist* curl_headers = nullptr; + curl_headers = curl_slist_append(curl_headers, "Content-Type: application/json"); REQUIRE(curl_headers); scope_exit curl_headers_free{[&]() { curl_slist_free_all(curl_headers); }}; @@ -727,7 +727,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Verify response first_pro_proof = response.proof; INFO("Signature: " << oxenc::to_hex(first_pro_proof.sig.data) - << ", backend pubkey: " << oxenc::to_hex(DEV_BACKEND_PUBKEY)); + << ", backend pubkey: " << oxenc::to_hex(DEV_BACKEND_PUBKEY) + << ", response: " << response_json); REQUIRE(pro_proof_verify_signature( &first_pro_proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( From f59b16b9edc2fa3992e312622ec4c0594751dc51 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 11:05:05 +1000 Subject: [PATCH 087/171] Formatting --- src/config/groups/keys.cpp | 1 - src/config/internal.cpp | 3 ++- src/config/internal.hpp | 3 ++- src/config/pro.cpp | 4 +++- src/pro_backend.cpp | 31 +++++++++++++++++-------------- src/session_protocol.cpp | 6 +++--- src/util.cpp | 1 - tests/test_session_protocol.cpp | 7 +++---- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index 293322c4..a09c8d88 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -24,7 +24,6 @@ #include "session/multi_encrypt.hpp" #include "session/session_encrypt.hpp" #include "session/xed25519.hpp" -#include "session/session_encrypt.hpp" using namespace std::literals; diff --git a/src/config/internal.cpp b/src/config/internal.cpp index 1f59a85a..7c8c3dac 100644 --- a/src/config/internal.cpp +++ b/src/config/internal.cpp @@ -127,7 +127,8 @@ std::optional maybe_ts(const session::config::dict& d, return result; } -std::optional> maybe_ts_ms(const session::config::dict& d, const char* key) { +std::optional> maybe_ts_ms( + const session::config::dict& d, const char* key) { std::optional> result; if (auto* i = maybe_scalar(d, key)) result.emplace(std::chrono::milliseconds{*i}); diff --git a/src/config/internal.hpp b/src/config/internal.hpp index 4903a39e..83dd4bea 100644 --- a/src/config/internal.hpp +++ b/src/config/internal.hpp @@ -185,7 +185,8 @@ std::optional maybe_ts(const session::config::dict& d, // Digs into a config `dict` to get out an int64_t containing unix timestamp milliseconds, returns // it wrapped in a std::chrono::sys_time. Returns nullopt if not there // (or not int). -std::optional> maybe_ts_ms(const session::config::dict& d, const char* key); +std::optional> maybe_ts_ms( + const session::config::dict& d, const char* key); // Works like maybe_ts, except that if the value isn't present it returns a default-constructed // sys_seconds (i.e. unix timestamp 0). Equivalent to `maybe_ts(d, diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 17f21252..a1fb19be 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -93,7 +93,9 @@ LIBSESSION_C_API bool pro_config_verify_signature( session::config::ProConfig config = {}; std::memcpy( - config.rotating_privkey.data(), pro->rotating_privkey.data, sizeof pro->rotating_privkey.data); + config.rotating_privkey.data(), + pro->rotating_privkey.data, + sizeof pro->rotating_privkey.data); config.proof.version = pro->proof.version; std::memcpy( config.proof.gen_index_hash.data(), diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index f38a32db..0e7a23f9 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -8,9 +8,10 @@ #include #include #include +#include #include #include -#include + #include "SessionProtos.pb.h" namespace { @@ -447,13 +448,16 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { // Parse payload uint32_t user_status = json_require(result_obj, "status", result.errors); if (user_status >= SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT) { - result.errors.push_back(fmt::format("User pro status value was out-of-bounds: {}", user_status)); + result.errors.push_back( + fmt::format("User pro status value was out-of-bounds: {}", user_status)); return result; } result.user_status = static_cast(user_status); - uint64_t latest_grace_ts = json_require(result_obj, "latest_grace_unix_ts_ms", result.errors); - uint64_t latest_expiry_ts = json_require(result_obj, "latest_expiry_unix_ts_ms", result.errors); + uint64_t latest_grace_ts = + json_require(result_obj, "latest_grace_unix_ts_ms", result.errors); + uint64_t latest_expiry_ts = + json_require(result_obj, "latest_expiry_unix_ts_ms", result.errors); result.latest_grace_unix_ts = std::chrono::sys_time( std::chrono::milliseconds(latest_grace_ts)); result.latest_expiry_unix_ts = std::chrono::sys_time( @@ -489,12 +493,12 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { item.grace_unix_ts = std::chrono::sys_time( std::chrono::milliseconds(grace_ts)); - item.expiry_unix_ts = - std::chrono::sys_time(std::chrono::milliseconds(expiry_ts)); - item.redeemed_unix_ts = - std::chrono::sys_time(std::chrono::milliseconds(redeemed_ts)); - item.refunded_unix_ts = - std::chrono::sys_time(std::chrono::milliseconds(refunded_ts)); + item.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(expiry_ts)); + item.redeemed_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(redeemed_ts)); + item.refunded_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(refunded_ts)); item.subscription_duration = std::chrono::seconds(sub_duration_s); if (payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL && payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { @@ -637,8 +641,7 @@ session_pro_backend_get_pro_proof_request_build_sigs( return result; } -LIBSESSION_C_API session_pro_backend_signature -session_pro_backend_get_pro_status_request_build_sig( +LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_status_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -946,8 +949,8 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ dest.subscription_duration_s = std::chrono::duration_cast(src.subscription_duration).count(); dest.grace_unix_ts_ms = std::chrono::duration_cast( - src.grace_unix_ts.time_since_epoch()) - .count(); + src.grace_unix_ts.time_since_epoch()) + .count(); dest.expiry_unix_ts_ms = std::chrono::duration_cast( src.expiry_unix_ts.time_since_epoch()) .count(); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 48cf9ff6..e5abbbe9 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1,14 +1,14 @@ #include #include -#include #include #include +#include #include #include +#include #include #include -#include #include #include "SessionProtos.pb.h" @@ -163,7 +163,7 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( } return result; } -}; // namespace +}; // namespace session namespace session { diff --git a/src/util.cpp b/src/util.cpp index 1dd49540..30bc4dcc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3,7 +3,6 @@ #include #include #include -#include namespace session { diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 6abe0b14..5a9f0934 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -59,10 +59,9 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se result.proof.gen_index_hash.data(), result.proof.gen_index_hash.size()); proto_proof->set_rotatingpublickey( result.proof.rotating_pubkey.data(), result.proof.rotating_pubkey.size()); - proto_proof->set_expiryunixts( - std::chrono::duration_cast( - result.proof.expiry_unix_ts.time_since_epoch()) - .count()); + proto_proof->set_expiryunixts(std::chrono::duration_cast( + result.proof.expiry_unix_ts.time_since_epoch()) + .count()); proto_proof->set_sig(result.proof.sig.data(), result.proof.sig.size()); // Generate the plaintext From 4880fb0675460433671b7273fbc4c3e52513f151 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 11:49:46 +1000 Subject: [PATCH 088/171] Use non-SSH url for simdutf --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 8d314998..5461d327 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,4 +24,4 @@ url = https://github.com/oxen-io/oxen-logging.git [submodule "external/simdutf"] path = external/simdutf - url = git@github.com:simdutf/simdutf.git + url = https://github.com/simdutf/simdutf.git From a4dfe6f82a58899ddfa4826b37c9c7fb9359703f Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 13:47:50 +1000 Subject: [PATCH 089/171] Remove null-checks for args marked NON-NULL --- include/session/session_protocol.h | 4 ++-- src/session_protocol.cpp | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 579386c8..334c3192 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -604,10 +604,10 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( const void* envelope_plaintext, size_t envelope_plaintext_len, uint64_t unix_ts, - const void* pro_backend_pubkey, + OPTIONAL const void* pro_backend_pubkey, size_t pro_backend_pubkey_len, OPTIONAL char* error, - size_t error_len) NON_NULL_ARG(1, 2, 5); + size_t error_len) NON_NULL_ARG(1, 2); /// API: session_protocol/session_protocol_decrypt_envelope_free /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index e5abbbe9..faab6910 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -696,20 +696,18 @@ static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { bytes32 result = {}; - if (proof) { - session::array_uc32 hash = proof_hash_internal( - proof->version, - proof->gen_index_hash.data, - proof->rotating_pubkey.data, - proof->expiry_unix_ts_ms); - std::memcpy(result.data, hash.data(), hash.size()); - } + session::array_uc32 hash = proof_hash_internal( + proof->version, + proof->gen_index_hash.data, + proof->rotating_pubkey.data, + proof->expiry_unix_ts_ms); + std::memcpy(result.data, hash.data(), hash.size()); return result; } LIBSESSION_C_API bool pro_proof_verify_signature( pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { - if (!proof || verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) + if (verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) return false; auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); session::array_uc32 hash = proof_hash_internal( @@ -734,7 +732,7 @@ LIBSESSION_C_API bool pro_proof_verify_message( } LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_ms) { - bool result = proof && proof_is_active_internal(proof->expiry_unix_ts_ms, unix_ts_ms); + bool result = proof_is_active_internal(proof->expiry_unix_ts_ms, unix_ts_ms); return result; } From 16757f495f90acd42e43af01a68fe0a4822a617e Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 14:07:31 +1000 Subject: [PATCH 090/171] Use format macro to dump proof expiry --- tests/test_pro_backend.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index f78f8c64..6b0298af 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -31,17 +32,17 @@ static bool string8_equals(string8 s8, std::string_view str) { fprintf(stderr, "proof.rotating_pubkey: %s\n", oxenc::to_hex(proof.rotating_pubkey.data).c_str()); - fprintf(stderr, "proof.expiry_unix_ts_ms: %zu\n", proof.expiry_unix_ts_ms); + fprintf(stderr, "proof.expiry_unix_ts_ms: %" PRIu64 "\n", proof.expiry_unix_ts_ms); fprintf(stderr, "proof.sig: %s\n", oxenc::to_hex(proof.sig.data).c_str()); } [[maybe_unused]] static void dump_pro_payment_item( const session_pro_backend_pro_payment_item& item) { - fprintf(stderr, "item.expiry_unix_ts_ms: %zu\n", item.expiry_unix_ts_ms); - fprintf(stderr, "item.grace_unix_ts_ms: %zu\n", item.grace_unix_ts_ms); - fprintf(stderr, "item.redeemed_unix_ts_ms: %zu\n", item.redeemed_unix_ts_ms); - fprintf(stderr, "item.refunded_unix_ts_ms: %zu\n", item.refunded_unix_ts_ms); - fprintf(stderr, "item.subscription_duration: %zu\n", item.subscription_duration_s); + fprintf(stderr, "item.expiry_unix_ts_ms: %" PRIu64 "\n", item.expiry_unix_ts_ms); + fprintf(stderr, "item.grace_unix_ts_ms: %" PRIu64 "zu\n", item.grace_unix_ts_ms); + fprintf(stderr, "item.redeemed_unix_ts_ms: %" PRIu64 "zu\n", item.redeemed_unix_ts_ms); + fprintf(stderr, "item.refunded_unix_ts_ms: %" PRIu64 "zu\n", item.refunded_unix_ts_ms); + fprintf(stderr, "item.subscription_duration: %" PRIu64 "zu\n", item.subscription_duration_s); fprintf(stderr, "item.payment_provider: %u\n", item.payment_provider); fprintf(stderr, "item.google_payment_token: %.*s\n", @@ -60,7 +61,7 @@ static bool string8_equals(string8 s8, std::string_view str) { [[maybe_unused]] static void dump_pro_revocation( const session_pro_backend_pro_revocation_item& item) { - fprintf(stderr, "item.expiry_unix_ts: %zu\n", item.expiry_unix_ts_ms); + fprintf(stderr, "item.expiry_unix_ts: %" PRIu64 "zu\n", item.expiry_unix_ts_ms); fprintf(stderr, "item.gen_index_hash: %s\n", oxenc::to_hex(item.gen_index_hash.data).c_str()); } From 13aa74bb5eb051fa3e1f5eac260e3b1b509c6cc5 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 14:16:03 +1000 Subject: [PATCH 091/171] Add community message parsing to handle pro signature from content or envelope --- include/session/session_protocol.hpp | 27 +++ proto/SessionProtos.pb.cc | 181 +++++++++++------- proto/SessionProtos.pb.h | 268 ++++++++++++++++++--------- proto/SessionProtos.proto | 54 ++++++ src/pro_backend.cpp | 1 - src/session_protocol.cpp | 170 +++++++++++++++++ 6 files changed, 547 insertions(+), 154 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index bae0654a..ab9f8a72 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -257,6 +257,28 @@ struct DecryptedEnvelope { std::optional pro; }; +struct ParsedCommunityMessage { + // The envelope parsed from the plaintext. Set if the plaintext was originally an envelope blob. + // This is optional because the protocol is undergoing a migration period to start sending + // community messages as an `Envelope` instead of `Content` so we will receive one or the other + // kind of blob on the wire during that period. + std::optional envelope; + + // Content blob + std::span content_plaintext; + + // The signature if it was present in the payload. If the envelope is set and the envelope has + // the pro signature flag set, then this signature was extracted from the envelope. When the + // signature is sourced from the envelope, the envelope's `pro_sig` field is also set to the + // same signature as this instance for consistency. Otherwise the signature, if set was + // extracted from the community-exclusive pro signature field in the content message. + std::optional pro_sig; + + // Set if the envelope included a pro payload. The caller must check the status to determine if + // the embedded pro data/proof was valid, invalid or whether or not the proof has expired. + std::optional pro; +}; + struct DecryptEnvelopeKey { // Set the key to decrypt the envelope. If this key is set then it's assumed that the envelope // payload is encrypted (e.g. groups v2) and that the contents are unencrypted. If this key is @@ -527,4 +549,9 @@ DecryptedEnvelope decrypt_envelope( std::span envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey); + +ParsedCommunityMessage parse_for_community_message( + std::span content_or_envelope_payload, + std::chrono::sys_seconds unix_ts, + const array_uc32& pro_backend_pubkey); } // namespace session diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index 7b56cc16..5233e6ed 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -88,6 +88,7 @@ PROTOBUF_CONSTEXPR Content::Content( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.prosigforcommunitymessageonly_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.datamessage_)*/nullptr , /*decltype(_impl_.callmessage_)*/nullptr , /*decltype(_impl_.receiptmessage_)*/nullptr @@ -2624,48 +2625,51 @@ class Content::_Internal { using HasBits = decltype(std::declval()._impl_._has_bits_); static const ::SessionProtos::DataMessage& datamessage(const Content* msg); static void set_has_datamessage(HasBits* has_bits) { - (*has_bits)[0] |= 1u; + (*has_bits)[0] |= 2u; } static const ::SessionProtos::CallMessage& callmessage(const Content* msg); static void set_has_callmessage(HasBits* has_bits) { - (*has_bits)[0] |= 2u; + (*has_bits)[0] |= 4u; } static const ::SessionProtos::ReceiptMessage& receiptmessage(const Content* msg); static void set_has_receiptmessage(HasBits* has_bits) { - (*has_bits)[0] |= 4u; + (*has_bits)[0] |= 8u; } static const ::SessionProtos::TypingMessage& typingmessage(const Content* msg); static void set_has_typingmessage(HasBits* has_bits) { - (*has_bits)[0] |= 8u; + (*has_bits)[0] |= 16u; } static const ::SessionProtos::DataExtractionNotification& dataextractionnotification(const Content* msg); static void set_has_dataextractionnotification(HasBits* has_bits) { - (*has_bits)[0] |= 16u; + (*has_bits)[0] |= 32u; } static const ::SessionProtos::UnsendRequest& unsendrequest(const Content* msg); static void set_has_unsendrequest(HasBits* has_bits) { - (*has_bits)[0] |= 32u; + (*has_bits)[0] |= 64u; } static const ::SessionProtos::MessageRequestResponse& messagerequestresponse(const Content* msg); static void set_has_messagerequestresponse(HasBits* has_bits) { - (*has_bits)[0] |= 64u; + (*has_bits)[0] |= 128u; } static const ::SessionProtos::SharedConfigMessage& sharedconfigmessage(const Content* msg); static void set_has_sharedconfigmessage(HasBits* has_bits) { - (*has_bits)[0] |= 128u; + (*has_bits)[0] |= 256u; } static void set_has_expirationtype(HasBits* has_bits) { - (*has_bits)[0] |= 512u; + (*has_bits)[0] |= 1024u; } static void set_has_expirationtimer(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; + (*has_bits)[0] |= 2048u; } static void set_has_sigtimestamp(HasBits* has_bits) { - (*has_bits)[0] |= 2048u; + (*has_bits)[0] |= 4096u; } static const ::SessionProtos::ProMessage& promessage(const Content* msg); static void set_has_promessage(HasBits* has_bits) { - (*has_bits)[0] |= 256u; + (*has_bits)[0] |= 512u; + } + static void set_has_prosigforcommunitymessageonly(HasBits* has_bits) { + (*has_bits)[0] |= 1u; } }; @@ -2717,6 +2721,7 @@ Content::Content(const Content& from) new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.prosigforcommunitymessageonly_){} , decltype(_impl_.datamessage_){nullptr} , decltype(_impl_.callmessage_){nullptr} , decltype(_impl_.receiptmessage_){nullptr} @@ -2731,6 +2736,14 @@ Content::Content(const Content& from) , decltype(_impl_.sigtimestamp_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); + _impl_.prosigforcommunitymessageonly_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.prosigforcommunitymessageonly_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_prosigforcommunitymessageonly()) { + _this->_impl_.prosigforcommunitymessageonly_.Set(from._internal_prosigforcommunitymessageonly(), + _this->GetArenaForAllocation()); + } if (from._internal_has_datamessage()) { _this->_impl_.datamessage_ = new ::SessionProtos::DataMessage(*from._impl_.datamessage_); } @@ -2771,6 +2784,7 @@ inline void Content::SharedCtor( new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.prosigforcommunitymessageonly_){} , decltype(_impl_.datamessage_){nullptr} , decltype(_impl_.callmessage_){nullptr} , decltype(_impl_.receiptmessage_){nullptr} @@ -2784,6 +2798,10 @@ inline void Content::SharedCtor( , decltype(_impl_.expirationtimer_){0u} , decltype(_impl_.sigtimestamp_){uint64_t{0u}} }; + _impl_.prosigforcommunitymessageonly_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.prosigforcommunitymessageonly_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Content::~Content() { @@ -2797,6 +2815,7 @@ Content::~Content() { inline void Content::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.prosigforcommunitymessageonly_.Destroy(); if (this != internal_default_instance()) delete _impl_.datamessage_; if (this != internal_default_instance()) delete _impl_.callmessage_; if (this != internal_default_instance()) delete _impl_.receiptmessage_; @@ -2821,43 +2840,48 @@ void Content::Clear() { cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { + _impl_.prosigforcommunitymessageonly_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(_impl_.datamessage_ != nullptr); _impl_.datamessage_->Clear(); } - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(_impl_.callmessage_ != nullptr); _impl_.callmessage_->Clear(); } - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { GOOGLE_DCHECK(_impl_.receiptmessage_ != nullptr); _impl_.receiptmessage_->Clear(); } - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000010u) { GOOGLE_DCHECK(_impl_.typingmessage_ != nullptr); _impl_.typingmessage_->Clear(); } - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000020u) { GOOGLE_DCHECK(_impl_.dataextractionnotification_ != nullptr); _impl_.dataextractionnotification_->Clear(); } - if (cached_has_bits & 0x00000020u) { + if (cached_has_bits & 0x00000040u) { GOOGLE_DCHECK(_impl_.unsendrequest_ != nullptr); _impl_.unsendrequest_->Clear(); } - if (cached_has_bits & 0x00000040u) { + if (cached_has_bits & 0x00000080u) { GOOGLE_DCHECK(_impl_.messagerequestresponse_ != nullptr); _impl_.messagerequestresponse_->Clear(); } - if (cached_has_bits & 0x00000080u) { + } + if (cached_has_bits & 0x00000300u) { + if (cached_has_bits & 0x00000100u) { GOOGLE_DCHECK(_impl_.sharedconfigmessage_ != nullptr); _impl_.sharedconfigmessage_->Clear(); } + if (cached_has_bits & 0x00000200u) { + GOOGLE_DCHECK(_impl_.promessage_ != nullptr); + _impl_.promessage_->Clear(); + } } - if (cached_has_bits & 0x00000100u) { - GOOGLE_DCHECK(_impl_.promessage_ != nullptr); - _impl_.promessage_->Clear(); - } - if (cached_has_bits & 0x00000e00u) { + if (cached_has_bits & 0x00001c00u) { ::memset(&_impl_.expirationtype_, 0, static_cast( reinterpret_cast(&_impl_.sigtimestamp_) - reinterpret_cast(&_impl_.expirationtype_)) + sizeof(_impl_.sigtimestamp_)); @@ -2976,6 +3000,15 @@ const char* Content::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; + // optional bytes proSigForCommunityMessageOnly = 17; + case 17: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 138)) { + auto str = _internal_mutable_prosigforcommunitymessageonly(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -3008,87 +3041,93 @@ uint8_t* Content::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // optional .SessionProtos.DataMessage dataMessage = 1; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::datamessage(this), _Internal::datamessage(this).GetCachedSize(), target, stream); } // optional .SessionProtos.CallMessage callMessage = 3; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(3, _Internal::callmessage(this), _Internal::callmessage(this).GetCachedSize(), target, stream); } // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(5, _Internal::receiptmessage(this), _Internal::receiptmessage(this).GetCachedSize(), target, stream); } // optional .SessionProtos.TypingMessage typingMessage = 6; - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000010u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(6, _Internal::typingmessage(this), _Internal::typingmessage(this).GetCachedSize(), target, stream); } // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000020u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(8, _Internal::dataextractionnotification(this), _Internal::dataextractionnotification(this).GetCachedSize(), target, stream); } // optional .SessionProtos.UnsendRequest unsendRequest = 9; - if (cached_has_bits & 0x00000020u) { + if (cached_has_bits & 0x00000040u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(9, _Internal::unsendrequest(this), _Internal::unsendrequest(this).GetCachedSize(), target, stream); } // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - if (cached_has_bits & 0x00000040u) { + if (cached_has_bits & 0x00000080u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(10, _Internal::messagerequestresponse(this), _Internal::messagerequestresponse(this).GetCachedSize(), target, stream); } // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - if (cached_has_bits & 0x00000080u) { + if (cached_has_bits & 0x00000100u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(11, _Internal::sharedconfigmessage(this), _Internal::sharedconfigmessage(this).GetCachedSize(), target, stream); } // optional .SessionProtos.Content.ExpirationType expirationType = 12; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( 12, this->_internal_expirationtype(), target); } // optional uint32 expirationTimer = 13; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(13, this->_internal_expirationtimer(), target); } // optional uint64 sigTimestamp = 15; - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00001000u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt64ToArray(15, this->_internal_sigtimestamp(), target); } // optional .SessionProtos.ProMessage proMessage = 16; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(16, _Internal::promessage(this), _Internal::promessage(this).GetCachedSize(), target, stream); } + // optional bytes proSigForCommunityMessageOnly = 17; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteBytesMaybeAliased( + 17, this->_internal_prosigforcommunitymessageonly(), target); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); @@ -3107,84 +3146,91 @@ size_t Content::ByteSizeLong() const { cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { - // optional .SessionProtos.DataMessage dataMessage = 1; + // optional bytes proSigForCommunityMessageOnly = 17; if (cached_has_bits & 0x00000001u) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_prosigforcommunitymessageonly()); + } + + // optional .SessionProtos.DataMessage dataMessage = 1; + if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.datamessage_); } // optional .SessionProtos.CallMessage callMessage = 3; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.callmessage_); } // optional .SessionProtos.ReceiptMessage receiptMessage = 5; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.receiptmessage_); } // optional .SessionProtos.TypingMessage typingMessage = 6; - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000010u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.typingmessage_); } // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000020u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.dataextractionnotification_); } // optional .SessionProtos.UnsendRequest unsendRequest = 9; - if (cached_has_bits & 0x00000020u) { + if (cached_has_bits & 0x00000040u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.unsendrequest_); } // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; - if (cached_has_bits & 0x00000040u) { + if (cached_has_bits & 0x00000080u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.messagerequestresponse_); } + } + if (cached_has_bits & 0x00001f00u) { // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; - if (cached_has_bits & 0x00000080u) { + if (cached_has_bits & 0x00000100u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.sharedconfigmessage_); } - } - if (cached_has_bits & 0x00000f00u) { // optional .SessionProtos.ProMessage proMessage = 16; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.promessage_); } // optional .SessionProtos.Content.ExpirationType expirationType = 12; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { total_size += 1 + ::_pbi::WireFormatLite::EnumSize(this->_internal_expirationtype()); } // optional uint32 expirationTimer = 13; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_expirationtimer()); } // optional uint64 sigTimestamp = 15; - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00001000u) { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_sigtimestamp()); } @@ -3213,50 +3259,53 @@ void Content::MergeFrom(const Content& from) { cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { + _this->_internal_set_prosigforcommunitymessageonly(from._internal_prosigforcommunitymessageonly()); + } + if (cached_has_bits & 0x00000002u) { _this->_internal_mutable_datamessage()->::SessionProtos::DataMessage::MergeFrom( from._internal_datamessage()); } - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { _this->_internal_mutable_callmessage()->::SessionProtos::CallMessage::MergeFrom( from._internal_callmessage()); } - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { _this->_internal_mutable_receiptmessage()->::SessionProtos::ReceiptMessage::MergeFrom( from._internal_receiptmessage()); } - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000010u) { _this->_internal_mutable_typingmessage()->::SessionProtos::TypingMessage::MergeFrom( from._internal_typingmessage()); } - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000020u) { _this->_internal_mutable_dataextractionnotification()->::SessionProtos::DataExtractionNotification::MergeFrom( from._internal_dataextractionnotification()); } - if (cached_has_bits & 0x00000020u) { + if (cached_has_bits & 0x00000040u) { _this->_internal_mutable_unsendrequest()->::SessionProtos::UnsendRequest::MergeFrom( from._internal_unsendrequest()); } - if (cached_has_bits & 0x00000040u) { + if (cached_has_bits & 0x00000080u) { _this->_internal_mutable_messagerequestresponse()->::SessionProtos::MessageRequestResponse::MergeFrom( from._internal_messagerequestresponse()); } - if (cached_has_bits & 0x00000080u) { + } + if (cached_has_bits & 0x00001f00u) { + if (cached_has_bits & 0x00000100u) { _this->_internal_mutable_sharedconfigmessage()->::SessionProtos::SharedConfigMessage::MergeFrom( from._internal_sharedconfigmessage()); } - } - if (cached_has_bits & 0x00000f00u) { - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { _this->_internal_mutable_promessage()->::SessionProtos::ProMessage::MergeFrom( from._internal_promessage()); } - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { _this->_impl_.expirationtype_ = from._impl_.expirationtype_; } - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { _this->_impl_.expirationtimer_ = from._impl_.expirationtimer_; } - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00001000u) { _this->_impl_.sigtimestamp_ = from._impl_.sigtimestamp_; } _this->_impl_._has_bits_[0] |= cached_has_bits; @@ -3301,8 +3350,14 @@ bool Content::IsInitialized() const { void Content::InternalSwap(Content* other) { using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.prosigforcommunitymessageonly_, lhs_arena, + &other->_impl_.prosigforcommunitymessageonly_, rhs_arena + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Content, _impl_.sigtimestamp_) + sizeof(Content::_impl_.sigtimestamp_) diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index 43259bae..832dcb53 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -1366,6 +1366,7 @@ class Content final : // accessors ------------------------------------------------------- enum : int { + kProSigForCommunityMessageOnlyFieldNumber = 17, kDataMessageFieldNumber = 1, kCallMessageFieldNumber = 3, kReceiptMessageFieldNumber = 5, @@ -1379,6 +1380,24 @@ class Content final : kExpirationTimerFieldNumber = 13, kSigTimestampFieldNumber = 15, }; + // optional bytes proSigForCommunityMessageOnly = 17; + bool has_prosigforcommunitymessageonly() const; + private: + bool _internal_has_prosigforcommunitymessageonly() const; + public: + void clear_prosigforcommunitymessageonly(); + const std::string& prosigforcommunitymessageonly() const; + template + void set_prosigforcommunitymessageonly(ArgT0&& arg0, ArgT... args); + std::string* mutable_prosigforcommunitymessageonly(); + PROTOBUF_NODISCARD std::string* release_prosigforcommunitymessageonly(); + void set_allocated_prosigforcommunitymessageonly(std::string* prosigforcommunitymessageonly); + private: + const std::string& _internal_prosigforcommunitymessageonly() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_prosigforcommunitymessageonly(const std::string& value); + std::string* _internal_mutable_prosigforcommunitymessageonly(); + public: + // optional .SessionProtos.DataMessage dataMessage = 1; bool has_datamessage() const; private: @@ -1590,6 +1609,7 @@ class Content final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr prosigforcommunitymessageonly_; ::SessionProtos::DataMessage* datamessage_; ::SessionProtos::CallMessage* callmessage_; ::SessionProtos::ReceiptMessage* receiptmessage_; @@ -7368,7 +7388,7 @@ inline void MessageRequestResponse::set_allocated_profile(::SessionProtos::LokiP // optional .SessionProtos.DataMessage dataMessage = 1; inline bool Content::_internal_has_datamessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; PROTOBUF_ASSUME(!value || _impl_.datamessage_ != nullptr); return value; } @@ -7377,7 +7397,7 @@ inline bool Content::has_datamessage() const { } inline void Content::clear_datamessage() { if (_impl_.datamessage_ != nullptr) _impl_.datamessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::SessionProtos::DataMessage& Content::_internal_datamessage() const { const ::SessionProtos::DataMessage* p = _impl_.datamessage_; @@ -7395,14 +7415,14 @@ inline void Content::unsafe_arena_set_allocated_datamessage( } _impl_.datamessage_ = datamessage; if (datamessage) { - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.dataMessage) } inline ::SessionProtos::DataMessage* Content::release_datamessage() { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; ::SessionProtos::DataMessage* temp = _impl_.datamessage_; _impl_.datamessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7418,13 +7438,13 @@ inline ::SessionProtos::DataMessage* Content::release_datamessage() { } inline ::SessionProtos::DataMessage* Content::unsafe_arena_release_datamessage() { // @@protoc_insertion_point(field_release:SessionProtos.Content.dataMessage) - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; ::SessionProtos::DataMessage* temp = _impl_.datamessage_; _impl_.datamessage_ = nullptr; return temp; } inline ::SessionProtos::DataMessage* Content::_internal_mutable_datamessage() { - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000002u; if (_impl_.datamessage_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::DataMessage>(GetArenaForAllocation()); _impl_.datamessage_ = p; @@ -7448,9 +7468,9 @@ inline void Content::set_allocated_datamessage(::SessionProtos::DataMessage* dat datamessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, datamessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; } _impl_.datamessage_ = datamessage; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.dataMessage) @@ -7458,7 +7478,7 @@ inline void Content::set_allocated_datamessage(::SessionProtos::DataMessage* dat // optional .SessionProtos.CallMessage callMessage = 3; inline bool Content::_internal_has_callmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; PROTOBUF_ASSUME(!value || _impl_.callmessage_ != nullptr); return value; } @@ -7467,7 +7487,7 @@ inline bool Content::has_callmessage() const { } inline void Content::clear_callmessage() { if (_impl_.callmessage_ != nullptr) _impl_.callmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000004u; } inline const ::SessionProtos::CallMessage& Content::_internal_callmessage() const { const ::SessionProtos::CallMessage* p = _impl_.callmessage_; @@ -7485,14 +7505,14 @@ inline void Content::unsafe_arena_set_allocated_callmessage( } _impl_.callmessage_ = callmessage; if (callmessage) { - _impl_._has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000004u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.callMessage) } inline ::SessionProtos::CallMessage* Content::release_callmessage() { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000004u; ::SessionProtos::CallMessage* temp = _impl_.callmessage_; _impl_.callmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7508,13 +7528,13 @@ inline ::SessionProtos::CallMessage* Content::release_callmessage() { } inline ::SessionProtos::CallMessage* Content::unsafe_arena_release_callmessage() { // @@protoc_insertion_point(field_release:SessionProtos.Content.callMessage) - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000004u; ::SessionProtos::CallMessage* temp = _impl_.callmessage_; _impl_.callmessage_ = nullptr; return temp; } inline ::SessionProtos::CallMessage* Content::_internal_mutable_callmessage() { - _impl_._has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000004u; if (_impl_.callmessage_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::CallMessage>(GetArenaForAllocation()); _impl_.callmessage_ = p; @@ -7538,9 +7558,9 @@ inline void Content::set_allocated_callmessage(::SessionProtos::CallMessage* cal callmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, callmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000004u; } _impl_.callmessage_ = callmessage; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.callMessage) @@ -7548,7 +7568,7 @@ inline void Content::set_allocated_callmessage(::SessionProtos::CallMessage* cal // optional .SessionProtos.ReceiptMessage receiptMessage = 5; inline bool Content::_internal_has_receiptmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; PROTOBUF_ASSUME(!value || _impl_.receiptmessage_ != nullptr); return value; } @@ -7557,7 +7577,7 @@ inline bool Content::has_receiptmessage() const { } inline void Content::clear_receiptmessage() { if (_impl_.receiptmessage_ != nullptr) _impl_.receiptmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000008u; } inline const ::SessionProtos::ReceiptMessage& Content::_internal_receiptmessage() const { const ::SessionProtos::ReceiptMessage* p = _impl_.receiptmessage_; @@ -7575,14 +7595,14 @@ inline void Content::unsafe_arena_set_allocated_receiptmessage( } _impl_.receiptmessage_ = receiptmessage; if (receiptmessage) { - _impl_._has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000008u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.receiptMessage) } inline ::SessionProtos::ReceiptMessage* Content::release_receiptmessage() { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000008u; ::SessionProtos::ReceiptMessage* temp = _impl_.receiptmessage_; _impl_.receiptmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7598,13 +7618,13 @@ inline ::SessionProtos::ReceiptMessage* Content::release_receiptmessage() { } inline ::SessionProtos::ReceiptMessage* Content::unsafe_arena_release_receiptmessage() { // @@protoc_insertion_point(field_release:SessionProtos.Content.receiptMessage) - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000008u; ::SessionProtos::ReceiptMessage* temp = _impl_.receiptmessage_; _impl_.receiptmessage_ = nullptr; return temp; } inline ::SessionProtos::ReceiptMessage* Content::_internal_mutable_receiptmessage() { - _impl_._has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000008u; if (_impl_.receiptmessage_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::ReceiptMessage>(GetArenaForAllocation()); _impl_.receiptmessage_ = p; @@ -7628,9 +7648,9 @@ inline void Content::set_allocated_receiptmessage(::SessionProtos::ReceiptMessag receiptmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, receiptmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _impl_._has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000008u; } _impl_.receiptmessage_ = receiptmessage; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.receiptMessage) @@ -7638,7 +7658,7 @@ inline void Content::set_allocated_receiptmessage(::SessionProtos::ReceiptMessag // optional .SessionProtos.TypingMessage typingMessage = 6; inline bool Content::_internal_has_typingmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; PROTOBUF_ASSUME(!value || _impl_.typingmessage_ != nullptr); return value; } @@ -7647,7 +7667,7 @@ inline bool Content::has_typingmessage() const { } inline void Content::clear_typingmessage() { if (_impl_.typingmessage_ != nullptr) _impl_.typingmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } inline const ::SessionProtos::TypingMessage& Content::_internal_typingmessage() const { const ::SessionProtos::TypingMessage* p = _impl_.typingmessage_; @@ -7665,14 +7685,14 @@ inline void Content::unsafe_arena_set_allocated_typingmessage( } _impl_.typingmessage_ = typingmessage; if (typingmessage) { - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.typingMessage) } inline ::SessionProtos::TypingMessage* Content::release_typingmessage() { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; ::SessionProtos::TypingMessage* temp = _impl_.typingmessage_; _impl_.typingmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7688,13 +7708,13 @@ inline ::SessionProtos::TypingMessage* Content::release_typingmessage() { } inline ::SessionProtos::TypingMessage* Content::unsafe_arena_release_typingmessage() { // @@protoc_insertion_point(field_release:SessionProtos.Content.typingMessage) - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; ::SessionProtos::TypingMessage* temp = _impl_.typingmessage_; _impl_.typingmessage_ = nullptr; return temp; } inline ::SessionProtos::TypingMessage* Content::_internal_mutable_typingmessage() { - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000010u; if (_impl_.typingmessage_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::TypingMessage>(GetArenaForAllocation()); _impl_.typingmessage_ = p; @@ -7718,9 +7738,9 @@ inline void Content::set_allocated_typingmessage(::SessionProtos::TypingMessage* typingmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, typingmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } _impl_.typingmessage_ = typingmessage; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.typingMessage) @@ -7728,7 +7748,7 @@ inline void Content::set_allocated_typingmessage(::SessionProtos::TypingMessage* // optional .SessionProtos.DataExtractionNotification dataExtractionNotification = 8; inline bool Content::_internal_has_dataextractionnotification() const { - bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; PROTOBUF_ASSUME(!value || _impl_.dataextractionnotification_ != nullptr); return value; } @@ -7737,7 +7757,7 @@ inline bool Content::has_dataextractionnotification() const { } inline void Content::clear_dataextractionnotification() { if (_impl_.dataextractionnotification_ != nullptr) _impl_.dataextractionnotification_->Clear(); - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000020u; } inline const ::SessionProtos::DataExtractionNotification& Content::_internal_dataextractionnotification() const { const ::SessionProtos::DataExtractionNotification* p = _impl_.dataextractionnotification_; @@ -7755,14 +7775,14 @@ inline void Content::unsafe_arena_set_allocated_dataextractionnotification( } _impl_.dataextractionnotification_ = dataextractionnotification; if (dataextractionnotification) { - _impl_._has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000020u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.dataExtractionNotification) } inline ::SessionProtos::DataExtractionNotification* Content::release_dataextractionnotification() { - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000020u; ::SessionProtos::DataExtractionNotification* temp = _impl_.dataextractionnotification_; _impl_.dataextractionnotification_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7778,13 +7798,13 @@ inline ::SessionProtos::DataExtractionNotification* Content::release_dataextract } inline ::SessionProtos::DataExtractionNotification* Content::unsafe_arena_release_dataextractionnotification() { // @@protoc_insertion_point(field_release:SessionProtos.Content.dataExtractionNotification) - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000020u; ::SessionProtos::DataExtractionNotification* temp = _impl_.dataextractionnotification_; _impl_.dataextractionnotification_ = nullptr; return temp; } inline ::SessionProtos::DataExtractionNotification* Content::_internal_mutable_dataextractionnotification() { - _impl_._has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000020u; if (_impl_.dataextractionnotification_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::DataExtractionNotification>(GetArenaForAllocation()); _impl_.dataextractionnotification_ = p; @@ -7808,9 +7828,9 @@ inline void Content::set_allocated_dataextractionnotification(::SessionProtos::D dataextractionnotification = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, dataextractionnotification, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000020u; } _impl_.dataextractionnotification_ = dataextractionnotification; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.dataExtractionNotification) @@ -7818,7 +7838,7 @@ inline void Content::set_allocated_dataextractionnotification(::SessionProtos::D // optional .SessionProtos.UnsendRequest unsendRequest = 9; inline bool Content::_internal_has_unsendrequest() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; PROTOBUF_ASSUME(!value || _impl_.unsendrequest_ != nullptr); return value; } @@ -7827,7 +7847,7 @@ inline bool Content::has_unsendrequest() const { } inline void Content::clear_unsendrequest() { if (_impl_.unsendrequest_ != nullptr) _impl_.unsendrequest_->Clear(); - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000040u; } inline const ::SessionProtos::UnsendRequest& Content::_internal_unsendrequest() const { const ::SessionProtos::UnsendRequest* p = _impl_.unsendrequest_; @@ -7845,14 +7865,14 @@ inline void Content::unsafe_arena_set_allocated_unsendrequest( } _impl_.unsendrequest_ = unsendrequest; if (unsendrequest) { - _impl_._has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] |= 0x00000040u; } else { - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000040u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.unsendRequest) } inline ::SessionProtos::UnsendRequest* Content::release_unsendrequest() { - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000040u; ::SessionProtos::UnsendRequest* temp = _impl_.unsendrequest_; _impl_.unsendrequest_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7868,13 +7888,13 @@ inline ::SessionProtos::UnsendRequest* Content::release_unsendrequest() { } inline ::SessionProtos::UnsendRequest* Content::unsafe_arena_release_unsendrequest() { // @@protoc_insertion_point(field_release:SessionProtos.Content.unsendRequest) - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000040u; ::SessionProtos::UnsendRequest* temp = _impl_.unsendrequest_; _impl_.unsendrequest_ = nullptr; return temp; } inline ::SessionProtos::UnsendRequest* Content::_internal_mutable_unsendrequest() { - _impl_._has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] |= 0x00000040u; if (_impl_.unsendrequest_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::UnsendRequest>(GetArenaForAllocation()); _impl_.unsendrequest_ = p; @@ -7898,9 +7918,9 @@ inline void Content::set_allocated_unsendrequest(::SessionProtos::UnsendRequest* unsendrequest = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, unsendrequest, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] |= 0x00000040u; } else { - _impl_._has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000040u; } _impl_.unsendrequest_ = unsendrequest; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.unsendRequest) @@ -7908,7 +7928,7 @@ inline void Content::set_allocated_unsendrequest(::SessionProtos::UnsendRequest* // optional .SessionProtos.MessageRequestResponse messageRequestResponse = 10; inline bool Content::_internal_has_messagerequestresponse() const { - bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; PROTOBUF_ASSUME(!value || _impl_.messagerequestresponse_ != nullptr); return value; } @@ -7917,7 +7937,7 @@ inline bool Content::has_messagerequestresponse() const { } inline void Content::clear_messagerequestresponse() { if (_impl_.messagerequestresponse_ != nullptr) _impl_.messagerequestresponse_->Clear(); - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000080u; } inline const ::SessionProtos::MessageRequestResponse& Content::_internal_messagerequestresponse() const { const ::SessionProtos::MessageRequestResponse* p = _impl_.messagerequestresponse_; @@ -7935,14 +7955,14 @@ inline void Content::unsafe_arena_set_allocated_messagerequestresponse( } _impl_.messagerequestresponse_ = messagerequestresponse; if (messagerequestresponse) { - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000080u; } else { - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000080u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.messageRequestResponse) } inline ::SessionProtos::MessageRequestResponse* Content::release_messagerequestresponse() { - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000080u; ::SessionProtos::MessageRequestResponse* temp = _impl_.messagerequestresponse_; _impl_.messagerequestresponse_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -7958,13 +7978,13 @@ inline ::SessionProtos::MessageRequestResponse* Content::release_messagerequestr } inline ::SessionProtos::MessageRequestResponse* Content::unsafe_arena_release_messagerequestresponse() { // @@protoc_insertion_point(field_release:SessionProtos.Content.messageRequestResponse) - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000080u; ::SessionProtos::MessageRequestResponse* temp = _impl_.messagerequestresponse_; _impl_.messagerequestresponse_ = nullptr; return temp; } inline ::SessionProtos::MessageRequestResponse* Content::_internal_mutable_messagerequestresponse() { - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000080u; if (_impl_.messagerequestresponse_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::MessageRequestResponse>(GetArenaForAllocation()); _impl_.messagerequestresponse_ = p; @@ -7988,9 +8008,9 @@ inline void Content::set_allocated_messagerequestresponse(::SessionProtos::Messa messagerequestresponse = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, messagerequestresponse, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000080u; } else { - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000080u; } _impl_.messagerequestresponse_ = messagerequestresponse; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.messageRequestResponse) @@ -7998,7 +8018,7 @@ inline void Content::set_allocated_messagerequestresponse(::SessionProtos::Messa // optional .SessionProtos.SharedConfigMessage sharedConfigMessage = 11; inline bool Content::_internal_has_sharedconfigmessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; PROTOBUF_ASSUME(!value || _impl_.sharedconfigmessage_ != nullptr); return value; } @@ -8007,7 +8027,7 @@ inline bool Content::has_sharedconfigmessage() const { } inline void Content::clear_sharedconfigmessage() { if (_impl_.sharedconfigmessage_ != nullptr) _impl_.sharedconfigmessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000100u; } inline const ::SessionProtos::SharedConfigMessage& Content::_internal_sharedconfigmessage() const { const ::SessionProtos::SharedConfigMessage* p = _impl_.sharedconfigmessage_; @@ -8025,14 +8045,14 @@ inline void Content::unsafe_arena_set_allocated_sharedconfigmessage( } _impl_.sharedconfigmessage_ = sharedconfigmessage; if (sharedconfigmessage) { - _impl_._has_bits_[0] |= 0x00000080u; + _impl_._has_bits_[0] |= 0x00000100u; } else { - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000100u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.sharedConfigMessage) } inline ::SessionProtos::SharedConfigMessage* Content::release_sharedconfigmessage() { - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000100u; ::SessionProtos::SharedConfigMessage* temp = _impl_.sharedconfigmessage_; _impl_.sharedconfigmessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -8048,13 +8068,13 @@ inline ::SessionProtos::SharedConfigMessage* Content::release_sharedconfigmessag } inline ::SessionProtos::SharedConfigMessage* Content::unsafe_arena_release_sharedconfigmessage() { // @@protoc_insertion_point(field_release:SessionProtos.Content.sharedConfigMessage) - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000100u; ::SessionProtos::SharedConfigMessage* temp = _impl_.sharedconfigmessage_; _impl_.sharedconfigmessage_ = nullptr; return temp; } inline ::SessionProtos::SharedConfigMessage* Content::_internal_mutable_sharedconfigmessage() { - _impl_._has_bits_[0] |= 0x00000080u; + _impl_._has_bits_[0] |= 0x00000100u; if (_impl_.sharedconfigmessage_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::SharedConfigMessage>(GetArenaForAllocation()); _impl_.sharedconfigmessage_ = p; @@ -8078,9 +8098,9 @@ inline void Content::set_allocated_sharedconfigmessage(::SessionProtos::SharedCo sharedconfigmessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, sharedconfigmessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000080u; + _impl_._has_bits_[0] |= 0x00000100u; } else { - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000100u; } _impl_.sharedconfigmessage_ = sharedconfigmessage; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.sharedConfigMessage) @@ -8088,7 +8108,7 @@ inline void Content::set_allocated_sharedconfigmessage(::SessionProtos::SharedCo // optional .SessionProtos.Content.ExpirationType expirationType = 12; inline bool Content::_internal_has_expirationtype() const { - bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } inline bool Content::has_expirationtype() const { @@ -8096,7 +8116,7 @@ inline bool Content::has_expirationtype() const { } inline void Content::clear_expirationtype() { _impl_.expirationtype_ = 0; - _impl_._has_bits_[0] &= ~0x00000200u; + _impl_._has_bits_[0] &= ~0x00000400u; } inline ::SessionProtos::Content_ExpirationType Content::_internal_expirationtype() const { return static_cast< ::SessionProtos::Content_ExpirationType >(_impl_.expirationtype_); @@ -8107,7 +8127,7 @@ inline ::SessionProtos::Content_ExpirationType Content::expirationtype() const { } inline void Content::_internal_set_expirationtype(::SessionProtos::Content_ExpirationType value) { assert(::SessionProtos::Content_ExpirationType_IsValid(value)); - _impl_._has_bits_[0] |= 0x00000200u; + _impl_._has_bits_[0] |= 0x00000400u; _impl_.expirationtype_ = value; } inline void Content::set_expirationtype(::SessionProtos::Content_ExpirationType value) { @@ -8117,7 +8137,7 @@ inline void Content::set_expirationtype(::SessionProtos::Content_ExpirationType // optional uint32 expirationTimer = 13; inline bool Content::_internal_has_expirationtimer() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; return value; } inline bool Content::has_expirationtimer() const { @@ -8125,7 +8145,7 @@ inline bool Content::has_expirationtimer() const { } inline void Content::clear_expirationtimer() { _impl_.expirationtimer_ = 0u; - _impl_._has_bits_[0] &= ~0x00000400u; + _impl_._has_bits_[0] &= ~0x00000800u; } inline uint32_t Content::_internal_expirationtimer() const { return _impl_.expirationtimer_; @@ -8135,7 +8155,7 @@ inline uint32_t Content::expirationtimer() const { return _internal_expirationtimer(); } inline void Content::_internal_set_expirationtimer(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000400u; + _impl_._has_bits_[0] |= 0x00000800u; _impl_.expirationtimer_ = value; } inline void Content::set_expirationtimer(uint32_t value) { @@ -8145,7 +8165,7 @@ inline void Content::set_expirationtimer(uint32_t value) { // optional uint64 sigTimestamp = 15; inline bool Content::_internal_has_sigtimestamp() const { - bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00001000u) != 0; return value; } inline bool Content::has_sigtimestamp() const { @@ -8153,7 +8173,7 @@ inline bool Content::has_sigtimestamp() const { } inline void Content::clear_sigtimestamp() { _impl_.sigtimestamp_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000800u; + _impl_._has_bits_[0] &= ~0x00001000u; } inline uint64_t Content::_internal_sigtimestamp() const { return _impl_.sigtimestamp_; @@ -8163,7 +8183,7 @@ inline uint64_t Content::sigtimestamp() const { return _internal_sigtimestamp(); } inline void Content::_internal_set_sigtimestamp(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000800u; + _impl_._has_bits_[0] |= 0x00001000u; _impl_.sigtimestamp_ = value; } inline void Content::set_sigtimestamp(uint64_t value) { @@ -8173,7 +8193,7 @@ inline void Content::set_sigtimestamp(uint64_t value) { // optional .SessionProtos.ProMessage proMessage = 16; inline bool Content::_internal_has_promessage() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; PROTOBUF_ASSUME(!value || _impl_.promessage_ != nullptr); return value; } @@ -8182,7 +8202,7 @@ inline bool Content::has_promessage() const { } inline void Content::clear_promessage() { if (_impl_.promessage_ != nullptr) _impl_.promessage_->Clear(); - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; } inline const ::SessionProtos::ProMessage& Content::_internal_promessage() const { const ::SessionProtos::ProMessage* p = _impl_.promessage_; @@ -8200,14 +8220,14 @@ inline void Content::unsafe_arena_set_allocated_promessage( } _impl_.promessage_ = promessage; if (promessage) { - _impl_._has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000200u; } else { - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:SessionProtos.Content.proMessage) } inline ::SessionProtos::ProMessage* Content::release_promessage() { - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; ::SessionProtos::ProMessage* temp = _impl_.promessage_; _impl_.promessage_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -8223,13 +8243,13 @@ inline ::SessionProtos::ProMessage* Content::release_promessage() { } inline ::SessionProtos::ProMessage* Content::unsafe_arena_release_promessage() { // @@protoc_insertion_point(field_release:SessionProtos.Content.proMessage) - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; ::SessionProtos::ProMessage* temp = _impl_.promessage_; _impl_.promessage_ = nullptr; return temp; } inline ::SessionProtos::ProMessage* Content::_internal_mutable_promessage() { - _impl_._has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000200u; if (_impl_.promessage_ == nullptr) { auto* p = CreateMaybeMessage<::SessionProtos::ProMessage>(GetArenaForAllocation()); _impl_.promessage_ = p; @@ -8253,14 +8273,82 @@ inline void Content::set_allocated_promessage(::SessionProtos::ProMessage* prome promessage = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, promessage, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000200u; } else { - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000200u; } _impl_.promessage_ = promessage; // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.proMessage) } +// optional bytes proSigForCommunityMessageOnly = 17; +inline bool Content::_internal_has_prosigforcommunitymessageonly() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Content::has_prosigforcommunitymessageonly() const { + return _internal_has_prosigforcommunitymessageonly(); +} +inline void Content::clear_prosigforcommunitymessageonly() { + _impl_.prosigforcommunitymessageonly_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Content::prosigforcommunitymessageonly() const { + // @@protoc_insertion_point(field_get:SessionProtos.Content.proSigForCommunityMessageOnly) + return _internal_prosigforcommunitymessageonly(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Content::set_prosigforcommunitymessageonly(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.prosigforcommunitymessageonly_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:SessionProtos.Content.proSigForCommunityMessageOnly) +} +inline std::string* Content::mutable_prosigforcommunitymessageonly() { + std::string* _s = _internal_mutable_prosigforcommunitymessageonly(); + // @@protoc_insertion_point(field_mutable:SessionProtos.Content.proSigForCommunityMessageOnly) + return _s; +} +inline const std::string& Content::_internal_prosigforcommunitymessageonly() const { + return _impl_.prosigforcommunitymessageonly_.Get(); +} +inline void Content::_internal_set_prosigforcommunitymessageonly(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.prosigforcommunitymessageonly_.Set(value, GetArenaForAllocation()); +} +inline std::string* Content::_internal_mutable_prosigforcommunitymessageonly() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.prosigforcommunitymessageonly_.Mutable(GetArenaForAllocation()); +} +inline std::string* Content::release_prosigforcommunitymessageonly() { + // @@protoc_insertion_point(field_release:SessionProtos.Content.proSigForCommunityMessageOnly) + if (!_internal_has_prosigforcommunitymessageonly()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.prosigforcommunitymessageonly_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.prosigforcommunitymessageonly_.IsDefault()) { + _impl_.prosigforcommunitymessageonly_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Content::set_allocated_prosigforcommunitymessageonly(std::string* prosigforcommunitymessageonly) { + if (prosigforcommunitymessageonly != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.prosigforcommunitymessageonly_.SetAllocated(prosigforcommunitymessageonly, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.prosigforcommunitymessageonly_.IsDefault()) { + _impl_.prosigforcommunitymessageonly_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:SessionProtos.Content.proSigForCommunityMessageOnly) +} + // ------------------------------------------------------------------- // CallMessage diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index a6db5ee1..9aff23f5 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -74,6 +74,60 @@ message Content { optional uint32 expirationTimer = 13; optional uint64 sigTimestamp = 15; optional ProMessage proMessage = 16; + + // NOTE: Temporary transition field to include the pro-signature into Content for community + // messages to use. + // + // Community messages are currently sent and received as plaintext Content. We call this state of + // the network v0. + // + // We will continue to send Community messages using the Content structure, but, now enhanced with + // the optional `proSigForCommunityMessageOnly` field which contains the pro signature. We call + // this network v1. The new clients running v1 will pack the pro-signature into the payload. We + // maintain forwards compatibility with clients on v0 as we are still sending content + // on the wire, they skip the new pro data. + // + // Simultaneously in v1 the responsibility of parsing the open groups messages will go into + // libsession. Libsession will be setup to try and parse the open groups message as a `Content` + // message at first, if that fails it will try to read the community message as an `Envelope`. + // In summary in a v1 network: + // + // v0 will still receive messages from v1 as they send `Content` community messages. + // + // v1 accepts v0 (`Content`) and v1 (`Envelope`) on the wire for community messages. v1 sends + // `Content` community messages so that there's compatibility with v0. + // + // After a defined transitionary period, we create a new release and update libsession to stop + // sending `Content` for communities and transition to sending `Envelope` for messages. We mark + // this as a v2 network: + // + // v0 will still receive messages from v1 (`Content`) but not v2 (`Envelope`) community + // messages. + // + // v1 accepts v0 (`Content`) and v1 (`Envelope`) on the wire for community messages. v1 sends + // `Content` community messages so that there's compatibility with v0. + // + // v2 swaps the parsing order. it tries parsing v1 (`envelope`) then v0 (`content`) from a + // community message. v2 sends `envelope` community messages so compatbility is maintained with + // v1 but not v0. + // + // After a final transitionary period, v3, remove parsing content entirely from libsession for + // community messages and removes the pro-signature from `content`. in this final stage, v2 and v3 + // are the final set of clients that can continue to talk to each other. + // + // +---------+----------------+-------------+------------------+-------------+-------------+ + // | Version | Sends | Receives v0 | Receives v1 | Receives v2 | Receives v3 | + // | | | (Content) | (Content+ProSig) | (Envelope) | (Envelope) | + // +---------+----------------+-------------+------------------+-------------+-------------+ + // | v0 | Content | Yes | Yes | No | No | + // +---------+----------------+-------------+------------------+-------------+-------------+ + // | v1 | Content+ProSig | Yes | Yes | Yes | Yes | + // +---------+----------------+-------------+------------------+-------------+-------------+ + // | v2 | Envelope | Yes | Yes | Yes | Yes | + // +---------+----------------+-------------+------------------+-------------+-------------+ + // | v3 | Envelope | No | No | Yes | Yes | + // +---------+----------------+-------------+------------------+-------------+-------------+ + optional bytes proSigForCommunityMessageOnly = 17; } message CallMessage { diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 0e7a23f9..1d97d43a 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -36,7 +36,6 @@ template const T json_require( const nlohmann::json& j, std::string_view key, std::vector& errors) { T result = {}; - ; auto it = j.find(key); if (it == j.end()) { errors.push_back(fmt::format("Key '{}' is missing", key)); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index faab6910..2f35638f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -686,6 +686,176 @@ DecryptedEnvelope decrypt_envelope( } return result; } + +ParsedCommunityMessage parse_for_community_message( + std::span content_or_envelope_payload, + std::chrono::sys_seconds unix_ts, + const array_uc32& pro_backend_pubkey) { + // TODO: Community message parsing requires a custom code path for now as we are planning to + // migrate from sending plain `Content` to `Content` with a pro signature embedded in `Content` + // (added exclusively for communities usecase), then, transitioning to sending an `Envelope` to + // make it match how messages are sent for 1o1 and groups. + // + // We have intermediate steps to allow a timeframe for providing backwards compatibility with + // older clients before changing data structures and shutting them out from receiving messages. + // More detailed information on this transition is documented in the SessionProtos.proto file + // + // In the intermediary stages, handling community messages requires some custom code that's + // similar but different to the normal path that it's less friction to write some custom + // code to handle those bits than try and re-purpose the general purpose decrypt envelope + // function. + ParsedCommunityMessage result = {}; + + // Attempt to parse the blob as an envelope + std::optional> pro_sig; + { + SessionProtos::Envelope pb_envelope = {}; + bool envelope_parsed = pb_envelope.ParseFromArray( + content_or_envelope_payload.data(), content_or_envelope_payload.size()); + + if (envelope_parsed) { + // Create the envelope + Envelope& envelope = result.envelope.emplace(); + result.content_plaintext = to_span(pb_envelope.content()); + + // Extract the envelope into our type + // Parse source (optional) + if (pb_envelope.has_source()) { + // Libsession is now responsible for creating the envelope. The only data that we + // send in the source is a Session public key (see: encrypt_for_destination) + const std::string& source = pb_envelope.source(); + if (source.size() != envelope.source.max_size()) + throw std::runtime_error( + fmt::format( + "Parse envelope failed, source had unexpected size ({} bytes)", + source.size())); + std::memcpy(envelope.source.data(), source.data(), source.size()); + envelope.flags |= ENVELOPE_FLAGS_SOURCE; + } + + // Parse source device (optional) + if (pb_envelope.has_sourcedevice()) { + envelope.source_device = pb_envelope.sourcedevice(); + envelope.flags |= ENVELOPE_FLAGS_SOURCE_DEVICE; + } + + // Parse server timestamp (optional) + if (pb_envelope.has_servertimestamp()) { + envelope.server_timestamp = pb_envelope.servertimestamp(); + envelope.flags |= ENVELOPE_FLAGS_SERVER_TIMESTAMP; + } + + // Parse pro signature (optional) + if (pb_envelope.has_prosig()) { + envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; + pro_sig = to_span(pb_envelope.prosig()); + } + } else { + result.content_plaintext = content_or_envelope_payload; + } + } + + // Parse the content blob + SessionProtos::Content content = {}; + if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) + throw std::runtime_error{"Parsing community message failed"}; + + // Extract the pro signature from content if it was present + if (content.has_prosigforcommunitymessageonly()) { + // Signature must be in the envelope if it existed or the content. Specifying both is + // not allowed. + if (result.envelope && result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG) { + throw std::runtime_error( + "Parse community message failed, envelope and content both had a pro signature " + "specified"); + } + assert(!pro_sig); + pro_sig = to_span(content.prosigforcommunitymessageonly()); + } + + // If there was a pro signature in one of the payloads, verify and copy it to our result struct + if (pro_sig) { + if (pro_sig->size() != crypto_sign_ed25519_BYTES) + throw std::runtime_error( + "Parse community message failed, pro signature has wrong size"); + + // Signature was the correct size, copy it into the envelope if there was one and copy it + // into the root structure + if (result.envelope) + std::memcpy(result.envelope->pro_sig.data(), pro_sig->data(), pro_sig->size()); + + // Set it into the signature sitting in result + result.pro_sig.emplace(); + std::memcpy(result.pro_sig->data(), pro_sig->data(), pro_sig->size()); + } + + if (result.pro_sig && content.has_promessage()) { + // Extract the pro message + DecryptedPro& pro = result.pro.emplace(); + const SessionProtos::ProMessage& pro_msg = content.promessage(); + if (!pro_msg.has_proof()) + throw std::runtime_error("Parse community message failed, pro config missing proof"); + if (!pro_msg.has_features()) + throw std::runtime_error("Parse community message failed, pro config missing features"); + + // Parse the proof from protobufs + const SessionProtos::ProProof& proto_proof = pro_msg.proof(); + session::config::ProProof& proof = pro.proof; + // clang-format off + size_t proof_errors = 0; + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); + proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); + proof_errors += !proto_proof.has_expiryunixts(); + proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); + // clang-format on + if (proof_errors) + throw std::runtime_error("Parse community message failed, pro metadata was malformed"); + + // Fill out the resulting proof structure, we have parsed successfully + pro.features = pro_msg.features(); + std::memcpy( + proof.gen_index_hash.data(), + proto_proof.genindexhash().data(), + proto_proof.genindexhash().size()); + std::memcpy( + proof.rotating_pubkey.data(), + proto_proof.rotatingpublickey().data(), + proto_proof.rotatingpublickey().size()); + proof.expiry_unix_ts = + std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); + std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); + + // Evaluate the pro status given the extracted components (was it signed, is it expired, + // was the message signed validly?) + config::ProSignedMessage signed_msg = {}; + signed_msg.sig = to_span(*result.pro_sig); + + // IMPORTANT: We have to bit-manipulate the content because we're including the signature + // inside the payload itself that we had to sign. But we originally signed the payload + // without a signature set in it. This is only the case if we're dealing with a `Content` + // message that had the signature inside the content instead of the envelope. + if (result.envelope && result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG) { + signed_msg.msg = result.content_plaintext; + pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); + } else { + SessionProtos::Content content_copy_without_sig = content; + assert(content_copy_without_sig.has_prosigforcommunitymessageonly()); + + // Remove signature from the payload + content_copy_without_sig.clear_prosigforcommunitymessageonly(); + assert(!content_copy_without_sig.has_prosigforcommunitymessageonly()); + + // Reserialise the payload without the signature + std::string content_copy_without_sig_payload = + content_copy_without_sig.SerializeAsString(); + + signed_msg.msg = to_span(content_copy_without_sig_payload); + pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); + } + } + return result; +} } // namespace session using namespace session; From 425afbb255a21a5a1c5fbf6b88c53fdf489980fe Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 16:10:04 +1000 Subject: [PATCH 092/171] Add encode/decode for community messages --- include/session/session_protocol.hpp | 80 +++++++++++++++----- proto/SessionProtos.proto | 2 +- src/session_protocol.cpp | 109 ++++++++++++++++++++++----- tests/test_session_protocol.cpp | 53 ++++++++++++- 4 files changed, 204 insertions(+), 40 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index ab9f8a72..0658c605 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -257,7 +257,7 @@ struct DecryptedEnvelope { std::optional pro; }; -struct ParsedCommunityMessage { +struct DecodedCommunityMessage { // The envelope parsed from the plaintext. Set if the plaintext was originally an envelope blob. // This is optional because the protocol is undergoing a migration period to start sending // community messages as an `Envelope` instead of `Content` so we will receive one or the other @@ -265,7 +265,7 @@ struct ParsedCommunityMessage { std::optional envelope; // Content blob - std::span content_plaintext; + std::vector content_plaintext; // The signature if it was present in the payload. If the envelope is set and the envelope has // the pro signature flag set, then this signature was extracted from the envelope. When the @@ -450,6 +450,30 @@ std::vector encrypt_for_group( const cleared_uc32& group_ed25519_privkey, const std::optional& pro_sig); +/// API: session_protocol/encrypt_for_group +/// +/// Encrypt a plaintext `Content` message for a community for the Session Protocol. This function +/// encodes Session Pro metadata including generating and embedding the Session Pro signature, when +/// given a Session Pro rotating Ed25519 key into the final payload suitable for transmission on the +/// wire. +/// +/// This function throws if any input argument is invalid (e.g., incorrect key sizes). It also +/// throws if the pro signature is already set in the plaintext `Content` or the `plaintext` cannot +/// be interpreted as a `Content` message. +/// +/// Inputs: +/// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - pro_rotating_ed25519_privkey -- The sender's Session Pro rotating libsodium-style secret key +/// (64 bytes). Can also be passed as a 32-byte seed. Used to sign the payload. +/// +/// Outputs: +/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire +/// (i.e: it has been protobuf encoded/wrapped if necessary). +std::vector encode_for_community( + std::span plaintext, + std::span pro_rotating_ed25519_privkey); + /// API: session_protocol/encrypt_for_destination /// /// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of @@ -520,9 +544,6 @@ std::vector encrypt_for_destination( /// issuer /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw -/// an exception then this is caught internally and success is set to false. All remaining fields -/// in the result are to be ignored on failure. /// - `envelope` -- Envelope structure that was decrypted/parsed from the `envelope_plaintext` /// - `content_plaintext` -- Decrypted contents of the envelope structure. This is the protobuf /// encoded stream that can be parsed into a protobuf `Content` structure. @@ -532,25 +553,48 @@ std::vector encrypt_for_destination( /// - `sender_x25519_pubkey` -- The sender's x25519 public key. It's always set on successful /// decryption either by extracting the key from the encrypted groups envelope, or, by deriving /// the x25519 key from the sender's ed25519 key in the case of a session message envelope. -/// - `pro_status` -- The pro status associated with the envelope, if any, that the sender has -/// embedded into the envelope being parsed. This field is set to nil if there was no pro metadata -/// associated with the envelope. -/// -/// This field should be used to determine the presence of pro and whether or not the caller -/// can respect the contents of the pro proof and features. A valid pro proof that can be used -/// effectively after parsing is indicated by this value being set to the Valid enum. -/// - `pro_proof` -- The pro proof in the envelope. This field is set to all zeros if `pro_status` -/// was nil, otherwise it's populated with proof data. -/// - `pro_features` -- Pro features that were activated in this envelope by the sender. This field -/// is only set if `pro_status` is not nil. It should only be enforced if the `pro_status` was -/// the Valid enum. +/// - `pro` -- Optional object that is set if there was pro metadata associatd with the envelope, if +/// any. The `status` field in the decrypted pro object should be used to determine whether or not +/// the caller can respect the contents of the `proof` and `features`. +/// +/// If the `status` is set to valid the the caller can proceed with entitling the envelope with +/// access to pro features if it's using any. DecryptedEnvelope decrypt_envelope( const DecryptEnvelopeKey& keys, std::span envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey); -ParsedCommunityMessage parse_for_community_message( +/// API: session_protocol/decode_for_community +/// +/// Given an unencrypted content or envelope payload extract the plaintext to the content and any +/// associated pro metadata if there was any in the message. +/// +/// Inputs: +/// - `content_or_envelope_payload` -- the unencrypted content or envelope payload containing the +/// community message +/// - `unix_ts` -- pass in the current system time in seconds which is used to determine, whether or +/// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no +/// proof in the message. +/// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in +/// the proof, validating whether or not the attached proof was indeed issued by an authorised +/// issuer +/// +/// Outputs: +/// - `envelope` -- Envelope structure that was parsed from the `content_or_envelope_payload` if the +/// payload was an envelope. Nil otherwise. +/// - `content_plaintext` -- The protobuf encoded stream that can be parsed into a protobuf +/// `Content` structure that was extracted from the `content_or_envelope_payload` +/// - `pro_sig` -- Optional pro signature if there was one located in the +/// `content_or_envelope_payload`. This is the same signature as the one located in the `envelope` +/// object if the original payload was an envelope. +/// - `pro` -- Optional object that is set if there was pro metadata associatd with the envelope, if +/// any. The `status` field in the decrypted pro object should be used to determine whether or not +/// the caller can respect the contents of the `proof` and `features`. +/// +/// If the `status` is set to valid the the caller can proceed with entitling the envelope with +/// access to pro features if it's using any. +DecodedCommunityMessage decode_for_community( std::span content_or_envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey); diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 9aff23f5..743ed91b 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -387,7 +387,7 @@ message ProProof { optional uint32 version = 1; optional bytes genIndexHash = 2; optional bytes rotatingPublicKey = 3; - optional uint64 expiryUnixTs = 4; + optional uint64 expiryUnixTs = 4; // Epoch timestamp in milliseconds optional bytes sig = 5; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 2f35638f..8a6bdf19 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -228,6 +228,65 @@ std::vector encrypt_for_group( return result; } +std::vector encode_for_community( + std::span plaintext, + std::span pro_rotating_ed25519_privkey) +{ + // TODO: In future once platforms adopt this function, then we can change to sending an envelope + // and all platforms will uniformly agree on this convention. For backwards compat, the decode + // for community function will continue to try and parse `Content` and `Envelope` for messages + // sent to the community. + std::vector result; + if (pro_rotating_ed25519_privkey.size()) { + if (pro_rotating_ed25519_privkey.size() != 32 && pro_rotating_ed25519_privkey.size() != 64) + throw std::invalid_argument{ + "Invalid pro_rotating_ed25519_privkey: expected 32 or 64 bytes"}; + + // TODO: Sub-optimal, but we parse the content again to make sure it's valid. Sign the blob + // then, fill in the signature in-place as part of the transitioning of open groups messages + // to envelopes. As part of that, libsession is going to take responsibility of constructing + // community messages so that eventually all platforms switch over and we can change the + // implementation across all platforms in one swoop. + // + // Parse the content blob + SessionProtos::Content content = {}; + if (!content.ParseFromArray(plaintext.data(), plaintext.size())) + throw std::runtime_error{"Parsing community message failed"}; + + if (content.has_prosigforcommunitymessageonly()) + throw std::runtime_error{ + "Pro signature for community message must not be set. Libsession's responsible " + "for generating the signature and setting it"}; + + // Generate and assign the pro signature + array_uc64 pro_sig; + crypto_sign_ed25519_detached( + pro_sig.data(), + nullptr, + plaintext.data(), + plaintext.size(), + pro_rotating_ed25519_privkey.data()); + content.set_prosigforcommunitymessageonly(pro_sig.data(), pro_sig.size()); + + // Reserialize the content to return to the user + result.resize(content.ByteSizeLong()); + bool serialized = content.SerializeToArray(result.data(), result.size()); + assert(serialized); + } else { + // TODO: Very wasteful copy, but it's done to simplify the caller's interface. This is + // temporary until we transition away from plain content messages being sent for community + // messages. At that point, we should abstract away constructing content messages into + // libsession. + // + // Then the caller would just pass in the components, libsession constructs the payload to + // send on the wire. None of this back and forth situation we have here where they + // don't pass in a pro key with an already serialised `plaintext` (e.g. a no-op). + result = std::vector(plaintext.begin(), plaintext.end()); + } + + return result; +} + // Interop between the C and CPP API. The C api will request malloc which writes to `ciphertext_c`. // This pointer is taken verbatim and avoids requiring a copy from the CPP vector. The CPP api will // steal the contents from `ciphertext_cpp`. @@ -672,8 +731,8 @@ DecryptedEnvelope decrypt_envelope( proof.rotating_pubkey.data(), proto_proof.rotatingpublickey().data(), proto_proof.rotatingpublickey().size()); - proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); + proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(proto_proof.expiryunixts())); std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); // Evaluate the pro status given the extracted components (was it signed, is it expired, @@ -687,7 +746,7 @@ DecryptedEnvelope decrypt_envelope( return result; } -ParsedCommunityMessage parse_for_community_message( +DecodedCommunityMessage decode_for_community( std::span content_or_envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey) { @@ -704,19 +763,20 @@ ParsedCommunityMessage parse_for_community_message( // similar but different to the normal path that it's less friction to write some custom // code to handle those bits than try and re-purpose the general purpose decrypt envelope // function. - ParsedCommunityMessage result = {}; + DecodedCommunityMessage result = {}; // Attempt to parse the blob as an envelope std::optional> pro_sig; + SessionProtos::Envelope pb_envelope = {}; { - SessionProtos::Envelope pb_envelope = {}; bool envelope_parsed = pb_envelope.ParseFromArray( content_or_envelope_payload.data(), content_or_envelope_payload.size()); if (envelope_parsed) { // Create the envelope Envelope& envelope = result.envelope.emplace(); - result.content_plaintext = to_span(pb_envelope.content()); + result.content_plaintext = std::vector( + pb_envelope.content().begin(), pb_envelope.content().end()); // Extract the envelope into our type // Parse source (optional) @@ -751,14 +811,18 @@ ParsedCommunityMessage parse_for_community_message( pro_sig = to_span(pb_envelope.prosig()); } } else { - result.content_plaintext = content_or_envelope_payload; + // TODO: Do wasteful copy in the interim whilst transitioning protocol + result.content_plaintext = std::vector( + content_or_envelope_payload.begin(), content_or_envelope_payload.end()); } } // Parse the content blob SessionProtos::Content content = {}; if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) - throw std::runtime_error{"Parsing community message failed"}; + throw std::runtime_error{ + "Decoding community message failed, could not interpret blob as content or " + "envelope"}; // Extract the pro signature from content if it was present if (content.has_prosigforcommunitymessageonly()) { @@ -766,8 +830,8 @@ ParsedCommunityMessage parse_for_community_message( // not allowed. if (result.envelope && result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG) { throw std::runtime_error( - "Parse community message failed, envelope and content both had a pro signature " - "specified"); + "Decoding community message failed, envelope and content both had a pro " + "signature specified"); } assert(!pro_sig); pro_sig = to_span(content.prosigforcommunitymessageonly()); @@ -777,7 +841,7 @@ ParsedCommunityMessage parse_for_community_message( if (pro_sig) { if (pro_sig->size() != crypto_sign_ed25519_BYTES) throw std::runtime_error( - "Parse community message failed, pro signature has wrong size"); + "Decoding community message failed, pro signature has wrong size"); // Signature was the correct size, copy it into the envelope if there was one and copy it // into the root structure @@ -794,23 +858,25 @@ ParsedCommunityMessage parse_for_community_message( DecryptedPro& pro = result.pro.emplace(); const SessionProtos::ProMessage& pro_msg = content.promessage(); if (!pro_msg.has_proof()) - throw std::runtime_error("Parse community message failed, pro config missing proof"); + throw std::runtime_error("Decoding community message failed, pro config missing proof"); if (!pro_msg.has_features()) - throw std::runtime_error("Parse community message failed, pro config missing features"); + throw std::runtime_error( + "Decoding community message failed, pro config missing features"); // Parse the proof from protobufs const SessionProtos::ProProof& proto_proof = pro_msg.proof(); - session::config::ProProof& proof = pro.proof; + session::ProProof& proof = pro.proof; // clang-format off size_t proof_errors = 0; - proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::config::ProProofVersion_v0); + proof_errors += !proto_proof.has_version() || proto_proof.version() != static_cast(session::ProProofVersion_v0); proof_errors += !proto_proof.has_genindexhash() || proto_proof.genindexhash().size() != proof.gen_index_hash.max_size(); proof_errors += !proto_proof.has_rotatingpublickey() || proto_proof.rotatingpublickey().size() != proof.rotating_pubkey.max_size(); proof_errors += !proto_proof.has_expiryunixts(); proof_errors += !proto_proof.has_sig() || proto_proof.sig().size() != proof.sig.max_size(); // clang-format on if (proof_errors) - throw std::runtime_error("Parse community message failed, pro metadata was malformed"); + throw std::runtime_error( + "Decoding community message failed, pro metadata was malformed"); // Fill out the resulting proof structure, we have parsed successfully pro.features = pro_msg.features(); @@ -822,20 +888,23 @@ ParsedCommunityMessage parse_for_community_message( proof.rotating_pubkey.data(), proto_proof.rotatingpublickey().data(), proto_proof.rotatingpublickey().size()); - proof.expiry_unix_ts = - std::chrono::sys_seconds(std::chrono::seconds(proto_proof.expiryunixts())); + proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(proto_proof.expiryunixts())); std::memcpy(proof.sig.data(), proto_proof.sig().data(), proto_proof.sig().size()); // Evaluate the pro status given the extracted components (was it signed, is it expired, // was the message signed validly?) - config::ProSignedMessage signed_msg = {}; + ProSignedMessage signed_msg = {}; signed_msg.sig = to_span(*result.pro_sig); // IMPORTANT: We have to bit-manipulate the content because we're including the signature // inside the payload itself that we had to sign. But we originally signed the payload // without a signature set in it. This is only the case if we're dealing with a `Content` // message that had the signature inside the content instead of the envelope. - if (result.envelope && result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG) { + if (result.envelope) { + // Entering the `pro_sig` and `result.envelope` branch means that the envelope must have + // a pro signature. + assert(result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG); signed_msg.msg = result.content_plaintext; pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); } else { diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 5a9f0934..f03b741d 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -59,7 +59,7 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se result.proof.gen_index_hash.data(), result.proof.gen_index_hash.size()); proto_proof->set_rotatingpublickey( result.proof.rotating_pubkey.data(), result.proof.rotating_pubkey.size()); - proto_proof->set_expiryunixts(std::chrono::duration_cast( + proto_proof->set_expiryunixts(std::chrono::duration_cast( result.proof.expiry_unix_ts.time_since_epoch()) .count()); proto_proof->set_sig(result.proof.sig.data(), result.proof.sig.size()); @@ -713,4 +713,55 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encrypt_for_destination_free(&encrypt_result); session_protocol_decrypt_envelope_free(&decrypt_result); } + + SECTION("Encode/decode for community (content message)") { + std::vector encoded = + encode_for_community(to_span(protobuf_content_with_pro.plaintext), {}); + + DecodedCommunityMessage decode_comm_msg = + decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); + REQUIRE(!decode_comm_msg.pro_sig); + REQUIRE(!decode_comm_msg.pro); + } + + SECTION("Encode/decode for community (content message+pro)") { + std::vector encoded = encode_for_community( + to_span(protobuf_content_with_pro.plaintext), user_pro_ed_sk); + + DecodedCommunityMessage decode_comm_msg = + decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); + REQUIRE(decode_comm_msg.pro_sig); + REQUIRE(decode_comm_msg.pro); + REQUIRE(decode_comm_msg.pro->status == ProStatus::Valid); + } + + SECTION("Decode for community (envelope)") { + SessionProtos::Envelope envelope; + envelope.set_type(SessionProtos::Envelope_Type_SESSION_MESSAGE); + envelope.set_timestamp(timestamp_s.time_since_epoch().count()); + envelope.set_content(protobuf_content_with_pro.plaintext); + std::string envelope_plaintext = envelope.SerializeAsString(); + + DecodedCommunityMessage decode_comm_msg = + decode_for_community(to_span(envelope_plaintext), timestamp_s, pro_backend_ed_pk); + REQUIRE(!decode_comm_msg.pro_sig); + REQUIRE(!decode_comm_msg.pro); + } + + SECTION("Decode for community (envelope+pro)") { + SessionProtos::Envelope envelope; + envelope.set_type(SessionProtos::Envelope_Type_SESSION_MESSAGE); + envelope.set_timestamp(timestamp_s.time_since_epoch().count()); + envelope.set_content(protobuf_content_with_pro.plaintext); + envelope.set_prosig( + protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.data(), + protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.size()); + std::string envelope_plaintext = envelope.SerializeAsString(); + + DecodedCommunityMessage decode_comm_msg = + decode_for_community(to_span(envelope_plaintext), timestamp_s, pro_backend_ed_pk); + REQUIRE(decode_comm_msg.pro_sig); + REQUIRE(decode_comm_msg.pro); + REQUIRE(decode_comm_msg.pro->status == ProStatus::Valid); + } } From a7eda0527557d54566f06b568334570b4ff0009e Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 16:15:03 +1000 Subject: [PATCH 093/171] Rename encrypt/decrypt_for to encode/decode_for for consistency --- include/session/session_protocol.hpp | 38 ++++++++++++++-------------- src/session_protocol.cpp | 32 +++++++++++------------ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 0658c605..77a6a7d2 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -21,10 +21,10 @@ /// /// - Wrap and/or encrypt a plaintext content message into an Envelope or Websocket message /// (depending on the configured namespace and destination) ready to be sent on the wire with -/// `encrypt_for_destination`. +/// `encode_for_destination`. /// /// - Decrypt an incoming message in its websocket wrapped, and or encrypted envelope form with -/// `decrypt_envelope` +/// `decode_envelope` /// /// TODO: In future the goal is to begin abstracting more protobuf types away from client /// implementations such that the only dependency clients need to encode and decode Session Protocol @@ -228,7 +228,7 @@ struct Envelope { array_uc64 pro_sig; }; -struct DecryptedPro { +struct DecodedPro { ProStatus status; // Validity of the proof embedded in the envelope // Session Pro proof that was embedded in the envelope, this is always populated irrespective of // the status but the validity of the contents should be verified by checking `status` @@ -236,11 +236,11 @@ struct DecryptedPro { PRO_FEATURES features; // Bit flag features that were used in the embedded message }; -struct DecryptedEnvelope { +struct DecodedEnvelope { // The envelope parsed from the plaintext Envelope envelope; - // Decrypted envelope content into plaintext + // Decoded envelope content into plaintext std::vector content_plaintext; // Sender public key extracted from the encrypted content payload. This is not set if the @@ -254,7 +254,7 @@ struct DecryptedEnvelope { // Set if the envelope included a pro payload. The caller must check the status to determine if // the embedded pro data/proof was valid, invalid or whether or not the proof has expired. - std::optional pro; + std::optional pro; }; struct DecodedCommunityMessage { @@ -276,10 +276,10 @@ struct DecodedCommunityMessage { // Set if the envelope included a pro payload. The caller must check the status to determine if // the embedded pro data/proof was valid, invalid or whether or not the proof has expired. - std::optional pro; + std::optional pro; }; -struct DecryptEnvelopeKey { +struct DecodeEnvelopeKey { // Set the key to decrypt the envelope. If this key is set then it's assumed that the envelope // payload is encrypted (e.g. groups v2) and that the contents are unencrypted. If this key is // not set the it's assumed the envelope is not encrypted but the contents are encrypted (e.g.: @@ -347,7 +347,7 @@ ProFeaturesForMsg pro_features_for_utf8( ProFeaturesForMsg pro_features_for_utf16( char16_t const* utf16, size_t utf8_size, PRO_EXTRA_FEATURES flags); -/// API: session_protocol/encrypt_for_1o1 +/// API: session_protocol/encode_for_1o1 /// /// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session /// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for @@ -372,14 +372,14 @@ ProFeaturesForMsg pro_features_for_utf16( /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire /// (i.e: it has been protobuf encoded/wrapped if necessary). -std::vector encrypt_for_1o1( +std::vector encode_for_1o1( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const std::optional& pro_sig); -/// API: session_protocol/encrypt_for_community_inbox +/// API: session_protocol/encode_for_community_inbox /// /// Encrypt a plaintext message for a community inbox in the Session Protocol. This function wraps /// the plaintext in the necessary structures and encrypts it for transmission to a community inbox @@ -406,7 +406,7 @@ std::vector encrypt_for_1o1( /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire /// (i.e: it has been protobuf encoded/wrapped if necessary). -std::vector encrypt_for_community_inbox( +std::vector encode_for_community_inbox( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -414,7 +414,7 @@ std::vector encrypt_for_community_inbox( const array_uc32& community_pubkey, const std::optional& pro_sig); -/// API: session_protocol/encrypt_for_group +/// API: session_protocol/encode_for_group /// /// Encrypt a plaintext message for a group in the Session Protocol. This function wraps the /// plaintext in the necessary structures and encrypts it for transmission to a group, using the @@ -442,7 +442,7 @@ std::vector encrypt_for_community_inbox( /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire /// (i.e: it has been protobuf encoded/wrapped if necessary). -std::vector encrypt_for_group( +std::vector encode_for_group( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -450,7 +450,7 @@ std::vector encrypt_for_group( const cleared_uc32& group_ed25519_privkey, const std::optional& pro_sig); -/// API: session_protocol/encrypt_for_group +/// API: session_protocol/encode_for_community /// /// Encrypt a plaintext `Content` message for a community for the Session Protocol. This function /// encodes Session Pro metadata including generating and embedding the Session Pro signature, when @@ -501,12 +501,12 @@ std::vector encode_for_community( /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire /// (i.e: it has been protobuf encoded/wrapped if necessary). -std::vector encrypt_for_destination( +std::vector encode_for_destination( std::span plaintext, std::span ed25519_privkey, const Destination& dest); -/// API: session_protocol/decrypt_envelope +/// API: session_protocol/decode_envelope /// /// Given an envelope payload (i.e.: protobuf encoded stream of `WebsocketRequestMessage` which /// wraps an `Envelope` for 1o1 messages/sync messages, or `Envelope` encrypted using a Groups v2 @@ -559,8 +559,8 @@ std::vector encrypt_for_destination( /// /// If the `status` is set to valid the the caller can proceed with entitling the envelope with /// access to pro features if it's using any. -DecryptedEnvelope decrypt_envelope( - const DecryptEnvelopeKey& keys, +DecodedEnvelope decode_envelope( + const DecodeEnvelopeKey& keys, std::span envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 8a6bdf19..93c16daa 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -179,7 +179,7 @@ ProFeaturesForMsg pro_features_for_utf16( return result; } -std::vector encrypt_for_1o1( +std::vector encode_for_1o1( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -190,11 +190,11 @@ std::vector encrypt_for_1o1( dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; - std::vector result = encrypt_for_destination(plaintext, ed25519_privkey, dest); + std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); return result; } -std::vector encrypt_for_community_inbox( +std::vector encode_for_community_inbox( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -207,11 +207,11 @@ std::vector encrypt_for_community_inbox( dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; dest.community_inbox_server_pubkey = community_pubkey; - std::vector result = encrypt_for_destination(plaintext, ed25519_privkey, dest); + std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); return result; } -std::vector encrypt_for_group( +std::vector encode_for_group( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, @@ -224,7 +224,7 @@ std::vector encrypt_for_group( dest.sent_timestamp_ms = sent_timestamp; dest.group_ed25519_pubkey = group_ed25519_pubkey; dest.group_ed25519_privkey = group_ed25519_privkey; - std::vector result = encrypt_for_destination(plaintext, ed25519_privkey, dest); + std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); return result; } @@ -501,7 +501,7 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( return result; } -std::vector encrypt_for_destination( +std::vector encode_for_destination( std::span plaintext, std::span ed25519_privkey, const Destination& dest) { @@ -522,12 +522,12 @@ std::vector encrypt_for_destination( return result; } -DecryptedEnvelope decrypt_envelope( - const DecryptEnvelopeKey& keys, +DecodedEnvelope decode_envelope( + const DecodeEnvelopeKey& keys, std::span envelope_payload, std::chrono::sys_seconds unix_ts, const array_uc32& pro_backend_pubkey) { - DecryptedEnvelope result = {}; + DecodedEnvelope result = {}; SessionProtos::Envelope envelope = {}; std::span envelope_plaintext = envelope_payload; @@ -693,7 +693,7 @@ DecryptedEnvelope decrypt_envelope( if (content.has_promessage()) { // Mark the envelope as having a pro signature that the caller can use. result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; - DecryptedPro& pro = result.pro.emplace(); + DecodedPro& pro = result.pro.emplace(); // Extract the pro message const SessionProtos::ProMessage& pro_msg = content.promessage(); @@ -855,7 +855,7 @@ DecodedCommunityMessage decode_for_community( if (result.pro_sig && content.has_promessage()) { // Extract the pro message - DecryptedPro& pro = result.pro.emplace(); + DecodedPro& pro = result.pro.emplace(); const SessionProtos::ProMessage& pro_msg = content.promessage(); if (!pro_msg.has_proof()) throw std::runtime_error("Decoding community message failed, pro config missing proof"); @@ -1200,19 +1200,19 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( } // Setup decryption keys and decrypt - DecryptEnvelopeKey keys_cpp = {}; + DecodeEnvelopeKey keys_cpp = {}; if (keys->group_ed25519_pubkey.size) { keys_cpp.group_ed25519_pubkey = std::span( keys->group_ed25519_pubkey.data, keys->group_ed25519_pubkey.size); } - DecryptedEnvelope result_cpp = {}; + DecodedEnvelope result_cpp = {}; for (size_t index = 0; index < keys->ed25519_privkeys_len; index++) { std::span key = { keys->ed25519_privkeys[index].data, keys->ed25519_privkeys[index].size}; keys_cpp.ed25519_privkeys = {&key, 1}; try { - result_cpp = decrypt_envelope( + result_cpp = decode_envelope( keys_cpp, {static_cast(envelope_plaintext), envelope_plaintext_len}, std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), @@ -1260,7 +1260,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( result.envelope.server_timestamp = result_cpp.envelope.server_timestamp; if (result_cpp.pro) { - const DecryptedPro& pro = *result_cpp.pro; + const DecodedPro& pro = *result_cpp.pro; result.pro_status = static_cast(pro.status); result.pro_proof.version = pro.proof.version; result.pro_proof.expiry_unix_ts_ms = From 050159f9d1f9a0a1d7f95626f0185eff7fb90652 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 25 Sep 2025 17:55:33 +1000 Subject: [PATCH 094/171] Rename encrypt->encode and implement 1o1 padding/unpadding --- include/session/session_protocol.h | 50 ++++---- include/session/session_protocol.hpp | 7 +- src/session_protocol.cpp | 100 ++++++++++------ tests/test_session_protocol.cpp | 172 +++++++++++++-------------- 4 files changed, 178 insertions(+), 151 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 334c3192..91fc6c3b 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -105,13 +105,13 @@ typedef struct session_protocol_envelope { bytes64 pro_sig; } session_protocol_envelope; -typedef struct session_protocol_decrypt_envelope_keys { +typedef struct session_protocol_decode_envelope_keys { span_u8 group_ed25519_pubkey; const span_u8* ed25519_privkeys; size_t ed25519_privkeys_len; -} session_protocol_decrypt_envelope_keys; +} session_protocol_decode_envelope_keys; -typedef struct session_protocol_decrypted_envelope { +typedef struct session_protocol_decode_envelope { // Indicates if the decryption was successful. If the decryption step failed and threw an // exception, this is false. bool success; @@ -123,15 +123,15 @@ typedef struct session_protocol_decrypted_envelope { pro_proof pro_proof; PRO_FEATURES pro_features; size_t error_len_incl_null_terminator; -} session_protocol_decrypted_envelope; +} session_protocol_decoded_envelope; -typedef struct session_protocol_encrypted_for_destination { +typedef struct session_protocol_encoded_for_destination { // Indicates if the encryption was successful. If any step failed and threw an exception, this // is false. bool success; span_u8 ciphertext; size_t error_len_incl_null_terminator; -} session_protocol_encrypted_for_destination; +} session_protocol_encoded_for_destination; /// API: pro/pro_proof_hash /// @@ -287,13 +287,13 @@ LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( uint16_t const* utf16, size_t utf16_size, PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); -/// API: session_protocol_encrypt_for_1o1 +/// API: session_protocol_encode_for_1o1 /// /// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session /// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for /// transmission to a single recipient. /// -/// See: session_protocol/encrypt_for_1o1 for more information +/// See: session_protocol/encode_for_1o1 for more information /// /// The encryption result must be freed with session_protocol_encrypt_for_destination_free when /// the caller is done with the result. @@ -332,7 +332,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( /// at minimum the requested length, including the null-terminator in order for the error message /// to be preserved in full. LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( +session_protocol_encoded_for_destination session_protocol_encode_for_1o1( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -343,13 +343,13 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( OPTIONAL char* error, size_t error_len) NON_NULL_ARG(1, 3, 6); -/// API: session_protocol_encrypt_for_community_inbox +/// API: session_protocol_encode_for_community_inbox /// /// Encrypt a plaintext message for a community inbox in the Session Protocol. This function wraps /// the plaintext in the necessary structures and encrypts it for transmission to a community inbox /// server. /// -/// See: session_protocol/encrypt_for_community_inbox for more information +/// See: session_protocol/encode_for_community_inbox for more information /// /// The encryption result must be freed with session_protocol_encrypt_for_destination_free when /// the caller is done with the result. @@ -392,7 +392,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( /// to be preserved in full. LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_for_community_inbox( +session_protocol_encoded_for_destination session_protocol_encode_for_community_inbox( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -404,14 +404,14 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit OPTIONAL char* error, size_t error_len) NON_NULL_ARG(1, 3, 6, 7); -/// API: session_protocol_encrypt_for_group +/// API: session_protocol_encode_for_group /// /// Encrypt a plaintext message for a group in the Session Protocol. This function wraps the /// plaintext in the necessary structures and encrypts it for transmission to a group, using the /// group's encryption key. Only v2 groups, (0x03) prefixed keys are supported. Passing a legacy /// group (0x05) prefixed key will cause the function to return a failure with an error message. /// -/// See: session_protocol/encrypt_for_group for more information +/// See: session_protocol/encode_for_group for more information /// /// The encryption result must be freed with session_protocol_encrypt_for_destination_free when /// the caller is done with the result. @@ -453,7 +453,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit /// at minimum the requested length, including the null-terminator in order for the error message /// to be preserved in full. LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( +session_protocol_encoded_for_destination session_protocol_encode_for_group( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -506,7 +506,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( /// at minimum the requested length, including the null-terminator in order for the error message /// to be preserved in full. LIBSESSION_EXPORT -session_protocol_encrypted_for_destination session_protocol_encrypt_for_destination( +session_protocol_encoded_for_destination session_protocol_encode_for_destination( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -524,18 +524,18 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_destinat /// Inputs: /// - `encrypt` -- Encryption result to free. This object is zeroed out on free and should no longer /// be used after it is freed. -LIBSESSION_EXPORT void session_protocol_encrypt_for_destination_free( - session_protocol_encrypted_for_destination* encrypt); +LIBSESSION_EXPORT void session_protocol_encode_for_destination_free( + session_protocol_encoded_for_destination* encrypt); -/// API: session_protocol/session_protocol_decrypt_envelope +/// API: session_protocol/session_protocol_decode_envelope /// /// Given an envelope payload (i.e.: protobuf encoded stream of `WebsocketRequestMessage` which /// wraps an `Envelope` for 1o1 messages/sync messages, or `Envelope` encrypted using a Groups v2 /// key) parse (or decrypt) the envelope and return the envelope content decrypted if necessary. /// -/// See: session_protocol/decrypt_envelope for more information +/// See: session_protocol/decode_envelope for more information /// -/// The encryption result must be freed with `session_protocol_decrypt_envelope_free` when the +/// The encryption result must be freed with `session_protocol_decode_envelope_free` when the /// caller is done with the result. /// /// Inputs: @@ -599,8 +599,8 @@ LIBSESSION_EXPORT void session_protocol_encrypt_for_destination_free( /// at minimum the requested length, including the null-terminator in order for the error message /// to be preserved in full. LIBSESSION_EXPORT -session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const session_protocol_decrypt_envelope_keys* keys, +session_protocol_decoded_envelope session_protocol_decode_envelope( + const session_protocol_decode_envelope_keys* keys, const void* envelope_plaintext, size_t envelope_plaintext_len, uint64_t unix_ts, @@ -619,8 +619,8 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( /// - `envelope` -- Decryption result to free. This object is zeroed out on free and should no /// longer /// be used after it is freed. -LIBSESSION_EXPORT void session_protocol_decrypt_envelope_free( - session_protocol_decrypted_envelope* envelope); +LIBSESSION_EXPORT void session_protocol_decode_envelope_free( + session_protocol_decoded_envelope* envelope); #ifdef __cplusplus } diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 77a6a7d2..62a89ce7 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -360,7 +360,7 @@ ProFeaturesForMsg pro_features_for_utf16( /// /// Inputs: /// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must -/// not be already encrypted. +/// not be already encrypted and must not be padded. /// - ed25519_privkey -- The sender's libsodium-style secret key (64 bytes). Can also be passed as /// a 32-byte seed. Used to encrypt the plaintext. /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. @@ -471,8 +471,7 @@ std::vector encode_for_group( /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire /// (i.e: it has been protobuf encoded/wrapped if necessary). std::vector encode_for_community( - std::span plaintext, - std::span pro_rotating_ed25519_privkey); + std::span plaintext, std::span pro_rotating_ed25519_privkey); /// API: session_protocol/encrypt_for_destination /// @@ -492,7 +491,7 @@ std::vector encode_for_community( /// /// Inputs: /// - `plaintext` -- the protobuf serialised payload containing the protobuf encoded stream, -/// `Content`. It must not be already be encrypted. +/// `Content`. It must not be already be encrypted and must not be padded. /// - `ed25519_privkey` -- the libsodium-style secret key of the sender, 64 bytes. Can also be /// passed as a 32-byte seed. Used to encrypt the plaintext. /// - `dest` -- the extra metadata indicating the destination of the message and the necessary data diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 93c16daa..ac57888e 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -229,9 +229,7 @@ std::vector encode_for_group( } std::vector encode_for_community( - std::span plaintext, - std::span pro_rotating_ed25519_privkey) -{ + std::span plaintext, std::span pro_rotating_ed25519_privkey) { // TODO: In future once platforms adopt this function, then we can change to sending an envelope // and all platforms will uniformly agree on this convention. For backwards compat, the decode // for community function will continue to try and parse `Content` and `Envelope` for messages @@ -295,8 +293,10 @@ struct EncryptedForDestinationInternal { span_u8 ciphertext_c; }; +constexpr char PADDING_TERMINATING_BYTE = 0x80; + enum class UseMalloc { No, Yes }; -static EncryptedForDestinationInternal encrypt_for_destination_internal( +static EncryptedForDestinationInternal encode_for_destination_internal( std::span plaintext, std::span ed25519_privkey, DestinationType dest_type, @@ -333,8 +333,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( struct EncodeContext { Mode mode; - // Parameters for BuildMode => Envelope - bool before_envelope_encrypt_for_recipient_deterministic; // Ciphertext storing the result of encrypt for recipient deterministic, if it was necessary // to encrypt before enveloping. @@ -358,7 +356,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( dest_group_ed25519_pubkey[0] == static_cast(SessionIDPrefix::group); if (has_03_prefix) { enc.mode = Mode::Envelope; - enc.before_envelope_encrypt_for_recipient_deterministic = false; enc.after_envelope = AfterEnvelope::KeysEncryptMessage; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; @@ -372,7 +369,6 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( case DestinationType::ContactOrSyncMessage: { enc.mode = Mode::Envelope; - enc.before_envelope_encrypt_for_recipient_deterministic = true; enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; enc.after_envelope = AfterEnvelope::WrapInWSMessage; } break; @@ -387,9 +383,26 @@ static EncryptedForDestinationInternal encrypt_for_destination_internal( case Mode::Envelope: { assert(enc.envelope_type.has_value()); std::span content = plaintext; - if (enc.before_envelope_encrypt_for_recipient_deterministic) { - enc.before_envelope_ciphertext = session::encrypt_for_recipient_deterministic( - ed25519_privkey, dest_recipient_pubkey, content); + if (dest_type == DestinationType::ContactOrSyncMessage) { + // For Sync or 1o1 mesasges, we need to pad the contents to 160 bytes, see: + // https://github.com/session-foundation/session-desktop/blob/a04e62427034a6b6fee39dcff7dbabf0d0131b13/ts/session/crypto/BufferPadding.ts#L49 + const size_t MSG_PADDING = 160; + + // Calculate amount of padding required + size_t padded_content_size = content.size() + 1 /*padding byte*/; + uint8_t const bytes_for_padding = MSG_PADDING - (padded_content_size % MSG_PADDING); + padded_content_size += bytes_for_padding; + assert(padded_content_size % MSG_PADDING == 0); + + // Do the padding + std::vector padded_content; + padded_content.resize(padded_content_size); + std::memcpy(padded_content.data(), content.data(), content.size()); + padded_content[content.size()] = PADDING_TERMINATING_BYTE; + + // Encrypt the padded output + enc.before_envelope_ciphertext = encrypt_for_recipient_deterministic( + ed25519_privkey, dest_recipient_pubkey, padded_content); content = enc.before_envelope_ciphertext; } @@ -506,7 +519,7 @@ std::vector encode_for_destination( std::span ed25519_privkey, const Destination& dest) { - EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( + EncryptedForDestinationInternal result_internal = encode_for_destination_internal( /*plaintext=*/plaintext, /*ed25519_privkey=*/ed25519_privkey, /*dest_type=*/dest.type, @@ -591,7 +604,7 @@ DecodedEnvelope decode_envelope( // Parse source (optional) if (envelope.has_source()) { // Libsession is now responsible for creating the envelope. The only data that we send in - // the source is a Session public key (see: encrypt_for_destination) + // the source is a Session public key (see: encode_for_destination) const std::string& source = envelope.source(); if (source.size() != result.envelope.source.max_size()) throw std::runtime_error(fmt::format( @@ -647,6 +660,27 @@ DecodedEnvelope decode_envelope( keys.ed25519_privkeys.size())}; } + // Strip padding from content + { + size_t size_without_padding = content_plaintext.size(); + while (size_without_padding) { + char ch = content_plaintext[size_without_padding - 1]; + if (ch != 0 && ch != PADDING_TERMINATING_BYTE) { + // Non-zero padding encountered, terminate the loop and assume message is not + // padded + // TODO: We should enforce this but no client enforces it right now. + break; + } + + size_without_padding--; + if (ch == PADDING_TERMINATING_BYTE) + break; + } + + assert(size_without_padding <= content_plaintext.size()); + content_plaintext.resize(size_without_padding); + } + result.content_plaintext = std::move(content_plaintext); std::memcpy( result.sender_ed25519_pubkey.data(), @@ -782,13 +816,12 @@ DecodedCommunityMessage decode_for_community( // Parse source (optional) if (pb_envelope.has_source()) { // Libsession is now responsible for creating the envelope. The only data that we - // send in the source is a Session public key (see: encrypt_for_destination) + // send in the source is a Session public key (see: encode_for_destination) const std::string& source = pb_envelope.source(); if (source.size() != envelope.source.max_size()) - throw std::runtime_error( - fmt::format( - "Parse envelope failed, source had unexpected size ({} bytes)", - source.size())); + throw std::runtime_error(fmt::format( + "Parse envelope failed, source had unexpected size ({} bytes)", + source.size())); std::memcpy(envelope.source.data(), source.data(), source.size()); envelope.flags |= ENVELOPE_FLAGS_SOURCE; } @@ -1031,7 +1064,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( } LIBSESSION_C_API -session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( +session_protocol_encoded_for_destination session_protocol_encode_for_1o1( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -1048,7 +1081,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( dest.recipient_pubkey = *recipient_pubkey; dest.sent_timestamp_ms = sent_timestamp_ms; - session_protocol_encrypted_for_destination result = session_protocol_encrypt_for_destination( + session_protocol_encoded_for_destination result = session_protocol_encode_for_destination( plaintext, plaintext_len, ed25519_privkey, @@ -1060,7 +1093,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_1o1( } LIBSESSION_C_API -session_protocol_encrypted_for_destination session_protocol_encrypt_for_community_inbox( +session_protocol_encoded_for_destination session_protocol_encode_for_community_inbox( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -1079,7 +1112,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit dest.recipient_pubkey = *recipient_pubkey; dest.community_inbox_server_pubkey = *community_pubkey; - session_protocol_encrypted_for_destination result = session_protocol_encrypt_for_destination( + session_protocol_encoded_for_destination result = session_protocol_encode_for_destination( plaintext, plaintext_len, ed25519_privkey, @@ -1091,7 +1124,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_communit } LIBSESSION_C_API -session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( +session_protocol_encoded_for_destination session_protocol_encode_for_group( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -1110,7 +1143,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( dest.group_ed25519_privkey = *group_ed25519_privkey; dest.sent_timestamp_ms = sent_timestamp_ms; - session_protocol_encrypted_for_destination result = session_protocol_encrypt_for_destination( + session_protocol_encoded_for_destination result = session_protocol_encode_for_destination( plaintext, plaintext_len, ed25519_privkey, @@ -1121,8 +1154,7 @@ session_protocol_encrypted_for_destination session_protocol_encrypt_for_group( return result; } -LIBSESSION_C_API session_protocol_encrypted_for_destination -session_protocol_encrypt_for_destination( +LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encode_for_destination( const void* plaintext, size_t plaintext_len, const void* ed25519_privkey, @@ -1130,9 +1162,9 @@ session_protocol_encrypt_for_destination( const session_protocol_destination* dest, char* error, size_t error_len) { - session_protocol_encrypted_for_destination result = {}; + session_protocol_encoded_for_destination result = {}; try { - EncryptedForDestinationInternal result_internal = encrypt_for_destination_internal( + EncryptedForDestinationInternal result_internal = encode_for_destination_internal( /*plaintext=*/{static_cast(plaintext), plaintext_len}, /*ed25519_privkey=*/ {static_cast(ed25519_privkey), ed25519_privkey_len}, @@ -1163,8 +1195,8 @@ session_protocol_encrypt_for_destination( return result; } -LIBSESSION_C_API void session_protocol_encrypt_for_destination_free( - session_protocol_encrypted_for_destination* encrypt) { +LIBSESSION_C_API void session_protocol_encode_for_destination_free( + session_protocol_encoded_for_destination* encrypt) { if (encrypt) { free(encrypt->ciphertext.data); *encrypt = {}; @@ -1172,8 +1204,8 @@ LIBSESSION_C_API void session_protocol_encrypt_for_destination_free( } LIBSESSION_C_API -session_protocol_decrypted_envelope session_protocol_decrypt_envelope( - const session_protocol_decrypt_envelope_keys* keys, +session_protocol_decoded_envelope session_protocol_decode_envelope( + const session_protocol_decode_envelope_keys* keys, const void* envelope_plaintext, size_t envelope_plaintext_len, uint64_t unix_ts, @@ -1181,7 +1213,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( size_t pro_backend_pubkey_len, char* error, size_t error_len) { - session_protocol_decrypted_envelope result = {}; + session_protocol_decoded_envelope result = {}; // Setup the pro backend pubkey array_uc32 pro_backend_pubkey_cpp = {}; @@ -1306,7 +1338,7 @@ session_protocol_decrypted_envelope session_protocol_decrypt_envelope( } LIBSESSION_C_API -void session_protocol_decrypt_envelope_free(session_protocol_decrypted_envelope* envelope) { +void session_protocol_decode_envelope_free(session_protocol_decoded_envelope* envelope) { if (envelope) { free(envelope->content_plaintext.data); *envelope = {}; diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index f03b741d..64d61c10 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -155,8 +155,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Withhold the pro signature char error[256]; - session_protocol_encrypted_for_destination encrypt_without_pro_sig = - session_protocol_encrypt_for_1o1( + session_protocol_encoded_for_destination encrypt_without_pro_sig = + session_protocol_encode_for_1o1( data_body.data(), data_body.size(), keys.ed_sk0.data(), @@ -171,8 +171,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Set the pro signature bytes64 pro_sig = {}; - session_protocol_encrypted_for_destination encrypt_with_pro_sig = - session_protocol_encrypt_for_1o1( + session_protocol_encoded_for_destination encrypt_with_pro_sig = + session_protocol_encode_for_1o1( data_body.data(), data_body.size(), keys.ed_sk0.data(), @@ -186,8 +186,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Should have the same payload size REQUIRE(encrypt_without_pro_sig.ciphertext.size == encrypt_with_pro_sig.ciphertext.size); - session_protocol_encrypt_for_destination_free(&encrypt_without_pro_sig); - session_protocol_encrypt_for_destination_free(&encrypt_with_pro_sig); + session_protocol_encode_for_destination_free(&encrypt_without_pro_sig); + session_protocol_encode_for_destination_free(&encrypt_with_pro_sig); } // Setup a dummy "Session Pro Backend" key @@ -209,13 +209,13 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { } // Encrypt - session_protocol_encrypted_for_destination encrypt_result = {}; + session_protocol_encoded_for_destination encrypt_result = {}; { bytes64* pro_sig = nullptr; bytes33 recipient_pubkey = {}; std::memcpy(recipient_pubkey.data, keys.session_pk1.data(), keys.session_pk1.size()); - encrypt_result = session_protocol_encrypt_for_1o1( + encrypt_result = session_protocol_encode_for_1o1( plaintext.data(), plaintext.size(), keys.ed_sk0.data(), @@ -230,10 +230,10 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; + session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.ed25519_privkeys = &key; decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -244,7 +244,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro ProProof nil_proof = {}; @@ -264,7 +264,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } // Generate the user's Session Pro rotating key for testing encrypted payloads with Session @@ -319,8 +319,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { std::memcpy(dest.recipient_pubkey.data + 1, blind15_pk.data(), blind15_pk.size()); } - session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_for_destination( + session_protocol_encoded_for_destination encrypt_result = + session_protocol_encode_for_destination( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -331,31 +331,30 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(encrypt_result.ciphertext.size > 0); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); } } SECTION("Encrypt/decrypt for contact in default namespace with Pro") { // Encrypt content - session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_for_1o1( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - base_dest.sent_timestamp_ms, - &base_dest.recipient_pubkey, - base_dest.pro_sig, - error, - sizeof(error)); + session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_1o1( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + base_dest.pro_sig, + error, + sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; + session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.ed25519_privkeys = &key; decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -366,7 +365,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached @@ -384,7 +383,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { @@ -405,26 +404,24 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { pro_msg.features); // Encrypt content - session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_for_1o1( - protobuf_content_with_pro_and_features.plaintext.data(), - protobuf_content_with_pro_and_features.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - base_dest.sent_timestamp_ms, - &base_dest.recipient_pubkey, - &protobuf_content_with_pro_and_features - .sig_over_plaintext_with_user_pro_key_c, - error, - sizeof(error)); + session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_1o1( + protobuf_content_with_pro_and_features.plaintext.data(), + protobuf_content_with_pro_and_features.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + &protobuf_content_with_pro_and_features.sig_over_plaintext_with_user_pro_key_c, + error, + sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; + session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.ed25519_privkeys = &key; decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -435,7 +432,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached @@ -454,7 +451,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == large_message); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for legacy groups is rejected") { @@ -462,8 +459,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { dest.type = DESTINATION_TYPE_GROUP; assert(dest.recipient_pubkey.data[0] == 0x05); - session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_for_destination( + session_protocol_encoded_for_destination encrypt_result = + session_protocol_encode_for_destination( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -474,7 +471,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(encrypt_result.error_len_incl_null_terminator > 0); REQUIRE(encrypt_result.error_len_incl_null_terminator <= sizeof(error)); REQUIRE(!encrypt_result.success); - session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); } SECTION("Encrypt/decrypt for groups v2 (w/ encrypted envelope, plaintext content) with Pro") { @@ -487,7 +484,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { group_v2_pk.data(), group_v2_sk.data(), group_v2_seed.data()); // Encrypt - session_protocol_encrypted_for_destination encrypt_result = {}; + session_protocol_encoded_for_destination encrypt_result = {}; { bytes33 group_v2_session_pk = {}; bytes32 group_v2_session_sk = {}; @@ -496,7 +493,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { std::memcpy( group_v2_session_sk.data, group_v2_sk.data(), sizeof(group_v2_session_sk.data)); - encrypt_result = session_protocol_encrypt_for_group( + encrypt_result = session_protocol_encode_for_group( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -514,14 +511,14 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Decrypt envelope span_u8 key = {group_v2_sk.data(), group_v2_sk.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; + session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.group_ed25519_pubkey = {group_v2_pk.data(), group_v2_pk.size()}; decrypt_keys.ed25519_privkeys = &key; decrypt_keys.ed25519_privkeys_len = 1; // TODO: Finish setting up a group so we can check the decrypted result for now this will // throw because the keys aren't setup correctly. - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -535,32 +532,31 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encrypt_for_destination_free(&encrypt_result); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } SECTION("Encrypt/decrypt for sync messages with Pro") { // Encrypt - session_protocol_encrypted_for_destination encrypt_result = - session_protocol_encrypt_for_1o1( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - base_dest.sent_timestamp_ms, - &base_dest.recipient_pubkey, - base_dest.pro_sig, - error, - sizeof(error)); + session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_1o1( + protobuf_content_with_pro.plaintext.data(), + protobuf_content_with_pro.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + base_dest.sent_timestamp_ms, + &base_dest.recipient_pubkey, + base_dest.pro_sig, + error, + sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; + session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.ed25519_privkeys = &key; decrypt_keys.ed25519_privkeys_len = 1; { - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -588,12 +584,12 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_content.has_datamessage()); const SessionProtos::DataMessage& data = decrypt_content.datamessage(); REQUIRE(data.body() == data_body); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } // Try decrypt with a timestamp past the pro proof expiry date { - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -605,14 +601,14 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_EXPIRED); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } // Try decrypt with a bad backend key { array_uc32 bad_pro_backend_ed_pk = pro_backend_ed_pk; bad_pro_backend_ed_pk[0] ^= 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -624,16 +620,16 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_PRO_BACKEND_SIG); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } // Try decrypt with bad key (ed_sk0 which was the sender; ed_sk1 the recipient) span_u8 bad_key = {keys.ed_sk0.data(), keys.ed_sk0.size()}; { - session_protocol_decrypt_envelope_keys bad_decrypt_keys = {}; + session_protocol_decode_envelope_keys bad_decrypt_keys = {}; bad_decrypt_keys.ed25519_privkeys = &bad_key; bad_decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &bad_decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -647,16 +643,16 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(!decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator > 0); REQUIRE(decrypt_result.error_len_incl_null_terminator <= sizeof(error)); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } // Try decrypt with multiple keys, 1 bad, 1 good key { auto key_list = std::array{bad_key, key}; - session_protocol_decrypt_envelope_keys multi_decrypt_keys = {}; + session_protocol_decode_envelope_keys multi_decrypt_keys = {}; multi_decrypt_keys.ed25519_privkeys = key_list.data(); multi_decrypt_keys.ed25519_privkeys_len = key_list.size(); - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &multi_decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -670,18 +666,18 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } - session_protocol_encrypt_for_destination_free(&encrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); } SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { - session_protocol_encrypted_for_destination encrypt_result = {}; + session_protocol_encoded_for_destination encrypt_result = {}; { bytes64 pro_sig = base_pro_sig; pro_sig.data[0] ^= 1; // Break the sig by flipping a bit - encrypt_result = session_protocol_encrypt_for_1o1( + encrypt_result = session_protocol_encode_for_1o1( protobuf_content_with_pro.plaintext.data(), protobuf_content_with_pro.plaintext.size(), keys.ed_sk0.data(), @@ -695,10 +691,10 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { } span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decrypt_envelope_keys decrypt_keys = {}; + session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.ed25519_privkeys = &key; decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decrypted_envelope decrypt_result = session_protocol_decrypt_envelope( + session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, @@ -710,8 +706,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_USER_SIG); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encrypt_for_destination_free(&encrypt_result); - session_protocol_decrypt_envelope_free(&decrypt_result); + session_protocol_encode_for_destination_free(&encrypt_result); + session_protocol_decode_envelope_free(&decrypt_result); } SECTION("Encode/decode for community (content message)") { @@ -725,8 +721,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { } SECTION("Encode/decode for community (content message+pro)") { - std::vector encoded = encode_for_community( - to_span(protobuf_content_with_pro.plaintext), user_pro_ed_sk); + std::vector encoded = + encode_for_community(to_span(protobuf_content_with_pro.plaintext), user_pro_ed_sk); DecodedCommunityMessage decode_comm_msg = decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); From 30f0df1251f136a21e464e31470206daf8fdcf2a Mon Sep 17 00:00:00 2001 From: doylet Date: Sat, 27 Sep 2025 14:16:27 +1000 Subject: [PATCH 095/171] Simplify encrypt_for_destination because we do not need to support legacy groups --- src/session_protocol.cpp | 194 ++++++++++++--------------------------- 1 file changed, 59 insertions(+), 135 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index ac57888e..b65124e9 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -295,6 +295,9 @@ struct EncryptedForDestinationInternal { constexpr char PADDING_TERMINATING_BYTE = 0x80; +// TODO: Implement pro signing on behalf of the clients by getting them to pass in the pro rotating +// secret key + enum class UseMalloc { No, Yes }; static EncryptedForDestinationInternal encode_for_destination_internal( std::span plaintext, @@ -307,7 +310,6 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::span dest_group_ed25519_pubkey, std::span dest_group_ed25519_privkey, UseMalloc use_malloc) { - assert(dest_pro_sig.empty() || dest_pro_sig.size() == crypto_sign_ed25519_BYTES); assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); @@ -316,76 +318,25 @@ static EncryptedForDestinationInternal encode_for_destination_internal( // All incoming arguments are passed in from typed, fixed-sized arrays so we do not need to // throw if these sizes are wrong. It being wrong would be a development error. - EncryptedForDestinationInternal result = {}; - enum class Mode { - Envelope, - EncryptForBlindedRecipient, - }; - - // The step to partake after enveloping the content payload - enum class AfterEnvelope { - Nil, - EnvelopeIsCipherText, // No extra bit-mangling required after enveloping - WrapInWSMessage, // Wrap in the protobuf websocket message after enveloping - KeysEncryptMessage, // Encrypt with the group keys after ennveloping - }; - - struct EncodeContext { - Mode mode; - - // Ciphertext storing the result of encrypt for recipient deterministic, if it was necessary - // to encrypt before enveloping. - std::vector before_envelope_ciphertext; - - // Payload to set the envelope source if necessary. - std::optional> envelope_src; - - // Type of message to mark the enevelope as - std::optional envelope_type; - - // Action to take after generating the envelope (e.g.: further encryption/wrapping) - AfterEnvelope after_envelope; - }; - - // Figure out how to encrypt the message based on the destination and setup the encoding context - EncodeContext enc = {}; switch (dest_type) { - case DestinationType::Group: { - bool has_03_prefix = - dest_group_ed25519_pubkey[0] == static_cast(SessionIDPrefix::group); - if (has_03_prefix) { - enc.mode = Mode::Envelope; - enc.after_envelope = AfterEnvelope::KeysEncryptMessage; - enc.envelope_type = - SessionProtos::Envelope_Type::Envelope_Type_CLOSED_GROUP_MESSAGE; - } else { + case DestinationType::Group: /*FALLTHRU*/ + case DestinationType::ContactOrSyncMessage: { + bool is_group = dest_type == DestinationType::Group; + bool is_1o1 = dest_type == DestinationType::ContactOrSyncMessage; + if (is_group && + dest_group_ed25519_pubkey[0] != static_cast(SessionIDPrefix::group)) { // Legacy groups which have a 05 prefixed key throw std::runtime_error{ "Unsupported configuration, encrypting for a legacy group (0x05 prefix) is " "no longer supported"}; } - } break; - case DestinationType::ContactOrSyncMessage: { - enc.mode = Mode::Envelope; - enc.envelope_type = SessionProtos::Envelope_Type::Envelope_Type_SESSION_MESSAGE; - enc.after_envelope = AfterEnvelope::WrapInWSMessage; - } break; - - case DestinationType::CommunityInbox: { - enc.mode = Mode::EncryptForBlindedRecipient; - } break; - } - - // Do the encryption work - switch (enc.mode) { - case Mode::Envelope: { - assert(enc.envelope_type.has_value()); + // For Sync or 1o1 mesasges, we need to pad the contents to 160 bytes, see: + // https://github.com/session-foundation/session-desktop/blob/a04e62427034a6b6fee39dcff7dbabf0d0131b13/ts/session/crypto/BufferPadding.ts#L49 std::span content = plaintext; - if (dest_type == DestinationType::ContactOrSyncMessage) { - // For Sync or 1o1 mesasges, we need to pad the contents to 160 bytes, see: - // https://github.com/session-foundation/session-desktop/blob/a04e62427034a6b6fee39dcff7dbabf0d0131b13/ts/session/crypto/BufferPadding.ts#L49 + std::vector content_for_1o1; + if (is_1o1) { const size_t MSG_PADDING = 160; // Calculate amount of padding required @@ -401,23 +352,21 @@ static EncryptedForDestinationInternal encode_for_destination_internal( padded_content[content.size()] = PADDING_TERMINATING_BYTE; // Encrypt the padded output - enc.before_envelope_ciphertext = encrypt_for_recipient_deterministic( + content_for_1o1 = encrypt_for_recipient_deterministic( ed25519_privkey, dest_recipient_pubkey, padded_content); - content = enc.before_envelope_ciphertext; + content = content_for_1o1; } // Create envelope // Set sourcedevice to 1 as per: // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Utilities/MessageWrapper.swift#L57 SessionProtos::Envelope envelope = {}; - envelope.set_type(*enc.envelope_type); + envelope.set_type( + is_1o1 ? SessionProtos::Envelope_Type_SESSION_MESSAGE + : SessionProtos::Envelope_Type_CLOSED_GROUP_MESSAGE); envelope.set_sourcedevice(1); envelope.set_timestamp(dest_sent_timestamp_ms.count()); envelope.set_content(content.data(), content.size()); - if (enc.envelope_src) - envelope.set_source( - reinterpret_cast(enc.envelope_src->data()), - enc.envelope_src->size()); if (dest_pro_sig.empty()) { // If there's no pro signature specified, we still fill out the pro signature with a @@ -429,74 +378,50 @@ static EncryptedForDestinationInternal encode_for_destination_internal( envelope.set_prosig(dest_pro_sig.data(), dest_pro_sig.size()); } - switch (enc.after_envelope) { - case AfterEnvelope::Nil: - assert(false && "Dev error, after envelope action was not set"); - break; - - case AfterEnvelope::KeysEncryptMessage: { - std::string bytes = envelope.SerializeAsString(); - if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) - dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); - - std::vector ciphertext = encrypt_for_group( - ed25519_privkey, - dest_group_ed25519_pubkey, - dest_group_ed25519_privkey, - to_span(bytes), - /*compress*/ true, - /*padding*/ 256); - - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = - span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); - } else { - result.ciphertext_cpp = std::move(ciphertext); - } - } break; - - case AfterEnvelope::WrapInWSMessage: { - // Setup message - WebSocketProtos::WebSocketMessage msg = {}; - msg.set_type( - WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); - - // Make request - WebSocketProtos::WebSocketRequestMessage* req_msg = msg.mutable_request(); - req_msg->set_body(envelope.SerializeAsString()); - - // Write message as ciphertext - [[maybe_unused]] bool serialized = false; - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_alloc_or_throw(msg.ByteSizeLong()); - serialized = msg.SerializeToArray( - result.ciphertext_c.data, result.ciphertext_c.size); - } else { - result.ciphertext_cpp.resize(msg.ByteSizeLong()); - serialized = msg.SerializeToArray( - result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); - } - assert(serialized); - } break; - - case AfterEnvelope::EnvelopeIsCipherText: { - [[maybe_unused]] bool serialized = false; - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_alloc_or_throw(envelope.ByteSizeLong()); - serialized = envelope.SerializeToArray( - result.ciphertext_c.data, result.ciphertext_c.size); - } else { - result.ciphertext_cpp.resize(envelope.ByteSizeLong()); - serialized = envelope.SerializeToArray( - result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); - } - assert(serialized); - } break; + if (is_group) { + std::string bytes = envelope.SerializeAsString(); + if (dest_group_ed25519_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES + 1) + dest_group_ed25519_pubkey = dest_group_ed25519_pubkey.subspan(1); + + std::vector ciphertext = encrypt_for_group( + ed25519_privkey, + dest_group_ed25519_pubkey, + dest_group_ed25519_privkey, + to_span(bytes), + /*compress*/ true, + /*padding*/ 256); + + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = + span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + } else { + result.ciphertext_cpp = std::move(ciphertext); + } + } else { + // 1o1, Wrap in websocket message + WebSocketProtos::WebSocketMessage msg = {}; + msg.set_type(WebSocketProtos::WebSocketMessage_Type::WebSocketMessage_Type_REQUEST); + + // Make request + WebSocketProtos::WebSocketRequestMessage* req_msg = msg.mutable_request(); + req_msg->set_body(envelope.SerializeAsString()); + + // Write message as ciphertext + [[maybe_unused]] bool serialized = false; + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_alloc_or_throw(msg.ByteSizeLong()); + serialized = msg.SerializeToArray( + result.ciphertext_c.data, result.ciphertext_c.size); + } else { + result.ciphertext_cpp.resize(msg.ByteSizeLong()); + serialized = msg.SerializeToArray( + result.ciphertext_cpp.data(), result.ciphertext_cpp.size()); + } + assert(serialized); } - } break; - case Mode::EncryptForBlindedRecipient: { + case DestinationType::CommunityInbox: { std::vector ciphertext = encrypt_for_blinded_recipient( ed25519_privkey, dest_community_inbox_server_pubkey, @@ -510,7 +435,6 @@ static EncryptedForDestinationInternal encode_for_destination_internal( } } break; } - return result; } From cb68083bd1e09a3b596d6d89601301265365483b Mon Sep 17 00:00:00 2001 From: doylet Date: Sat, 27 Sep 2025 14:41:58 +1000 Subject: [PATCH 096/171] Correctly prefix pro structures in session protocol --- include/session/config/pro.h | 2 +- include/session/pro_backend.h | 2 +- include/session/session_protocol.h | 121 ++++++++++++++------------- include/session/session_protocol.hpp | 25 +++--- src/session_protocol.cpp | 102 +++++++++++----------- tests/test_config_pro.cpp | 9 +- tests/test_pro_backend.cpp | 14 ++-- tests/test_session_protocol.cpp | 93 +++++++++++--------- 8 files changed, 198 insertions(+), 170 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 896d1922..13ce5273 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -13,7 +13,7 @@ extern "C" { typedef struct pro_config { bytes64 rotating_privkey; - pro_proof proof; + 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` diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 35ccd036..c4e8c0a7 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -123,7 +123,7 @@ typedef struct session_pro_backend_get_pro_proof_request { typedef struct session_pro_backend_add_pro_payment_or_get_pro_proof_response { session_pro_backend_response_header header; - pro_proof proof; + session_protocol_pro_proof proof; } session_pro_backend_add_pro_payment_or_get_pro_proof_response; typedef struct session_pro_backend_get_pro_revocations_request { diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 91fc6c3b..c1965aff 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -16,65 +16,66 @@ enum { /// Maximum number of UTF16 code points that a standard message can use. If the message exceeds /// this then the message must activate the higher character limit feature provided by Session /// Pro which allows messages up to 10k characters. - PRO_STANDARD_CHARACTER_LIMIT = 2'000, + SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT = 2'000, /// Maximum number of UTF16 code points that a Session Pro entitled user can send in a message. /// This is not used in the codebase, but is provided for convenience to centralise protocol /// definitions for users of the library to consume. - PRO_HIGHER_CHARACTER_LIMIT = 10'000, + SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT = 10'000, }; -typedef enum PRO_STATUS { // See session::ProStatus - PRO_STATUS_NIL, - PRO_STATUS_INVALID_PRO_BACKEND_SIG, - PRO_STATUS_INVALID_USER_SIG, - PRO_STATUS_VALID, - PRO_STATUS_EXPIRED, +typedef enum SESSION_PROTOCOL_PRO_STATUS { // See session::ProStatus + SESSION_PROTOCOL_PRO_STATUS_NIL, + SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG, + SESSION_PROTOCOL_PRO_STATUS_INVALID_USER_SIG, + SESSION_PROTOCOL_PRO_STATUS_VALID, + SESSION_PROTOCOL_PRO_STATUS_EXPIRED, } PRO_STATUS; -typedef struct pro_signed_message { +typedef struct session_protocol_pro_signed_message { span_u8 sig; span_u8 msg; -} pro_signed_message; +} session_protocol_pro_signed_message; -typedef struct pro_proof { +typedef struct session_protocol_pro_proof { uint8_t version; bytes32 gen_index_hash; bytes32 rotating_pubkey; uint64_t expiry_unix_ts_ms; bytes64 sig; -} pro_proof; +} session_protocol_pro_proof; // Bit flags for features that are not currently able to be determined by the state stored in // Libsession. They are to be passed in by the client into `get_pro_msg_for_features` to return the // bitset of `PRO_FEATURES` that a message will use. -typedef uint64_t PRO_EXTRA_FEATURES; -enum PRO_EXTRA_FEATURES_ { - PRO_EXTRA_FEATURES_NIL = 0, - PRO_EXTRA_FEATURES_PRO_BADGE = 1 << 0, - PRO_EXTRA_FEATURES_ANIMATED_AVATAR = 1 << 1, +typedef uint64_t SESSION_PROTOCOL_PRO_EXTRA_FEATURES; +enum SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ { + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_NIL = 0, + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE = 1 << 0, + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR = 1 << 1, }; // Bitset of Session Pro features that a message uses. This bitset is stored in the protobuf // `Content.proMessage` when a message is sent for other clients to consume. -typedef uint64_t PRO_FEATURES; -enum PRO_FEATURES_ { - PRO_FEATURES_NIL = 0, - PRO_FEATURES_10K_CHARACTER_LIMIT = 1 << 0, - PRO_FEATURES_PRO_BADGE = 1 << 1, - PRO_FEATURES_ANIMATED_AVATAR = 1 << 2, - PRO_FEATURES_ALL = - PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR +typedef uint64_t SESSION_PROTOCOL_PRO_FEATURES; +enum SESSION_PROTOCOL_PRO_FEATURES_ { + SESSION_PROTOCOL_PRO_FEATURES_NIL = 0, + SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT = 1 << 0, + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE = 1 << 1, + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR = 1 << 2, + SESSION_PROTOCOL_PRO_FEATURES_ALL = SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR }; -typedef enum DESTINATION_TYPE { // See session::DestinationType - DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE, - DESTINATION_TYPE_GROUP, - DESTINATION_TYPE_COMMUNITY_INBOX, -} DESTINATION_TYPE; +typedef enum SESSION_PROTOCOL_DESTINATION_TYPE { // See session::DestinationType + SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1, + SESSION_PROTOCOL_DESTINATION_TYPE_GROUP, + SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX, +} SESSION_PROTOCOL_DESTINATION_TYPE; typedef struct session_protocol_destination { // See session::Destination - DESTINATION_TYPE type; + SESSION_PROTOCOL_DESTINATION_TYPE type; // The pro signature is optional, set the pointer to a 64 byte pro signature // to include it into the encrypted message, ignored otherwise @@ -88,16 +89,16 @@ typedef struct session_protocol_destination { // See session::Destination // Indicates which optional fields in the envelope has been populated out of the optional fields in // an envelope after it has been parsed off the wire. -typedef uint32_t ENVELOPE_FLAGS; +typedef uint32_t SESSION_PROTOCOL_ENVELOPE_FLAGS; enum ENVELOPE_FLAGS_ { - ENVELOPE_FLAGS_SOURCE = 1 << 0, - ENVELOPE_FLAGS_SOURCE_DEVICE = 1 << 1, - ENVELOPE_FLAGS_SERVER_TIMESTAMP = 1 << 2, - ENVELOPE_FLAGS_PRO_SIG = 1 << 3, + SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE = 1 << 0, + SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE_DEVICE = 1 << 1, + SESSION_PROTOCOL_ENVELOPE_FLAGS_SERVER_TIMESTAMP = 1 << 2, + SESSION_PROTOCOL_ENVELOPE_FLAGS_PRO_SIG = 1 << 3, }; typedef struct session_protocol_envelope { - ENVELOPE_FLAGS flags; + SESSION_PROTOCOL_ENVELOPE_FLAGS flags; uint64_t timestamp_ms; bytes33 source; uint32_t source_device; @@ -120,8 +121,8 @@ typedef struct session_protocol_decode_envelope { bytes32 sender_ed25519_pubkey; bytes32 sender_x25519_pubkey; PRO_STATUS pro_status; - pro_proof pro_proof; - PRO_FEATURES pro_features; + session_protocol_pro_proof pro_proof; + SESSION_PROTOCOL_PRO_FEATURES pro_features; size_t error_len_incl_null_terminator; } session_protocol_decoded_envelope; @@ -133,7 +134,7 @@ typedef struct session_protocol_encoded_for_destination { size_t error_len_incl_null_terminator; } session_protocol_encoded_for_destination; -/// API: pro/pro_proof_hash +/// API: session_protocol/session_protocol_pro_proof_hash /// /// Generate the 32 byte hash that is to be signed by the rotating key or Session Pro Backend key to /// embed in the envelope or proof respectively which other clients use to authenticate the validity @@ -144,9 +145,10 @@ typedef struct session_protocol_encoded_for_destination { /// /// Outputs: /// - `bytes32` -- The 32 byte hash calculated from the proof -LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof) NON_NULL_ARG(1); +LIBSESSION_EXPORT bytes32 session_protocol_pro_proof_hash(session_protocol_pro_proof const* proof) + NON_NULL_ARG(1); -/// API: pro/pro_proof_verify_signature +/// API: session_protocol/session_protocol_pro_proof_verify_signature /// /// Verify the proof was signed by the `verify_pubkey` /// @@ -159,11 +161,12 @@ LIBSESSION_EXPORT bytes32 pro_proof_hash(pro_proof const* proof) NON_NULL_ARG(1) /// /// Outputs: /// - `bool` -- True if verified, false otherwise -LIBSESSION_EXPORT bool pro_proof_verify_signature( - pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) - NON_NULL_ARG(1, 2); +LIBSESSION_EXPORT bool session_protocol_pro_proof_verify_signature( + session_protocol_pro_proof const* proof, + uint8_t const* verify_pubkey, + size_t verify_pubkey_len) NON_NULL_ARG(1, 2); -/// API: pro/pro_proof_verify_message +/// API: session_protocol/session_protocol_pro_proof_verify_message /// /// Check if the `rotating_pubkey` in the proof was the signatory of the message and signature /// passed in. This function throws if an signature is passed in that isn't 64 bytes. @@ -179,14 +182,14 @@ LIBSESSION_EXPORT bool pro_proof_verify_signature( /// /// Outputs: /// - `bool` -- True if verified, false otherwise (bad signature, or, invalid arguments). -LIBSESSION_EXPORT bool pro_proof_verify_message( - pro_proof const* proof, +LIBSESSION_EXPORT bool session_protocol_pro_proof_verify_message( + session_protocol_pro_proof const* proof, uint8_t const* sig, size_t sig_len, uint8_t const* msg, size_t msg_len) NON_NULL_ARG(1, 2, 4); -/// API: pro/pro_proof_is_active +/// API: session_protocol/session_protocol_pro_proof_is_active /// /// Check if the Pro proof is currently entitled to Pro given the `unix_ts` with respect to the /// proof's `expiry_unix_ts` @@ -197,10 +200,10 @@ LIBSESSION_EXPORT bool pro_proof_verify_message( /// /// Outputs: /// - `bool` -- True if expired, false otherwise -LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_ms) - NON_NULL_ARG(1); +LIBSESSION_EXPORT bool session_protocol_pro_proof_is_active( + session_protocol_pro_proof const* proof, uint64_t unix_ts_ms) NON_NULL_ARG(1); -/// API: pro/pro_proof_status +/// API: session_protocol/session_protocol_pro_proof_status /// /// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has /// not expired via `unix_ts_s` and optionally verify that the `signed_msg` was signed by the @@ -226,18 +229,18 @@ LIBSESSION_EXPORT bool pro_proof_is_active(pro_proof const* proof, uint64_t unix /// - `status` - The derived status given the components of the message. If `signed_msg` is /// not set then this function can never return `PRO_STATUS_INVALID_USER_SIG` from the set of /// possible enum values. Otherwise this funtion can return all possible values. -LIBSESSION_EXPORT PRO_STATUS pro_proof_status( - pro_proof const* proof, +LIBSESSION_EXPORT PRO_STATUS session_protocol_pro_proof_status( + session_protocol_pro_proof const* proof, const uint8_t* verify_pubkey, size_t verify_pubkey_len, uint64_t unix_ts_s, - OPTIONAL const pro_signed_message* signed_msg) NON_NULL_ARG(1, 2); + OPTIONAL const session_protocol_pro_signed_message* signed_msg) NON_NULL_ARG(1, 2); /// API: session_protocol/session_protocol_get_pro_features_for_msg typedef struct session_protocol_pro_features_for_msg { bool success; string8 error; - PRO_FEATURES features; + SESSION_PROTOCOL_PRO_FEATURES features; size_t codepoint_count; } session_protocol_pro_features_for_msg; @@ -262,7 +265,8 @@ typedef struct session_protocol_pro_features_for_msg { /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( - char const* utf8, size_t utf8_size, PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); + char const* utf8, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) + NON_NULL_ARG(1); /// API: session_protocol/session_protocol_get_pro_features_for_utf16 /// @@ -285,7 +289,8 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( - uint16_t const* utf16, size_t utf16_size, PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); + uint16_t const* utf16, size_t utf16_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) + NON_NULL_ARG(1); /// API: session_protocol_encode_for_1o1 /// diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 62a89ce7..4a632fd1 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -58,11 +58,11 @@ enum ProProofVersion { ProProofVersion_v0 }; enum class ProStatus { // Pro proof sig was not signed by the Pro backend key - InvalidProBackendSig = PRO_STATUS_INVALID_PRO_BACKEND_SIG, + InvalidProBackendSig = SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG, // Pro sig in the envelope was not signed by the Rotating key - InvalidUserSig = PRO_STATUS_INVALID_USER_SIG, - Valid = PRO_STATUS_VALID, // Proof is verified; has not expired - Expired = PRO_STATUS_EXPIRED, // Proof is verified; has expired + InvalidUserSig = SESSION_PROTOCOL_PRO_STATUS_INVALID_USER_SIG, + Valid = SESSION_PROTOCOL_PRO_STATUS_VALID, // Proof is verified; has not expired + Expired = SESSION_PROTOCOL_PRO_STATUS_EXPIRED, // Proof is verified; has expired }; struct ProSignedMessage { @@ -171,17 +171,17 @@ class ProProof { struct ProFeaturesForMsg { bool success; std::string_view error; - PRO_FEATURES features; + SESSION_PROTOCOL_PRO_FEATURES features; size_t codepoint_count; }; enum class DestinationType { - ContactOrSyncMessage = DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE, + SyncOr1o1 = SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1, /// Both legacy and non-legacy groups are to be identified as `Group`. A non-legacy /// group is detected by the (0x03) prefix byte on the given `dest_group_pubkey` specified in /// Destination. - Group = DESTINATION_TYPE_GROUP, - CommunityInbox = DESTINATION_TYPE_COMMUNITY_INBOX, + Group = SESSION_PROTOCOL_DESTINATION_TYPE_GROUP, + CommunityInbox = SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX, }; struct Destination { @@ -214,7 +214,7 @@ struct Destination { }; struct Envelope { - ENVELOPE_FLAGS flags; + SESSION_PROTOCOL_ENVELOPE_FLAGS flags; std::chrono::milliseconds timestamp; // Optional fields. These fields are set if the appropriate flag has been set in `flags` @@ -233,7 +233,8 @@ struct DecodedPro { // Session Pro proof that was embedded in the envelope, this is always populated irrespective of // the status but the validity of the contents should be verified by checking `status` ProProof proof; - PRO_FEATURES features; // Bit flag features that were used in the embedded message + SESSION_PROTOCOL_PRO_FEATURES + features; // Bit flag features that were used in the embedded message }; struct DecodedEnvelope { @@ -324,7 +325,7 @@ struct DecodeEnvelopeKey { /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf8( - char const* utf8, size_t utf8_size, PRO_EXTRA_FEATURES flags); + char const* utf8, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); /// API: session_protocol/pro_features_for_utf16 /// @@ -345,7 +346,7 @@ ProFeaturesForMsg pro_features_for_utf8( /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf16( - char16_t const* utf16, size_t utf8_size, PRO_EXTRA_FEATURES flags); + char16_t const* utf16, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); /// API: session_protocol/encode_for_1o1 /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index b65124e9..df1c2857 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -137,7 +137,7 @@ array_uc32 ProProof::hash() const { } session::ProFeaturesForMsg pro_features_for_utf8_or_16( - const void* utf, size_t utf_size, PRO_EXTRA_FEATURES extra, bool is_utf8) { + const void* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra, bool is_utf8) { session::ProFeaturesForMsg result = {}; simdutf::result validate = is_utf8 ? simdutf::validate_utf8_with_errors( reinterpret_cast(utf), utf_size) @@ -148,16 +148,16 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( result.codepoint_count = is_utf8 ? simdutf::count_utf8(reinterpret_cast(utf), utf_size) : simdutf::count_utf16(reinterpret_cast(utf), utf_size); - if (result.codepoint_count > PRO_STANDARD_CHARACTER_LIMIT) - result.features |= PRO_FEATURES_10K_CHARACTER_LIMIT; + if (result.codepoint_count > SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT) + result.features |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - if (extra & PRO_EXTRA_FEATURES_ANIMATED_AVATAR) - result.features |= PRO_FEATURES_ANIMATED_AVATAR; + if (extra & SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR) + result.features |= SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR; - if (extra & PRO_EXTRA_FEATURES_PRO_BADGE) - result.features |= PRO_FEATURES_PRO_BADGE; + if (extra & SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE) + result.features |= SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE; - assert((result.features & ~PRO_FEATURES_ALL) == 0); + assert((result.features & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) == 0); } else { result.error = simdutf::error_to_string(validate.error); } @@ -168,13 +168,13 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( namespace session { ProFeaturesForMsg pro_features_for_utf8( - const char* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); return result; } ProFeaturesForMsg pro_features_for_utf16( - const uint16_t* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + const uint16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); return result; } @@ -186,7 +186,7 @@ std::vector encode_for_1o1( const array_uc33& recipient_pubkey, const std::optional& pro_sig) { Destination dest = {}; - dest.type = DestinationType::ContactOrSyncMessage; + dest.type = DestinationType::SyncOr1o1; dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; @@ -321,9 +321,9 @@ static EncryptedForDestinationInternal encode_for_destination_internal( EncryptedForDestinationInternal result = {}; switch (dest_type) { case DestinationType::Group: /*FALLTHRU*/ - case DestinationType::ContactOrSyncMessage: { + case DestinationType::SyncOr1o1: { bool is_group = dest_type == DestinationType::Group; - bool is_1o1 = dest_type == DestinationType::ContactOrSyncMessage; + bool is_1o1 = dest_type == DestinationType::SyncOr1o1; if (is_group && dest_group_ed25519_pubkey[0] != static_cast(SessionIDPrefix::group)) { // Legacy groups which have a 05 prefixed key @@ -534,19 +534,19 @@ DecodedEnvelope decode_envelope( throw std::runtime_error(fmt::format( "Parse envelope failed, source had unexpected size ({} bytes)", source.size())); std::memcpy(result.envelope.source.data(), source.data(), source.size()); - result.envelope.flags |= ENVELOPE_FLAGS_SOURCE; + result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE; } // Parse source device (optional) if (envelope.has_sourcedevice()) { result.envelope.source_device = envelope.sourcedevice(); - result.envelope.flags |= ENVELOPE_FLAGS_SOURCE_DEVICE; + result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE_DEVICE; } // Parse server timestamp (optional) if (envelope.has_servertimestamp()) { result.envelope.server_timestamp = envelope.servertimestamp(); - result.envelope.flags |= ENVELOPE_FLAGS_SERVER_TIMESTAMP; + result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SERVER_TIMESTAMP; } // Parse content @@ -650,7 +650,7 @@ DecodedEnvelope decode_envelope( if (content.has_promessage()) { // Mark the envelope as having a pro signature that the caller can use. - result.envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; + result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_PRO_SIG; DecodedPro& pro = result.pro.emplace(); // Extract the pro message @@ -747,24 +747,24 @@ DecodedCommunityMessage decode_for_community( "Parse envelope failed, source had unexpected size ({} bytes)", source.size())); std::memcpy(envelope.source.data(), source.data(), source.size()); - envelope.flags |= ENVELOPE_FLAGS_SOURCE; + envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE; } // Parse source device (optional) if (pb_envelope.has_sourcedevice()) { envelope.source_device = pb_envelope.sourcedevice(); - envelope.flags |= ENVELOPE_FLAGS_SOURCE_DEVICE; + envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE_DEVICE; } // Parse server timestamp (optional) if (pb_envelope.has_servertimestamp()) { envelope.server_timestamp = pb_envelope.servertimestamp(); - envelope.flags |= ENVELOPE_FLAGS_SERVER_TIMESTAMP; + envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SERVER_TIMESTAMP; } // Parse pro signature (optional) if (pb_envelope.has_prosig()) { - envelope.flags |= ENVELOPE_FLAGS_PRO_SIG; + envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_PRO_SIG; pro_sig = to_span(pb_envelope.prosig()); } } else { @@ -785,7 +785,7 @@ DecodedCommunityMessage decode_for_community( if (content.has_prosigforcommunitymessageonly()) { // Signature must be in the envelope if it existed or the content. Specifying both is // not allowed. - if (result.envelope && result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG) { + if (result.envelope && result.envelope->flags & SESSION_PROTOCOL_ENVELOPE_FLAGS_PRO_SIG) { throw std::runtime_error( "Decoding community message failed, envelope and content both had a pro " "signature specified"); @@ -861,7 +861,7 @@ DecodedCommunityMessage decode_for_community( if (result.envelope) { // Entering the `pro_sig` and `result.envelope` branch means that the envelope must have // a pro signature. - assert(result.envelope->flags & ENVELOPE_FLAGS_PRO_SIG); + assert(result.envelope->flags & SESSION_PROTOCOL_ENVELOPE_FLAGS_PRO_SIG); signed_msg.msg = result.content_plaintext; pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); } else { @@ -886,11 +886,13 @@ DecodedCommunityMessage decode_for_community( using namespace session; -static_assert((sizeof((pro_proof*)0)->gen_index_hash) == 32); -static_assert((sizeof((pro_proof*)0)->rotating_pubkey) == crypto_sign_ed25519_PUBLICKEYBYTES); -static_assert((sizeof((pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); +static_assert((sizeof((session_protocol_pro_proof*)0)->gen_index_hash) == 32); +static_assert( + (sizeof((session_protocol_pro_proof*)0)->rotating_pubkey) == + crypto_sign_ed25519_PUBLICKEYBYTES); +static_assert((sizeof((session_protocol_pro_proof*)0)->sig) == crypto_sign_ed25519_BYTES); -LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { +LIBSESSION_C_API bytes32 session_protocol_pro_proof_hash(session_protocol_pro_proof const* proof) { bytes32 result = {}; session::array_uc32 hash = proof_hash_internal( proof->version, @@ -901,8 +903,10 @@ LIBSESSION_C_API bytes32 pro_proof_hash(pro_proof const* proof) { return result; } -LIBSESSION_C_API bool pro_proof_verify_signature( - pro_proof const* proof, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { +LIBSESSION_C_API bool session_protocol_pro_proof_verify_signature( + session_protocol_pro_proof const* proof, + uint8_t const* verify_pubkey, + size_t verify_pubkey_len) { if (verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) return false; auto verify_pubkey_span = std::span(verify_pubkey, verify_pubkey_len); @@ -915,8 +919,8 @@ LIBSESSION_C_API bool pro_proof_verify_signature( return result; } -LIBSESSION_C_API bool pro_proof_verify_message( - pro_proof const* proof, +LIBSESSION_C_API bool session_protocol_pro_proof_verify_message( + session_protocol_pro_proof const* proof, uint8_t const* sig, size_t sig_len, uint8_t const* msg, @@ -927,41 +931,43 @@ LIBSESSION_C_API bool pro_proof_verify_message( return result; } -LIBSESSION_C_API bool pro_proof_is_active(pro_proof const* proof, uint64_t unix_ts_ms) { +LIBSESSION_C_API bool session_protocol_pro_proof_is_active( + session_protocol_pro_proof const* proof, uint64_t unix_ts_ms) { bool result = proof_is_active_internal(proof->expiry_unix_ts_ms, unix_ts_ms); return result; } -LIBSESSION_C_API PRO_STATUS pro_proof_status( - pro_proof const* proof, +LIBSESSION_C_API PRO_STATUS session_protocol_pro_proof_status( + session_protocol_pro_proof const* proof, const uint8_t* verify_pubkey, size_t verify_pubkey_len, uint64_t unix_ts_s, - const pro_signed_message* signed_msg) { - PRO_STATUS result = PRO_STATUS_VALID; - if (!pro_proof_verify_signature(proof, verify_pubkey, verify_pubkey_len)) - result = PRO_STATUS_INVALID_PRO_BACKEND_SIG; + const session_protocol_pro_signed_message* signed_msg) { + PRO_STATUS result = SESSION_PROTOCOL_PRO_STATUS_VALID; + if (!session_protocol_pro_proof_verify_signature(proof, verify_pubkey, verify_pubkey_len)) + result = SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG; // Check if the message was signed if the user passed one in to verify against - if (result == PRO_STATUS_VALID && signed_msg) { - if (!pro_proof_verify_message( + if (result == SESSION_PROTOCOL_PRO_STATUS_VALID && signed_msg) { + if (!session_protocol_pro_proof_verify_message( proof, signed_msg->sig.data, signed_msg->sig.size, signed_msg->msg.data, signed_msg->msg.size)) - result = PRO_STATUS_INVALID_USER_SIG; + result = SESSION_PROTOCOL_PRO_STATUS_INVALID_USER_SIG; } // Check if the proof has expired - if (result == PRO_STATUS_VALID && !pro_proof_is_active(proof, unix_ts_s)) - result = PRO_STATUS_EXPIRED; + if (result == SESSION_PROTOCOL_PRO_STATUS_VALID && + !session_protocol_pro_proof_is_active(proof, unix_ts_s)) + result = SESSION_PROTOCOL_PRO_STATUS_EXPIRED; return result; } LIBSESSION_C_API session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( - const char* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { ProFeaturesForMsg result_cpp = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); session_protocol_pro_features_for_msg result = { @@ -975,7 +981,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( LIBSESSION_C_API session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( - const uint16_t* utf, size_t utf_size, PRO_EXTRA_FEATURES extra) { + const uint16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { ProFeaturesForMsg result_cpp = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); session_protocol_pro_features_for_msg result = { @@ -1000,7 +1006,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( size_t error_len) { session_protocol_destination dest = {}; - dest.type = DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE; + dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1; dest.pro_sig = pro_sig; dest.recipient_pubkey = *recipient_pubkey; dest.sent_timestamp_ms = sent_timestamp_ms; @@ -1030,7 +1036,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i size_t error_len) { session_protocol_destination dest = {}; - dest.type = DESTINATION_TYPE_COMMUNITY_INBOX; + dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX; dest.pro_sig = pro_sig; dest.sent_timestamp_ms = sent_timestamp_ms; dest.recipient_pubkey = *recipient_pubkey; @@ -1061,7 +1067,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( size_t error_len) { session_protocol_destination dest = {}; - dest.type = DESTINATION_TYPE_GROUP; + dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_GROUP; dest.pro_sig = pro_sig; dest.group_ed25519_pubkey = *group_ed25519_pubkey; dest.group_ed25519_privkey = *group_ed25519_privkey; diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 73682c9f..c3616318 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -44,7 +44,7 @@ TEST_CASE("Pro", "[config][pro]") { // Generate the hashes static_assert(crypto_sign_ed25519_BYTES == pro_cpp.proof.sig.max_size()); std::array hash_to_sign_cpp = pro_cpp.proof.hash(); - bytes32 hash_to_sign = pro_proof_hash(&pro.proof); + bytes32 hash_to_sign = session_protocol_pro_proof_hash(&pro.proof); static_assert(hash_to_sign_cpp.size() == sizeof(hash_to_sign)); CHECK(std::memcmp(hash_to_sign_cpp.data(), hash_to_sign.data, hash_to_sign_cpp.size()) == @@ -82,8 +82,9 @@ TEST_CASE("Pro", "[config][pro]") { CHECK(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts)); CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1ms)); - CHECK(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms)); - CHECK_FALSE(pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms + 1)); + CHECK(session_protocol_pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms)); + CHECK_FALSE( + session_protocol_pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms + 1)); } // Verify it can verify messages signed with the rotating public key @@ -98,7 +99,7 @@ TEST_CASE("Pro", "[config][pro]") { rotating_sk.data()); CHECK(sign_result == 0); CHECK(pro_cpp.proof.verify_message(sig, session::to_span(body))); - CHECK(pro_proof_verify_message( + CHECK(session_protocol_pro_proof_verify_message( &pro.proof, sig.data(), sig.size(), diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 6b0298af..e844a8a3 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -26,7 +26,7 @@ using namespace session::pro_backend; static bool string8_equals(string8 s8, std::string_view str) { return s8.size == str.size() && std::memcmp(s8.data, str.data(), s8.size) == 0; } -[[maybe_unused]] static void dump_pro_proof_to_stderr(const pro_proof& proof) { +[[maybe_unused]] static void dump_pro_proof_to_stderr(const session_protocol_pro_proof& proof) { fprintf(stderr, "proof.version: %u\n", proof.version); fprintf(stderr, "proof.gen_index_hash: %s\n", oxenc::to_hex(proof.gen_index_hash.data).c_str()); fprintf(stderr, @@ -665,7 +665,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { scope_exit curl_headers_free{[&]() { curl_slist_free_all(curl_headers); }}; // Add pro payment - pro_proof first_pro_proof = {}; + session_protocol_pro_proof first_pro_proof = {}; { bytes32 fake_google_payment_token; randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); @@ -730,7 +730,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { INFO("Signature: " << oxenc::to_hex(first_pro_proof.sig.data) << ", backend pubkey: " << oxenc::to_hex(DEV_BACKEND_PUBKEY) << ", response: " << response_json); - REQUIRE(pro_proof_verify_signature( + REQUIRE(session_protocol_pro_proof_verify_signature( &first_pro_proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( response.proof.rotating_pubkey.data, @@ -787,8 +787,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); // Verify response - pro_proof proof = response.proof; - REQUIRE(pro_proof_verify_signature( + session_protocol_pro_proof proof = response.proof; + REQUIRE(session_protocol_pro_proof_verify_signature( &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( response.proof.rotating_pubkey.data, @@ -956,8 +956,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { }}; // Verify response - pro_proof proof = response.proof; - REQUIRE(pro_proof_verify_signature( + session_protocol_pro_proof proof = response.proof; + REQUIRE(session_protocol_pro_proof_verify_signature( &proof, DEV_BACKEND_PUBKEY.data(), DEV_BACKEND_PUBKEY.size())); REQUIRE(std::memcmp( response.proof.rotating_pubkey.data, diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 64d61c10..1c439ff1 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -8,7 +8,6 @@ #include #include "SessionProtos.pb.h" -#include "WebSocketResources.pb.h" #include "utils.hpp" using namespace session; @@ -27,7 +26,7 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se const array_uc64& user_rotating_privkey, const array_uc64& pro_backend_privkey, std::chrono::sys_seconds pro_expiry_unix_ts, - PRO_FEATURES features) { + SESSION_PROTOCOL_PRO_FEATURES features) { SerialisedProtobufContentWithProForTesting result = {}; // Create protobuf `Content.dataMessage` @@ -94,13 +93,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Ensure get pro fetaures detects large message") { // Try a message below the size threshold { - auto msg = std::string(PRO_STANDARD_CHARACTER_LIMIT, 'a'); + auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT, 'a'); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); REQUIRE(pro_msg.success); - REQUIRE(pro_msg.features == (PRO_FEATURES_PRO_BADGE | PRO_FEATURES_ANIMATED_AVATAR)); + REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); REQUIRE(pro_msg.codepoint_count == msg.size()); } @@ -108,31 +109,33 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { { std::string_view msg = "\xFF"; session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( - msg.data(), msg.size(), PRO_FEATURES_NIL); + msg.data(), msg.size(), SESSION_PROTOCOL_PRO_FEATURES_NIL); REQUIRE(!pro_msg.success); REQUIRE(pro_msg.error.size); } // Try a message exceeding the size threshold { - auto msg = std::string(PRO_STANDARD_CHARACTER_LIMIT + 1, 'a'); + auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT + 1, 'a'); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), - PRO_EXTRA_FEATURES_PRO_BADGE | PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); REQUIRE(pro_msg.success); - REQUIRE(pro_msg.features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE | - PRO_FEATURES_ANIMATED_AVATAR)); + REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); REQUIRE(pro_msg.codepoint_count == msg.size()); } // Try asking for just one extra feature { - auto msg = std::string(PRO_STANDARD_CHARACTER_LIMIT, 'a'); + auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT, 'a'); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( - msg.data(), msg.size(), PRO_EXTRA_FEATURES_PRO_BADGE); + msg.data(), msg.size(), SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE); REQUIRE(pro_msg.success); - REQUIRE(pro_msg.features == PRO_FEATURES_PRO_BADGE); + REQUIRE(pro_msg.features == SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); REQUIRE(pro_msg.codepoint_count == msg.size()); } } @@ -249,9 +252,11 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Verify pro ProProof nil_proof = {}; array_uc32 nil_hash = nil_proof.hash(); - bytes32 decrypt_result_pro_hash = pro_proof_hash(&decrypt_result.pro_proof); - REQUIRE(decrypt_result.pro_status == PRO_STATUS_NIL); // Pro was not attached - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); + bytes32 decrypt_result_pro_hash = + session_protocol_pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(decrypt_result.pro_status == + SESSION_PROTOCOL_PRO_STATUS_NIL); // Pro was not attached + REQUIRE(decrypt_result.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); REQUIRE(std::memcmp( decrypt_result_pro_hash.data, nil_hash.data(), @@ -284,7 +289,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { /*user_rotating_privkey*/ user_pro_ed_sk, /*pro_backend_privkey*/ pro_backend_ed_sk, /*pro_expiry_unix_ts*/ timestamp_s, - PRO_FEATURES_NIL); + SESSION_PROTOCOL_PRO_FEATURES_NIL); // Setup base destination object with the pro signature w/ Session pubkey 1 as the recipient bytes64 base_pro_sig = {}; @@ -302,17 +307,18 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Check non-encryptable messages produce only plaintext") { auto dest_list = { - DESTINATION_TYPE_COMMUNITY_INBOX, DESTINATION_TYPE_CONTACT_OR_SYNC_MESSAGE}; + SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX, + SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1}; for (auto dest_type : dest_list) { - if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) + if (dest_type == SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX) INFO("Trying community inbox"); else INFO("Trying contacts to non-default namespace"); session_protocol_destination dest = base_dest; dest.type = dest_type; - if (dest_type == DESTINATION_TYPE_COMMUNITY_INBOX) { + if (dest_type == SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX) { auto [blind15_pk, blind15_sk] = session::blind15_key_pair( keys.ed_sk1, keys.ed_pk1, /*blind factor*/ nullptr); dest.recipient_pubkey.data[0] = 0x15; @@ -368,13 +374,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro - REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached - bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(decrypt_result.pro_status == + SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached + bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( hash.data, protobuf_content_with_pro.pro_proof_hash.data(), sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + REQUIRE(decrypt_result.pro_features == + SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested // Verify the content can be parsed w/ protobufs SessionProtos::Content decrypt_content = {}; @@ -389,11 +397,14 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { std::string large_message; - large_message.resize(PRO_STANDARD_CHARACTER_LIMIT + 1); + large_message.resize(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT + 1); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( - large_message.data(), large_message.size(), PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(pro_msg.features == (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); + large_message.data(), + large_message.size(), + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE); + REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); SerialisedProtobufContentWithProForTesting protobuf_content_with_pro_and_features = build_protobuf_content_with_session_pro( @@ -435,14 +446,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro - REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached - bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(decrypt_result.pro_status == + SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached + bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( hash.data, protobuf_content_with_pro.pro_proof_hash.data(), sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == - (PRO_FEATURES_10K_CHARACTER_LIMIT | PRO_FEATURES_PRO_BADGE)); + REQUIRE(decrypt_result.pro_features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); // Verify the content can be parsed w/ protobufs SessionProtos::Content decrypt_content = {}; @@ -456,7 +468,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for legacy groups is rejected") { session_protocol_destination dest = base_dest; - dest.type = DESTINATION_TYPE_GROUP; + dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_GROUP; assert(dest.recipient_pubkey.data[0] == 0x05); session_protocol_encoded_for_destination encrypt_result = @@ -529,7 +541,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(error)); INFO("Decrypt for group error: " << error); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); + REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_encode_for_destination_free(&encrypt_result); @@ -569,13 +581,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); // Verify pro - REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); // Pro was attached - bytes32 hash = pro_proof_hash(&decrypt_result.pro_proof); + REQUIRE(decrypt_result.pro_status == + SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached + bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( hash.data, protobuf_content_with_pro.pro_proof_hash.data(), sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == PRO_FEATURES_NIL); // No features requested + REQUIRE(decrypt_result.pro_features == + SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested // Verify the content can be parsed w/ protobufs SessionProtos::Content decrypt_content = {}; @@ -599,7 +613,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == PRO_STATUS_EXPIRED); + REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_EXPIRED); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_decode_envelope_free(&decrypt_result); } @@ -618,7 +632,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_PRO_BACKEND_SIG); + REQUIRE(decrypt_result.pro_status == + SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_decode_envelope_free(&decrypt_result); } @@ -664,7 +679,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == PRO_STATUS_VALID); + REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_decode_envelope_free(&decrypt_result); } @@ -704,7 +719,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == PRO_STATUS_INVALID_USER_SIG); + REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_INVALID_USER_SIG); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); session_protocol_encode_for_destination_free(&encrypt_result); session_protocol_decode_envelope_free(&decrypt_result); From 391a42b78fe3d118fdf94c66c7ebd355805ea799 Mon Sep 17 00:00:00 2001 From: doylet Date: Sat, 27 Sep 2025 16:14:43 +1000 Subject: [PATCH 097/171] Encode/decode protocol messages now take the pro key and sign the message for you --- include/session/session_protocol.h | 44 ++++++----- include/session/session_protocol.hpp | 7 +- include/session/types.h | 2 +- src/pro_backend.cpp | 14 ++-- src/session_encrypt.cpp | 4 +- src/session_protocol.cpp | 107 +++++++++++++++++++-------- src/types.cpp | 2 +- tests/test_session_protocol.cpp | 82 ++++++-------------- 8 files changed, 139 insertions(+), 123 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index c1965aff..e0e605db 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -76,10 +76,8 @@ typedef enum SESSION_PROTOCOL_DESTINATION_TYPE { // See session::DestinationTyp typedef struct session_protocol_destination { // See session::Destination SESSION_PROTOCOL_DESTINATION_TYPE type; - - // The pro signature is optional, set the pointer to a 64 byte pro signature - // to include it into the encrypted message, ignored otherwise - const bytes64* pro_sig; + const void* pro_rotating_ed25519_privkey; + size_t pro_rotating_ed25519_privkey_len; bytes33 recipient_pubkey; uint64_t sent_timestamp_ms; bytes32 community_inbox_server_pubkey; @@ -310,10 +308,11 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( /// a 32-byte seed. Used to encrypt the plaintext. /// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). /// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. -/// - `recipient_pubkey` -- The recipient's Session public key (33 bytes). -/// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro -/// rotating public key, if using Session Pro features. If provided, the corresponding proof must -/// be set in the Content protobuf. Pass NULL if not using Session Pro features. +/// - `pro_rotating_ed25519_privkey` -- Optional rotating Session Pro Ed25519 key (64-bytes or +/// 32-byte seed) to sign the encoded content if you wish to entitle the message to Session Pro. +/// If provided, the corresponding proof must be set in the `Content`. The signature must not be +/// set in `Content`. +/// - `pro_rotating_ed25519_privkey_len` -- The length of the Session Pro Ed25519 key /// - `error` -- Pointer to the character buffer to be populated with the error message if the /// returned success was false, untouched otherwise. If this is set to NULL, then on failure, /// the returned error_len_incl_null_terminator is the number of bytes required by the user to @@ -344,7 +343,8 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* recipient_pubkey, - OPTIONAL const bytes64* pro_sig, + OPTIONAL const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, OPTIONAL char* error, size_t error_len) NON_NULL_ARG(1, 3, 6); @@ -369,10 +369,12 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( /// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. /// - `recipient_pubkey` -- The recipient's Session public key (33 bytes). /// - `community_pubkey` -- The community inbox server's public key (32 bytes). -/// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro -/// rotating public key, if using Session Pro features. If provided, the corresponding proof must -/// be set in the Content protobuf. Pass NULL if not using Session Pro features. TODO: Pro sig -/// is not incorporated into community/inbox messages yet. +/// - `pro_rotating_ed25519_privkey` -- Optional rotating Session Pro Ed25519 key (64-bytes or +/// 32-byte seed) to sign the encoded content if you wish to entitle the message to Session Pro. +/// If provided, the corresponding proof must be set in the `Content`. The signature must not be +/// set in `Content`. +/// - `pro_rotating_ed25519_privkey_len` -- The length of the Session Pro Ed25519 key +// TODO: Pro sig is not incorporated into community/inbox messages yet. /// - `error` -- Pointer to the character buffer to be populated with the error message if the /// returned success was false, untouched otherwise. If this is set to NULL, then on failure, /// the returned error_len_incl_null_terminator is the number of bytes required by the user to @@ -405,7 +407,8 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i uint64_t sent_timestamp_ms, const bytes33* recipient_pubkey, const bytes32* community_pubkey, - OPTIONAL const bytes64* pro_sig, + OPTIONAL const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, OPTIONAL char* error, size_t error_len) NON_NULL_ARG(1, 3, 6, 7); @@ -432,9 +435,11 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i /// - `group_ed25519_pubkey` -- The group's public key (33 bytes) for encryption with a 0x03 prefix. /// - `group_ed25519_privkey` -- The group's private key (32 bytes) for groups v2 messages, /// typically the latest encryption key for the group (e.g., Keys::group_enc_key). -/// - `pro_sig` -- Optional signature over the unencrypted plaintext with the user's Session Pro -/// rotating public key, if using Session Pro features. If provided, the corresponding proof must -/// be set in the Content protobuf. Pass NULL if not using Session Pro features. +/// - `pro_rotating_ed25519_privkey` -- Optional rotating Session Pro Ed25519 key (64-bytes or +/// 32-byte seed) to sign the encoded content if you wish to entitle the message to Session Pro. +/// If provided, the corresponding proof must be set in the `Content`. The signature must not be +/// set in `Content`. +/// - `pro_rotating_ed25519_privkey_len` -- The length of the Session Pro Ed25519 key /// - `error` -- Pointer to the character buffer to be populated with the error message if the /// returned success was false, untouched otherwise. If this is set to NULL, then on failure, /// the returned error_len_incl_null_terminator is the number of bytes required by the user to @@ -466,9 +471,10 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( uint64_t sent_timestamp_ms, const bytes33* group_ed25519_pubkey, const bytes32* group_ed25519_privkey, - const bytes64* pro_sig, + OPTIONAL const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, OPTIONAL char* error, - size_t error_len) NON_NULL_ARG(1, 3, 6, 7, 8); + size_t error_len) NON_NULL_ARG(1, 3, 6, 7); /// API: session_protocol/session_protocol_encrypt_for_destination /// diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 4a632fd1..cf5a17a6 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -187,11 +187,8 @@ enum class DestinationType { struct Destination { DestinationType type; - // Signature over the unencrypted plaintext with the user's Session Pro rotating public key if - // they have Session Pro and opt into sending a message with pro features. If this is specified, - // the pro message component in `Content` must have been set with the corresponding proof for - // this signature. - std::optional pro_sig; + // TODO: Update comment message + std::optional pro_rotating_ed25519_privkey; // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; diff --git a/include/session/types.h b/include/session/types.h index cf333794..a9923d20 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -72,7 +72,7 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size); /// _always_ calculates the actual number of bytes written (not including the null-terminator). If a /// NULL is passed in then this function returns the number of bytes actually needed to write the /// entire string (as per normal snprintf behaviour). -int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, ...); +int snprintf_clamped(char* buffer, size_t size, char const* fmt, ...); /// Allocate the string with the specific size. Throws on allocation failure. string8 string8_alloc_or_throw(size_t size); diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 1d97d43a..3200c79f 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -594,7 +594,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); - result.error_count = snprintf_bytes_written_clamped( + result.error_count = snprintf_clamped( result.error, sizeof(result.error_count), "%.*s", @@ -630,7 +630,7 @@ session_pro_backend_get_pro_proof_request_build_sigs( result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); - result.error_count = snprintf_bytes_written_clamped( + result.error_count = snprintf_clamped( result.error, sizeof(result.error_count), "%.*s", @@ -657,7 +657,7 @@ LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_statu result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); - result.error_count = snprintf_bytes_written_clamped( + result.error_count = snprintf_clamped( result.error, sizeof(result.error_count), "%.*s", @@ -965,20 +965,20 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE: { - dest.google_payment_token_count = snprintf_bytes_written_clamped( + dest.google_payment_token_count = snprintf_clamped( dest.google_payment_token, sizeof(dest.google_payment_token), src.google_payment_token.data()); } break; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { - dest.apple_original_tx_id_count = snprintf_bytes_written_clamped( + dest.apple_original_tx_id_count = snprintf_clamped( dest.apple_original_tx_id, sizeof(dest.apple_original_tx_id), src.apple_original_tx_id.data()); - dest.apple_tx_id_count = snprintf_bytes_written_clamped( + dest.apple_tx_id_count = snprintf_clamped( dest.apple_tx_id, sizeof(dest.apple_tx_id), src.apple_tx_id.data()); - dest.apple_web_line_order_id_count = snprintf_bytes_written_clamped( + dest.apple_web_line_order_id_count = snprintf_clamped( dest.apple_web_line_order_id, sizeof(dest.apple_web_line_order_id), src.apple_web_line_order_id.data()); diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index feb28a99..2317281c 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -1143,7 +1143,7 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( } catch (const std::exception& e) { std::string error_cpp = e.what(); result.error_len_incl_null_terminator = - snprintf_bytes_written_clamped( + snprintf_clamped( error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + 1; } @@ -1259,7 +1259,7 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess } catch (const std::exception& e) { std::string error_cpp = e.what(); result.error_len_incl_null_terminator = - snprintf_bytes_written_clamped( + snprintf_clamped( error, error_len, "%.*s", (int)error_cpp.size(), error_cpp.data()) + 1; } diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index df1c2857..06095549 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -184,10 +184,10 @@ std::vector encode_for_1o1( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, - const std::optional& pro_sig) { + const std::optional& pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::SyncOr1o1; - dest.pro_sig = pro_sig; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); @@ -200,10 +200,10 @@ std::vector encode_for_community_inbox( std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const array_uc32& community_pubkey, - const std::optional& pro_sig) { + const std::optional& pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::CommunityInbox; - dest.pro_sig = pro_sig; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; dest.community_inbox_server_pubkey = community_pubkey; @@ -217,10 +217,10 @@ std::vector encode_for_group( std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, const cleared_uc32& group_ed25519_privkey, - const std::optional& pro_sig) { + const std::optional& pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::Group; - dest.pro_sig = pro_sig; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; dest.sent_timestamp_ms = sent_timestamp; dest.group_ed25519_pubkey = group_ed25519_pubkey; dest.group_ed25519_privkey = group_ed25519_privkey; @@ -303,14 +303,15 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::span plaintext, std::span ed25519_privkey, DestinationType dest_type, - std::span dest_pro_sig, + std::span dest_pro_rotating_ed25519_privkey, std::span dest_recipient_pubkey, std::chrono::milliseconds dest_sent_timestamp_ms, std::span dest_community_inbox_server_pubkey, std::span dest_group_ed25519_pubkey, std::span dest_group_ed25519_privkey, UseMalloc use_malloc) { - assert(dest_pro_sig.empty() || dest_pro_sig.size() == crypto_sign_ed25519_BYTES); + assert(dest_pro_rotating_ed25519_privkey.empty() || + dest_pro_rotating_ed25519_privkey.size() == crypto_sign_ed25519_SECRETKEYBYTES); assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); @@ -368,14 +369,20 @@ static EncryptedForDestinationInternal encode_for_destination_internal( envelope.set_timestamp(dest_sent_timestamp_ms.count()); envelope.set_content(content.data(), content.size()); - if (dest_pro_sig.empty()) { - // If there's no pro signature specified, we still fill out the pro signature with a - // dummy 64 byte stream. This is to make pro and non-pro messages indistinguishable. - std::string* pro_sig = envelope.mutable_prosig(); - pro_sig->resize(sizeof(array_uc64)); + // Generate the session pro signature. If there's no pro ed25519 key specified, we still + // fill out the pro signature with a dummy 64 byte stream. This is to make pro and + // non-pro messages indistinguishable. + std::string* pro_sig = envelope.mutable_prosig(); + pro_sig->resize(crypto_sign_ed25519_BYTES); + if (dest_pro_rotating_ed25519_privkey.empty()) { randombytes_buf(pro_sig->data(), pro_sig->size()); } else { - envelope.set_prosig(dest_pro_sig.data(), dest_pro_sig.size()); + crypto_sign_ed25519_detached( + reinterpret_cast(pro_sig->data()), + nullptr, + content.data(), + content.size(), + dest_pro_rotating_ed25519_privkey.data()); } if (is_group) { @@ -447,7 +454,9 @@ std::vector encode_for_destination( /*plaintext=*/plaintext, /*ed25519_privkey=*/ed25519_privkey, /*dest_type=*/dest.type, - /*dest_pro_sig=*/dest.pro_sig ? *dest.pro_sig : std::span(), + /*dest_pro_rotating_ed25519_privkey=*/dest.pro_rotating_ed25519_privkey + ? *dest.pro_rotating_ed25519_privkey + : std::span(), /*dest_recipient_pubkey=*/dest.recipient_pubkey, /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, /*dest_community_inbox_server_pubkey=*/dest.community_inbox_server_pubkey, @@ -697,7 +706,13 @@ DecodedEnvelope decode_envelope( // was the message signed validly?) ProSignedMessage signed_msg = {}; signed_msg.sig = to_span(pro_sig); - signed_msg.msg = result.content_plaintext; + + // Note that we sign the envelope content wholesale. For 1o1 which are padded to 160 + // bytes, this means that we expected the user to have signed the padding as well. + signed_msg.msg = std::span( + reinterpret_cast(envelope.content().data()), + envelope.content().size()); + pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); } } @@ -1001,13 +1016,15 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* recipient_pubkey, - const bytes64* pro_sig, + const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, char* error, size_t error_len) { session_protocol_destination dest = {}; dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1; - dest.pro_sig = pro_sig; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey_len = pro_rotating_ed25519_privkey_len; dest.recipient_pubkey = *recipient_pubkey; dest.sent_timestamp_ms = sent_timestamp_ms; @@ -1031,13 +1048,15 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i uint64_t sent_timestamp_ms, const bytes33* recipient_pubkey, const bytes32* community_pubkey, - const bytes64* pro_sig, + const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, char* error, size_t error_len) { session_protocol_destination dest = {}; dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX; - dest.pro_sig = pro_sig; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey_len = pro_rotating_ed25519_privkey_len; dest.sent_timestamp_ms = sent_timestamp_ms; dest.recipient_pubkey = *recipient_pubkey; dest.community_inbox_server_pubkey = *community_pubkey; @@ -1062,13 +1081,15 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( uint64_t sent_timestamp_ms, const bytes33* group_ed25519_pubkey, const bytes32* group_ed25519_privkey, - const bytes64* pro_sig, + const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, char* error, size_t error_len) { session_protocol_destination dest = {}; dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_GROUP; - dest.pro_sig = pro_sig; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey_len = pro_rotating_ed25519_privkey_len; dest.group_ed25519_pubkey = *group_ed25519_pubkey; dest.group_ed25519_privkey = *group_ed25519_privkey; dest.sent_timestamp_ms = sent_timestamp_ms; @@ -1092,14 +1113,42 @@ LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encod const session_protocol_destination* dest, char* error, size_t error_len) { + session_protocol_encoded_for_destination result = {}; + + // Ensure the Session Pro rotating key is a 64 byte key if given + std::span pro_rotating_ed25519_privkey_span = {}; + cleared_uc64 pro_rotating_ed25519_privkey; + if (dest->pro_rotating_ed25519_privkey) { + if (dest->pro_rotating_ed25519_privkey_len == 32) { + uc32 ignore_pk; + crypto_sign_ed25519_seed_keypair( + ignore_pk.data(), + pro_rotating_ed25519_privkey.data(), + reinterpret_cast(dest->pro_rotating_ed25519_privkey)); + pro_rotating_ed25519_privkey_span = { + pro_rotating_ed25519_privkey.data(), pro_rotating_ed25519_privkey.size()}; + } else if (dest->pro_rotating_ed25519_privkey_len == 64) { + pro_rotating_ed25519_privkey_span = std::span( + reinterpret_cast(dest->pro_rotating_ed25519_privkey), + reinterpret_cast(dest->pro_rotating_ed25519_privkey) + + dest->pro_rotating_ed25519_privkey_len); + } else { + result.error_len_incl_null_terminator = + snprintf_clamped( + error, error_len, "Invalid ed25519_privkey: expected 32 or 64 bytes") + + 1; + return result; + } + } + try { EncryptedForDestinationInternal result_internal = encode_for_destination_internal( /*plaintext=*/{static_cast(plaintext), plaintext_len}, /*ed25519_privkey=*/ {static_cast(ed25519_privkey), ed25519_privkey_len}, /*dest_type=*/static_cast(dest->type), - /*dest_pro_sig=*/dest->pro_sig ? dest->pro_sig->data : std::span(), + /*dest_pro_rotating_ed25519_privkey=*/pro_rotating_ed25519_privkey_span, /*dest_recipient_pubkey=*/dest->recipient_pubkey.data, /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), /*dest_community_inbox_server_pubkey=*/dest->community_inbox_server_pubkey.data, @@ -1113,7 +1162,7 @@ LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encod }; } catch (const std::exception& e) { std::string error_cpp = e.what(); - result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( + result.error_len_incl_null_terminator = snprintf_clamped( error, error_len, "%.*s", @@ -1149,7 +1198,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( array_uc32 pro_backend_pubkey_cpp = {}; if (pro_backend_pubkey) { if (pro_backend_pubkey_len != sizeof(pro_backend_pubkey_cpp)) { - result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( + result.error_len_incl_null_terminator = snprintf_clamped( error, error_len, "Invalid pro_backend_pubkey: Key was " @@ -1183,7 +1232,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( break; } catch (const std::exception& e) { std::string error_cpp = e.what(); - result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( + result.error_len_incl_null_terminator = snprintf_clamped( error, error_len, "%.*s", @@ -1195,9 +1244,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( if (keys->ed25519_privkeys_len == 0) { result.error_len_incl_null_terminator = - snprintf_bytes_written_clamped( - error, error_len, "No keys ed25519_privkeys were provided") + - 1; + snprintf_clamped(error, error_len, "No keys ed25519_privkeys were provided") + 1; } // Marshall into c type @@ -1207,7 +1254,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( } catch (const std::exception& e) { std::string error_cpp = e.what(); result.success = false; - result.error_len_incl_null_terminator = snprintf_bytes_written_clamped( + result.error_len_incl_null_terminator = snprintf_clamped( error, error_len, "%.*s", diff --git a/src/types.cpp b/src/types.cpp index ea1f2bad..6032a74f 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -19,7 +19,7 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size) { return result; } -int snprintf_bytes_written_clamped(char* buffer, size_t size, char const* fmt, ...) { +int snprintf_clamped(char* buffer, size_t size, char const* fmt, ...) { va_list args; va_start(args, fmt); int bytes_required_not_incl_null = vsnprintf(buffer, size, fmt, args); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 1c439ff1..9a15a90f 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -150,6 +150,15 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { std::chrono::duration_cast(timestamp_ms)); const std::string_view data_body = "hello"; + // Generate the user's Session Pro rotating key for testing encrypted payloads with Session + // Pro metadata + const auto user_pro_seed = + "0123456789abcdef0123456789abcdeff00baa00000000000000000000000000"_hexbytes; + array_uc32 user_pro_ed_pk; + array_uc64 user_pro_ed_sk; + crypto_sign_ed25519_seed_keypair( + user_pro_ed_pk.data(), user_pro_ed_sk.data(), user_pro_seed.data()); + SECTION("Encrypt with and w/o pro sig produce same payload size") { // Same payload size because the encrypt function should put in a dummy signature if one // wasn't specific to make pro and non-pro envelopes indistinguishable. @@ -167,13 +176,13 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { timestamp_ms.count(), &recipient_pubkey, nullptr, + 0, error, sizeof(error)); INFO(error); REQUIRE(encrypt_without_pro_sig.error_len_incl_null_terminator == 0); // Set the pro signature - bytes64 pro_sig = {}; session_protocol_encoded_for_destination encrypt_with_pro_sig = session_protocol_encode_for_1o1( data_body.data(), @@ -182,7 +191,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.size(), timestamp_ms.count(), &recipient_pubkey, - &pro_sig, + keys.ed_sk0.data(), // Use random key, doesn't matter, we're checking size + keys.ed_sk0.size(), error, sizeof(error)); REQUIRE(encrypt_with_pro_sig.error_len_incl_null_terminator == 0); @@ -214,10 +224,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Encrypt session_protocol_encoded_for_destination encrypt_result = {}; { - bytes64* pro_sig = nullptr; bytes33 recipient_pubkey = {}; std::memcpy(recipient_pubkey.data, keys.session_pk1.data(), keys.session_pk1.size()); - encrypt_result = session_protocol_encode_for_1o1( plaintext.data(), plaintext.size(), @@ -225,7 +233,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.size(), timestamp_ms.count(), &recipient_pubkey, - pro_sig, + nullptr, + 0, error, sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); @@ -272,15 +281,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_decode_envelope_free(&decrypt_result); } - // Generate the user's Session Pro rotating key for testing encrypted payloads with Session - // Pro metadata - const auto user_pro_seed = - "0123456789abcdef0123456789abcdeff00baa00000000000000000000000000"_hexbytes; - array_uc32 user_pro_ed_pk; - array_uc64 user_pro_ed_sk; - crypto_sign_ed25519_seed_keypair( - user_pro_ed_pk.data(), user_pro_ed_sk.data(), user_pro_seed.data()); - // Build protobuf `Content` message, serialise to `plaintext` and get it signed by the user's // "Session Pro" key into `sig_over_plaintext_with_user_pro_key` SerialisedProtobufContentWithProForTesting protobuf_content_with_pro = @@ -300,7 +300,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_destination base_dest = {}; base_dest.sent_timestamp_ms = timestamp_ms.count(); - base_dest.pro_sig = &base_pro_sig; + base_dest.pro_rotating_ed25519_privkey = user_pro_ed_sk.data(); + base_dest.pro_rotating_ed25519_privkey_len = user_pro_ed_sk.size(); REQUIRE(sizeof(base_dest.recipient_pubkey.data) == keys.session_pk1.size()); std::memcpy(base_dest.recipient_pubkey.data, keys.session_pk1.data(), keys.session_pk1.size()); @@ -350,7 +351,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.size(), base_dest.sent_timestamp_ms, &base_dest.recipient_pubkey, - base_dest.pro_sig, + user_pro_ed_sk.data(), + user_pro_ed_sk.size(), error, sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); @@ -422,7 +424,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.size(), base_dest.sent_timestamp_ms, &base_dest.recipient_pubkey, - &protobuf_content_with_pro_and_features.sig_over_plaintext_with_user_pro_key_c, + user_pro_ed_sk.data(), + user_pro_ed_sk.size(), error, sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); @@ -513,7 +516,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { base_dest.sent_timestamp_ms, &group_v2_session_pk, &group_v2_session_sk, - base_dest.pro_sig, + user_pro_ed_sk.data(), + user_pro_ed_sk.size(), error, sizeof(error)); INFO("Encrypt for group error: " << error); @@ -557,7 +561,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { keys.ed_sk0.size(), base_dest.sent_timestamp_ms, &base_dest.recipient_pubkey, - base_dest.pro_sig, + user_pro_ed_sk.data(), + user_pro_ed_sk.size(), error, sizeof(error)); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); @@ -686,45 +691,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encode_for_destination_free(&encrypt_result); } - SECTION("Encrypt/decrypt for sync messages with Pro and bad rotating signature") { - session_protocol_encoded_for_destination encrypt_result = {}; - { - bytes64 pro_sig = base_pro_sig; - pro_sig.data[0] ^= 1; // Break the sig by flipping a bit - - encrypt_result = session_protocol_encode_for_1o1( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), - keys.ed_sk0.data(), - keys.ed_sk0.size(), - base_dest.sent_timestamp_ms, - &base_dest.recipient_pubkey, - &pro_sig, - error, - sizeof(error)); - REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - } - - span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; - session_protocol_decode_envelope_keys decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; - session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( - &decrypt_keys, - encrypt_result.ciphertext.data, - encrypt_result.ciphertext.size, - timestamp_s.time_since_epoch().count(), - pro_backend_ed_pk.data(), - pro_backend_ed_pk.size(), - error, - sizeof(error)); - REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_INVALID_USER_SIG); - REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); - session_protocol_encode_for_destination_free(&encrypt_result); - session_protocol_decode_envelope_free(&decrypt_result); - } - SECTION("Encode/decode for community (content message)") { std::vector encoded = encode_for_community(to_span(protobuf_content_with_pro.plaintext), {}); From 55749856d85b9348f775c82e70796b0469e8eb63 Mon Sep 17 00:00:00 2001 From: doylet Date: Sat, 27 Sep 2025 18:57:01 +1000 Subject: [PATCH 098/171] Merge community encoding to single function, support inbox messages --- include/session/session_protocol.h | 3 + include/session/session_protocol.hpp | 70 +++--- src/session_protocol.cpp | 343 +++++++++++++++------------ tests/test_session_protocol.cpp | 66 ++++-- 4 files changed, 271 insertions(+), 211 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index e0e605db..e646741b 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -22,6 +22,8 @@ enum { /// This is not used in the codebase, but is provided for convenience to centralise protocol /// definitions for users of the library to consume. SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT = 10'000, + + SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING = 160, }; typedef enum SESSION_PROTOCOL_PRO_STATUS { // See session::ProStatus @@ -72,6 +74,7 @@ typedef enum SESSION_PROTOCOL_DESTINATION_TYPE { // See session::DestinationTyp SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1, SESSION_PROTOCOL_DESTINATION_TYPE_GROUP, SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX, + SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY, } SESSION_PROTOCOL_DESTINATION_TYPE; typedef struct session_protocol_destination { // See session::Destination diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index cf5a17a6..63801c2a 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -182,13 +182,16 @@ enum class DestinationType { /// Destination. Group = SESSION_PROTOCOL_DESTINATION_TYPE_GROUP, CommunityInbox = SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY_INBOX, + Community = SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY, }; struct Destination { DestinationType type; - // TODO: Update comment message - std::optional pro_rotating_ed25519_privkey; + // Optional rotating Session Pro Ed25519 private key to sign the message with on behalf of the + // caller. The Session Pro signature must _not_ be set in the plaintext content passed into the + // encoding function. + std::span pro_rotating_ed25519_privkey; // The timestamp to assign to the message envelope std::chrono::milliseconds sent_timestamp_ms; @@ -262,9 +265,13 @@ struct DecodedCommunityMessage { // kind of blob on the wire during that period. std::optional envelope; - // Content blob + // The protobuf encoded `Content` including padding. std::vector content_plaintext; + // The size of the payload from [content_plaintext.data(), content_plaintext_unpadded_size) that + // contains the protobuf encoded `Content` without padding. + size_t content_plaintext_unpadded_size; + // The signature if it was present in the payload. If the envelope is set and the envelope has // the pro signature flag set, then this signature was extracted from the envelope. When the // signature is sourced from the envelope, the envelope's `pro_sig` field is also set to the @@ -345,6 +352,12 @@ ProFeaturesForMsg pro_features_for_utf8( ProFeaturesForMsg pro_features_for_utf16( char16_t const* utf16, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); +/// API: session_protocol/pad_message +/// +/// Pad a message to the required alignment for 1o1/community messages (160 bytes) including space +/// for the padding-terminating byte. +std::vector pad_message(std::span payload); + /// API: session_protocol/encode_for_1o1 /// /// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session @@ -399,7 +412,6 @@ std::vector encode_for_1o1( /// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro /// rotating public key, if using Session Pro features. If provided, the corresponding proof must /// be set in the Content protobuf. -/// TODO: Pro sig is not incorporated into community/inbox messages yet /// /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire @@ -410,7 +422,30 @@ std::vector encode_for_community_inbox( std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const array_uc32& community_pubkey, - const std::optional& pro_sig); + std::span pro_rotating_ed25519_privkey); + +/// API: session_protocol/encode_for_community +/// +/// Encrypt a plaintext `Content` message for a community for the Session Protocol. This function +/// encodes Session Pro metadata including generating and embedding the Session Pro signature, when +/// given a Session Pro rotating Ed25519 key into the final payload suitable for transmission on the +/// wire. +/// +/// This function throws if any input argument is invalid (e.g., incorrect key sizes). It also +/// throws if the pro signature is already set in the plaintext `Content` or the `plaintext` cannot +/// be interpreted as a `Content` message. +/// +/// Inputs: +/// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - pro_rotating_ed25519_privkey -- The sender's Session Pro rotating libsodium-style secret key +/// (64 bytes). Can also be passed as a 32-byte seed. Used to sign the payload. +/// +/// Outputs: +/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire +/// (i.e: it has been protobuf encoded/wrapped if necessary). +std::vector encode_for_community( + std::span plaintext, std::span pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_group /// @@ -446,30 +481,7 @@ std::vector encode_for_group( std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, const cleared_uc32& group_ed25519_privkey, - const std::optional& pro_sig); - -/// API: session_protocol/encode_for_community -/// -/// Encrypt a plaintext `Content` message for a community for the Session Protocol. This function -/// encodes Session Pro metadata including generating and embedding the Session Pro signature, when -/// given a Session Pro rotating Ed25519 key into the final payload suitable for transmission on the -/// wire. -/// -/// This function throws if any input argument is invalid (e.g., incorrect key sizes). It also -/// throws if the pro signature is already set in the plaintext `Content` or the `plaintext` cannot -/// be interpreted as a `Content` message. -/// -/// Inputs: -/// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must -/// not be already encrypted. -/// - pro_rotating_ed25519_privkey -- The sender's Session Pro rotating libsodium-style secret key -/// (64 bytes). Can also be passed as a 32-byte seed. Used to sign the payload. -/// -/// Outputs: -/// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire -/// (i.e: it has been protobuf encoded/wrapped if necessary). -std::vector encode_for_community( - std::span plaintext, std::span pro_rotating_ed25519_privkey); + std::span pro_rotating_ed25519_privkey); /// API: session_protocol/encrypt_for_destination /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 06095549..2903418f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -184,7 +184,7 @@ std::vector encode_for_1o1( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, - const std::optional& pro_rotating_ed25519_privkey) { + std::span pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::SyncOr1o1; dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; @@ -200,7 +200,7 @@ std::vector encode_for_community_inbox( std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const array_uc32& community_pubkey, - const std::optional& pro_rotating_ed25519_privkey) { + std::span pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::CommunityInbox; dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; @@ -211,13 +211,23 @@ std::vector encode_for_community_inbox( return result; } +std::vector encode_for_community( + std::span plaintext, std::span pro_rotating_ed25519_privkey) { + Destination dest = {}; + dest.type = DestinationType::Community; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + std::span nil_ed25519_privkey; + std::vector result = encode_for_destination(plaintext, nil_ed25519_privkey, dest); + return result; +} + std::vector encode_for_group( std::span plaintext, std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, const cleared_uc32& group_ed25519_privkey, - const std::optional& pro_rotating_ed25519_privkey) { + std::span pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::Group; dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; @@ -228,63 +238,6 @@ std::vector encode_for_group( return result; } -std::vector encode_for_community( - std::span plaintext, std::span pro_rotating_ed25519_privkey) { - // TODO: In future once platforms adopt this function, then we can change to sending an envelope - // and all platforms will uniformly agree on this convention. For backwards compat, the decode - // for community function will continue to try and parse `Content` and `Envelope` for messages - // sent to the community. - std::vector result; - if (pro_rotating_ed25519_privkey.size()) { - if (pro_rotating_ed25519_privkey.size() != 32 && pro_rotating_ed25519_privkey.size() != 64) - throw std::invalid_argument{ - "Invalid pro_rotating_ed25519_privkey: expected 32 or 64 bytes"}; - - // TODO: Sub-optimal, but we parse the content again to make sure it's valid. Sign the blob - // then, fill in the signature in-place as part of the transitioning of open groups messages - // to envelopes. As part of that, libsession is going to take responsibility of constructing - // community messages so that eventually all platforms switch over and we can change the - // implementation across all platforms in one swoop. - // - // Parse the content blob - SessionProtos::Content content = {}; - if (!content.ParseFromArray(plaintext.data(), plaintext.size())) - throw std::runtime_error{"Parsing community message failed"}; - - if (content.has_prosigforcommunitymessageonly()) - throw std::runtime_error{ - "Pro signature for community message must not be set. Libsession's responsible " - "for generating the signature and setting it"}; - - // Generate and assign the pro signature - array_uc64 pro_sig; - crypto_sign_ed25519_detached( - pro_sig.data(), - nullptr, - plaintext.data(), - plaintext.size(), - pro_rotating_ed25519_privkey.data()); - content.set_prosigforcommunitymessageonly(pro_sig.data(), pro_sig.size()); - - // Reserialize the content to return to the user - result.resize(content.ByteSizeLong()); - bool serialized = content.SerializeToArray(result.data(), result.size()); - assert(serialized); - } else { - // TODO: Very wasteful copy, but it's done to simplify the caller's interface. This is - // temporary until we transition away from plain content messages being sent for community - // messages. At that point, we should abstract away constructing content messages into - // libsession. - // - // Then the caller would just pass in the components, libsession constructs the payload to - // send on the wire. None of this back and forth situation we have here where they - // don't pass in a pro key with an already serialised `plaintext` (e.g. a no-op). - result = std::vector(plaintext.begin(), plaintext.end()); - } - - return result; -} - // Interop between the C and CPP API. The C api will request malloc which writes to `ciphertext_c`. // This pointer is taken verbatim and avoids requiring a copy from the CPP vector. The CPP api will // steal the contents from `ciphertext_cpp`. @@ -294,9 +247,45 @@ struct EncryptedForDestinationInternal { }; constexpr char PADDING_TERMINATING_BYTE = 0x80; +std::vector pad_message(std::span payload) { -// TODO: Implement pro signing on behalf of the clients by getting them to pass in the pro rotating -// secret key + // Calculate amount of padding required + size_t padded_content_size = payload.size() + 1 /*padding byte*/; + uint8_t const bytes_for_padding = + SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING - + (padded_content_size % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING); + padded_content_size += bytes_for_padding; + assert(padded_content_size % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); + + // Do the padding + std::vector result; + result.resize(padded_content_size); + std::memcpy(result.data(), payload.data(), payload.size()); + result[payload.size()] = PADDING_TERMINATING_BYTE; + return result; +} + +static std::span unpad_message(std::span payload) { + // Strip padding from content + size_t size_without_padding = payload.size(); + while (size_without_padding) { + char ch = payload[size_without_padding - 1]; + if (ch != 0 && ch != PADDING_TERMINATING_BYTE) { + // Non-zero padding encountered, terminate the loop and assume message is not + // padded + // TODO: We should enforce this but no client enforces it right now. + break; + } + + size_without_padding--; + if (ch == PADDING_TERMINATING_BYTE) + break; + } + + assert(size_without_padding <= payload.size()); + auto result = std::span(payload.data(), payload.data() + size_without_padding); + return result; +} enum class UseMalloc { No, Yes }; static EncryptedForDestinationInternal encode_for_destination_internal( @@ -310,21 +299,46 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::span dest_group_ed25519_pubkey, std::span dest_group_ed25519_privkey, UseMalloc use_malloc) { - assert(dest_pro_rotating_ed25519_privkey.empty() || - dest_pro_rotating_ed25519_privkey.size() == crypto_sign_ed25519_SECRETKEYBYTES); + // The following arguments are passed in from structs with fixed-sized arrays so we expect the + // sizes to be correct. It being wrong would be a development error + // + // The ed25519_privkey is passed into the lower level layer, session encrypt which has its own + // private key normalisation to 64 bytes for us. assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_privkey.size() == 32 || dest_group_ed25519_privkey.size() == 64); - // All incoming arguments are passed in from typed, fixed-sized arrays so we do not need to - // throw if these sizes are wrong. It being wrong would be a development error. + // Ensure the Session Pro rotating key is a 64 byte key if given + cleared_uc64 pro_ed_sk_from_seed; + if (dest_pro_rotating_ed25519_privkey.size()) { + if (dest_pro_rotating_ed25519_privkey.size() == 32) { + uc32 ignore_pk; + crypto_sign_ed25519_seed_keypair( + ignore_pk.data(), + pro_ed_sk_from_seed.data(), + dest_pro_rotating_ed25519_privkey.data()); + dest_pro_rotating_ed25519_privkey = to_span(pro_ed_sk_from_seed); + } else if (dest_pro_rotating_ed25519_privkey.size() == 64) { + dest_pro_rotating_ed25519_privkey = to_span(dest_pro_rotating_ed25519_privkey); + } else { + throw std::runtime_error{fmt::format( + "Invalid dest_pro_rotating_ed25519_privkey: expected 32 or 64 bytes, received " + "{}", + dest_pro_rotating_ed25519_privkey.size())}; + } + } + + bool is_group = dest_type == DestinationType::Group; + bool is_1o1 = dest_type == DestinationType::SyncOr1o1; + bool is_community_inbox = dest_type == DestinationType::CommunityInbox; + bool is_community = dest_type == DestinationType::Community; + std::span content = plaintext; + EncryptedForDestinationInternal result = {}; switch (dest_type) { case DestinationType::Group: /*FALLTHRU*/ case DestinationType::SyncOr1o1: { - bool is_group = dest_type == DestinationType::Group; - bool is_1o1 = dest_type == DestinationType::SyncOr1o1; if (is_group && dest_group_ed25519_pubkey[0] != static_cast(SessionIDPrefix::group)) { // Legacy groups which have a 05 prefixed key @@ -335,27 +349,12 @@ static EncryptedForDestinationInternal encode_for_destination_internal( // For Sync or 1o1 mesasges, we need to pad the contents to 160 bytes, see: // https://github.com/session-foundation/session-desktop/blob/a04e62427034a6b6fee39dcff7dbabf0d0131b13/ts/session/crypto/BufferPadding.ts#L49 - std::span content = plaintext; - std::vector content_for_1o1; - if (is_1o1) { - const size_t MSG_PADDING = 160; - - // Calculate amount of padding required - size_t padded_content_size = content.size() + 1 /*padding byte*/; - uint8_t const bytes_for_padding = MSG_PADDING - (padded_content_size % MSG_PADDING); - padded_content_size += bytes_for_padding; - assert(padded_content_size % MSG_PADDING == 0); - - // Do the padding - std::vector padded_content; - padded_content.resize(padded_content_size); - std::memcpy(padded_content.data(), content.data(), content.size()); - padded_content[content.size()] = PADDING_TERMINATING_BYTE; - - // Encrypt the padded output - content_for_1o1 = encrypt_for_recipient_deterministic( - ed25519_privkey, dest_recipient_pubkey, padded_content); - content = content_for_1o1; + std::vector tmp_content_buffer; + if (is_1o1) { // Encrypt the padded output + std::vector padded_payload = pad_message(content); + tmp_content_buffer = encrypt_for_recipient_deterministic( + ed25519_privkey, dest_recipient_pubkey, padded_payload); + content = tmp_content_buffer; } // Create envelope @@ -428,17 +427,85 @@ static EncryptedForDestinationInternal encode_for_destination_internal( } } break; + case DestinationType::Community: /*FALLTHRU*/ case DestinationType::CommunityInbox: { - std::vector ciphertext = encrypt_for_blinded_recipient( - ed25519_privkey, - dest_community_inbox_server_pubkey, - dest_recipient_pubkey, // recipient blinded pubkey - plaintext); - - if (use_malloc == UseMalloc::Yes) { - result.ciphertext_c = span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + // Setup the pro signature for the community message + std::vector tmp_content_buffer; + + // Sign the message with the Session Pro key if given and then pad the message (both + // community message types require it) + // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L398 + if (dest_pro_rotating_ed25519_privkey.size()) { + // Key should be verified by the time we hit this branch + assert(dest_pro_rotating_ed25519_privkey.size() == crypto_sign_ed25519_SECRETKEYBYTES); + + // TODO: Sub-optimal, but we parse the content again to make sure it's valid. Sign + // the blob then, fill in the signature in-place as part of the transitioning of + // open groups messages to envelopes. As part of that, libsession is going to take + // responsibility of constructing community messages so that eventually all + // platforms switch over to envelopes and we can change the implementation across + // all platforms in one swoop and remove this. + // + // Parse the content blob + SessionProtos::Content content_w_sig = {}; + if (!content_w_sig.ParseFromArray(content.data(), content.size())) + throw std::runtime_error{"Parsing community message failed"}; + + if (content_w_sig.has_prosigforcommunitymessageonly()) + throw std::runtime_error{ + "Pro signature for community message must not be set. Libsession's " + "responsible for generating the signature and setting it"}; + + // We need to sign the padded content, so we pad the `Content` then sign it + tmp_content_buffer = pad_message(content); + array_uc64 pro_sig; + bool was_signed = crypto_sign_ed25519_detached( + pro_sig.data(), + nullptr, + tmp_content_buffer.data(), + tmp_content_buffer.size(), + dest_pro_rotating_ed25519_privkey.data()) == 0; + assert(was_signed); + + // Now assign the community specific pro signature field, reserialize it and we have + // to, yes, pad it again. This is all temporary wasted work whilst transitioning + // open groups. + content_w_sig.set_prosigforcommunitymessageonly(pro_sig.data(), pro_sig.size()); + tmp_content_buffer.resize(content_w_sig.ByteSizeLong()); + bool serialized = content_w_sig.SerializeToArray( + tmp_content_buffer.data(), tmp_content_buffer.size()); + assert(serialized); + + tmp_content_buffer = pad_message(tmp_content_buffer); + content = tmp_content_buffer; } else { - result.ciphertext_cpp = std::move(ciphertext); + tmp_content_buffer = pad_message(to_span(content)); + content = tmp_content_buffer; + } + + // TODO: We don't need to actually pad the community message since that's unencrypted, + // there's no need to make the message sizes uniform but we need it for backwards + // compat. We can remove this eventually, first step is to unify the clients. + + if (is_community_inbox) { + std::vector ciphertext = encrypt_for_blinded_recipient( + ed25519_privkey, + dest_community_inbox_server_pubkey, + dest_recipient_pubkey, // recipient blinded pubkey + content); + + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = + span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + } else { + result.ciphertext_cpp = std::move(ciphertext); + } + } else { + if (use_malloc == UseMalloc::Yes) { + result.ciphertext_c = span_u8_copy_or_throw(content.data(), content.size()); + } else { + result.ciphertext_cpp = std::vector(content.begin(), content.end()); + } } } break; } @@ -454,9 +521,7 @@ std::vector encode_for_destination( /*plaintext=*/plaintext, /*ed25519_privkey=*/ed25519_privkey, /*dest_type=*/dest.type, - /*dest_pro_rotating_ed25519_privkey=*/dest.pro_rotating_ed25519_privkey - ? *dest.pro_rotating_ed25519_privkey - : std::span(), + /*dest_pro_rotating_ed25519_privkey=*/dest.pro_rotating_ed25519_privkey, /*dest_recipient_pubkey=*/dest.recipient_pubkey, /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, /*dest_community_inbox_server_pubkey=*/dest.community_inbox_server_pubkey, @@ -594,25 +659,8 @@ DecodedEnvelope decode_envelope( } // Strip padding from content - { - size_t size_without_padding = content_plaintext.size(); - while (size_without_padding) { - char ch = content_plaintext[size_without_padding - 1]; - if (ch != 0 && ch != PADDING_TERMINATING_BYTE) { - // Non-zero padding encountered, terminate the loop and assume message is not - // padded - // TODO: We should enforce this but no client enforces it right now. - break; - } - - size_without_padding--; - if (ch == PADDING_TERMINATING_BYTE) - break; - } - - assert(size_without_padding <= content_plaintext.size()); - content_plaintext.resize(size_without_padding); - } + std::span unpadded_content = unpad_message(content_plaintext); + content_plaintext.resize(unpadded_content.size()); result.content_plaintext = std::move(content_plaintext); std::memcpy( @@ -709,10 +757,7 @@ DecodedEnvelope decode_envelope( // Note that we sign the envelope content wholesale. For 1o1 which are padded to 160 // bytes, this means that we expected the user to have signed the padding as well. - signed_msg.msg = std::span( - reinterpret_cast(envelope.content().data()), - envelope.content().size()); - + signed_msg.msg = to_span(envelope.content()); pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); } } @@ -787,11 +832,14 @@ DecodedCommunityMessage decode_for_community( result.content_plaintext = std::vector( content_or_envelope_payload.begin(), content_or_envelope_payload.end()); } + + // Get the unpadded size of the content + result.content_plaintext_unpadded_size = unpad_message(result.content_plaintext).size(); } // Parse the content blob SessionProtos::Content content = {}; - if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext.size())) + if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext_unpadded_size)) throw std::runtime_error{ "Decoding community message failed, could not interpret blob as content or " "envelope"}; @@ -887,9 +935,9 @@ DecodedCommunityMessage decode_for_community( content_copy_without_sig.clear_prosigforcommunitymessageonly(); assert(!content_copy_without_sig.has_prosigforcommunitymessageonly()); - // Reserialise the payload without the signature - std::string content_copy_without_sig_payload = - content_copy_without_sig.SerializeAsString(); + // Reserialise the payload without the signature, repad it then verify the signature + std::vector content_copy_without_sig_payload = + pad_message(to_span(content_copy_without_sig.SerializeAsString())); signed_msg.msg = to_span(content_copy_without_sig_payload); pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); @@ -1116,42 +1164,23 @@ LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encod session_protocol_encoded_for_destination result = {}; - // Ensure the Session Pro rotating key is a 64 byte key if given - std::span pro_rotating_ed25519_privkey_span = {}; - cleared_uc64 pro_rotating_ed25519_privkey; - if (dest->pro_rotating_ed25519_privkey) { - if (dest->pro_rotating_ed25519_privkey_len == 32) { - uc32 ignore_pk; - crypto_sign_ed25519_seed_keypair( - ignore_pk.data(), - pro_rotating_ed25519_privkey.data(), - reinterpret_cast(dest->pro_rotating_ed25519_privkey)); - pro_rotating_ed25519_privkey_span = { - pro_rotating_ed25519_privkey.data(), pro_rotating_ed25519_privkey.size()}; - } else if (dest->pro_rotating_ed25519_privkey_len == 64) { - pro_rotating_ed25519_privkey_span = std::span( - reinterpret_cast(dest->pro_rotating_ed25519_privkey), - reinterpret_cast(dest->pro_rotating_ed25519_privkey) + - dest->pro_rotating_ed25519_privkey_len); - } else { - result.error_len_incl_null_terminator = - snprintf_clamped( - error, error_len, "Invalid ed25519_privkey: expected 32 or 64 bytes") + - 1; - return result; - } - } - try { + std::span dest_pro_rotating_ed25519_privkey = std::span( + reinterpret_cast(dest->pro_rotating_ed25519_privkey), + reinterpret_cast(dest->pro_rotating_ed25519_privkey) + + dest->pro_rotating_ed25519_privkey_len); + EncryptedForDestinationInternal result_internal = encode_for_destination_internal( /*plaintext=*/{static_cast(plaintext), plaintext_len}, /*ed25519_privkey=*/ {static_cast(ed25519_privkey), ed25519_privkey_len}, /*dest_type=*/static_cast(dest->type), - /*dest_pro_rotating_ed25519_privkey=*/pro_rotating_ed25519_privkey_span, + /*dest_pro_rotating_ed25519_privkey=*/dest_pro_rotating_ed25519_privkey, /*dest_recipient_pubkey=*/dest->recipient_pubkey.data, - /*dest_sent_timestamp_ms=*/std::chrono::milliseconds(dest->sent_timestamp_ms), - /*dest_community_inbox_server_pubkey=*/dest->community_inbox_server_pubkey.data, + /*dest_sent_timestamp_ms=*/ + std::chrono::milliseconds(dest->sent_timestamp_ms), + /*dest_community_inbox_server_pubkey=*/ + dest->community_inbox_server_pubkey.data, /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey.data, /*dest_group_ed25519_privkey=*/dest->group_ed25519_privkey.data, /*use_malloc=*/UseMalloc::Yes); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 9a15a90f..3e907fe5 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -15,7 +15,9 @@ using namespace session; struct SerialisedProtobufContentWithProForTesting { ProProof proof; std::string plaintext; + std::vector plaintext_padded; array_uc64 sig_over_plaintext_with_user_pro_key; + array_uc64 sig_over_plaintext_padded_with_user_pro_key; array_uc32 pro_proof_hash; bytes64 sig_over_plaintext_with_user_pro_key_c; bytes32 pro_proof_hash_c; @@ -65,7 +67,9 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se // Generate the plaintext result.plaintext = content.SerializeAsString(); + result.plaintext_padded = session::pad_message(to_span(result.plaintext)); REQUIRE(result.plaintext.size() > data_body.size()); + REQUIRE(result.plaintext_padded.size() % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); // Sign the plaintext with the user's pro key crypto_sign_ed25519_detached( @@ -75,6 +79,14 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se result.plaintext.size(), user_rotating_privkey.data()); + crypto_sign_ed25519_detached( + result.sig_over_plaintext_padded_with_user_pro_key.data(), + nullptr, + reinterpret_cast(result.plaintext_padded.data()), + result.plaintext_padded.size(), + user_rotating_privkey.data()); + + // Setup the C versions for convenience std::memcpy( result.sig_over_plaintext_with_user_pro_key_c.data, @@ -283,7 +295,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Build protobuf `Content` message, serialise to `plaintext` and get it signed by the user's // "Session Pro" key into `sig_over_plaintext_with_user_pro_key` - SerialisedProtobufContentWithProForTesting protobuf_content_with_pro = + SerialisedProtobufContentWithProForTesting protobuf_content = build_protobuf_content_with_session_pro( /*data_body*/ data_body, /*user_rotating_privkey*/ user_pro_ed_sk, @@ -295,7 +307,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { bytes64 base_pro_sig = {}; std::memcpy( base_pro_sig.data, - protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.data(), + protobuf_content.sig_over_plaintext_with_user_pro_key.data(), sizeof(base_pro_sig.data)); session_protocol_destination base_dest = {}; @@ -328,8 +340,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_destination( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), &dest, @@ -345,8 +357,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for contact in default namespace with Pro") { // Encrypt content session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_1o1( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), base_dest.sent_timestamp_ms, @@ -381,7 +393,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( hash.data, - protobuf_content_with_pro.pro_proof_hash.data(), + protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == 0); REQUIRE(decrypt_result.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested @@ -454,7 +466,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( hash.data, - protobuf_content_with_pro.pro_proof_hash.data(), + protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == 0); REQUIRE(decrypt_result.pro_features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); @@ -476,8 +488,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_destination( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), &dest, @@ -509,8 +521,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { group_v2_session_sk.data, group_v2_sk.data(), sizeof(group_v2_session_sk.data)); encrypt_result = session_protocol_encode_for_group( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), base_dest.sent_timestamp_ms, @@ -555,8 +567,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encrypt/decrypt for sync messages with Pro") { // Encrypt session_protocol_encoded_for_destination encrypt_result = session_protocol_encode_for_1o1( - protobuf_content_with_pro.plaintext.data(), - protobuf_content_with_pro.plaintext.size(), + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), base_dest.sent_timestamp_ms, @@ -591,7 +603,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( hash.data, - protobuf_content_with_pro.pro_proof_hash.data(), + protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == 0); REQUIRE(decrypt_result.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested @@ -612,7 +624,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count() + 1, + protobuf_content.proof.expiry_unix_ts.time_since_epoch().count() + 1, pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, @@ -631,7 +643,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count(), + protobuf_content.proof.expiry_unix_ts.time_since_epoch().count(), bad_pro_backend_ed_pk.data(), bad_pro_backend_ed_pk.size(), error, @@ -653,7 +665,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &bad_decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch().count(), + protobuf_content.proof.expiry_unix_ts.time_since_epoch().count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, @@ -677,7 +689,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, std::chrono::duration_cast( - protobuf_content_with_pro.proof.expiry_unix_ts.time_since_epoch()) + protobuf_content.proof.expiry_unix_ts.time_since_epoch()) .count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), @@ -693,7 +705,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encode/decode for community (content message)") { std::vector encoded = - encode_for_community(to_span(protobuf_content_with_pro.plaintext), {}); + encode_for_community(to_span(protobuf_content.plaintext), {}); + REQUIRE(encoded.size() % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); DecodedCommunityMessage decode_comm_msg = decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); @@ -703,7 +716,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SECTION("Encode/decode for community (content message+pro)") { std::vector encoded = - encode_for_community(to_span(protobuf_content_with_pro.plaintext), user_pro_ed_sk); + encode_for_community(to_span(protobuf_content.plaintext), user_pro_ed_sk); + REQUIRE(encoded.size() % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); DecodedCommunityMessage decode_comm_msg = decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); @@ -716,7 +730,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SessionProtos::Envelope envelope; envelope.set_type(SessionProtos::Envelope_Type_SESSION_MESSAGE); envelope.set_timestamp(timestamp_s.time_since_epoch().count()); - envelope.set_content(protobuf_content_with_pro.plaintext); + envelope.set_content( + protobuf_content.plaintext_padded.data(), protobuf_content.plaintext_padded.size()); std::string envelope_plaintext = envelope.SerializeAsString(); DecodedCommunityMessage decode_comm_msg = @@ -729,10 +744,11 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SessionProtos::Envelope envelope; envelope.set_type(SessionProtos::Envelope_Type_SESSION_MESSAGE); envelope.set_timestamp(timestamp_s.time_since_epoch().count()); - envelope.set_content(protobuf_content_with_pro.plaintext); + envelope.set_content( + protobuf_content.plaintext_padded.data(), protobuf_content.plaintext_padded.size()); envelope.set_prosig( - protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.data(), - protobuf_content_with_pro.sig_over_plaintext_with_user_pro_key.size()); + protobuf_content.sig_over_plaintext_padded_with_user_pro_key.data(), + protobuf_content.sig_over_plaintext_padded_with_user_pro_key.size()); std::string envelope_plaintext = envelope.SerializeAsString(); DecodedCommunityMessage decode_comm_msg = From dc6dc91c2f0fc75ffd69578adb0d1d02cf636dda Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 29 Sep 2025 11:21:29 +1000 Subject: [PATCH 099/171] Allow configurable session pro backend URL in unit tests --- README.md | 13 ++++++++----- tests/CMakeLists.txt | 2 +- tests/main.cpp | 7 ++++++- tests/test_pro_backend.cpp | 25 +++++++++++++------------ 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index da474771..7defaee3 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,14 @@ # # -D TEST_PRO_BACKEND_WITH_DEV_SERVER=1 # -# These tests require the Session Pro Backend to be running at 127.0.0.1:5000 -# 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. +# 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="" when invoking the test suite. # cmake -G Ninja -S . -B Build diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ca1157af..16983201 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -60,7 +60,7 @@ target_link_libraries(testAll PRIVATE test_libs Catch2::Catch2) -option(TEST_PRO_BACKEND_WITH_DEV_SERVER "Run the Pro Backend tests relying on a development server at 127.0.0.1:5000 and CURL" OFF) +option(TEST_PRO_BACKEND_WITH_DEV_SERVER "Run the Pro Backend tests relying on a SESH_PRO_BACKEND_DEV=1 enabled server at the specified string with CURL" OFF) if (TEST_PRO_BACKEND_WITH_DEV_SERVER) find_package(CURL REQUIRED) target_link_libraries(testAll PRIVATE CURL::libcurl) diff --git a/tests/main.cpp b/tests/main.cpp index a814e50e..76c4cc49 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,6 +1,8 @@ #include #include +std::string g_test_pro_backend_dev_server_url = "http://127.0.0.1:5000"; + int main(int argc, char* argv[]) { Catch::Session session; @@ -15,7 +17,10 @@ int main(int argc, char* argv[]) { "oxen-logging log file to output logs to, or one of or one of " "stdout/-/stderr/syslog.") | Opt(test_case_tracing)["-T"]["--test-tracing"]( - "enable oxen log tracing of test cases/sections"); + "enable oxen log tracing of test cases/sections") | + Opt(g_test_pro_backend_dev_server_url, "url")["--pro-backend-dev-server-url"]( + "URL to a SESH_PRO_BACKEND_DEV=1 enabled Session Pro Backend server. Only " + "used if compiled with -D TEST_PRO_BACKEND_WITH_DEV_SERVER=1 support"); session.cli(cli); diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index e844a8a3..8018e028 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -23,6 +23,9 @@ struct scope_exit { using namespace session::pro_backend; +// NOTE: This is defined in main.cpp because it accepts a value from the CLI +extern std::string g_test_pro_backend_dev_server_url; + static bool string8_equals(string8 s8, std::string_view str) { return s8.size == str.size() && std::memcmp(s8.data, str.data(), s8.size) == 0; } @@ -76,17 +79,14 @@ size_t curl_perform_callback(void* contents, size_t size, size_t nmemb, void* us }; std::string curl_do_basic_blocking_post_request( - CURL* curl, curl_slist* headers, std::string_view url, std::string_view post_body) { - std::string url_null_terminated = std::string(url); - + CURL* curl, curl_slist* headers, const std::string& url, std::string_view post_body) { std::string result; curl_easy_reset(curl); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_perform_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &result); - curl_easy_setopt(curl, CURLOPT_URL, url_null_terminated.c_str()); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); if (post_body.size()) { curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_body.data()); @@ -647,7 +647,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { } #if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) - SECTION("Send to local dev server") { + SECTION("Send to dev server") { const auto DEV_BACKEND_PUBKEY = "fc947730f49eb01427a66e050733294d9e520e545c7a27125a780634e0860a27"_hexbytes; @@ -709,7 +709,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/add_pro_payment", + g_test_pro_backend_dev_server_url + "/add_pro_payment", std::string_view(request_json.json.data, request_json.json.size)); // Parse response @@ -768,7 +768,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/get_pro_proof", + g_test_pro_backend_dev_server_url + "/get_pro_proof", std::string_view(request_json.json.data, request_json.json.size)); // Parse response @@ -827,7 +827,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/get_pro_status", + g_test_pro_backend_dev_server_url + "/get_pro_status", std::string_view(request_json.json.data, request_json.json.size)); // Parse response @@ -876,7 +876,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/get_pro_status", + g_test_pro_backend_dev_server_url + "/get_pro_status", std::string_view(request_json.json.data, request_json.json.size)); // Parse response @@ -944,7 +944,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/add_pro_payment", + g_test_pro_backend_dev_server_url + "/add_pro_payment", std::string_view(request_json.json.data, request_json.json.size)); // Parse response @@ -980,7 +980,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - "http://127.0.0.1:5000/get_pro_revocations", + g_test_pro_backend_dev_server_url + "/get_pro_revocations", std::string_view(request_json.json.data, request_json.json.size)); // Parse response @@ -995,6 +995,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { string8 error = response.header.errors[index]; fprintf(stderr, "ERROR: %s\n", error.data); } + INFO("RESPONSE: " << response_json); // Verify the response REQUIRE(response.header.errors_count == 0); From bc4fe8af34ff365e36e3032d373bbec7759dd3e8 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 29 Sep 2025 13:36:03 +1000 Subject: [PATCH 100/171] Formatting --- src/session_protocol.cpp | 16 +++++++++------- tests/test_session_protocol.cpp | 18 ++++++------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 2903418f..b87b03d3 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -437,7 +437,8 @@ static EncryptedForDestinationInternal encode_for_destination_internal( // https://github.com/session-foundation/session-ios/blob/82deef869d0f7389b799295817f42ad14f8a1316/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L398 if (dest_pro_rotating_ed25519_privkey.size()) { // Key should be verified by the time we hit this branch - assert(dest_pro_rotating_ed25519_privkey.size() == crypto_sign_ed25519_SECRETKEYBYTES); + assert(dest_pro_rotating_ed25519_privkey.size() == + crypto_sign_ed25519_SECRETKEYBYTES); // TODO: Sub-optimal, but we parse the content again to make sure it's valid. Sign // the blob then, fill in the signature in-place as part of the transitioning of @@ -460,11 +461,11 @@ static EncryptedForDestinationInternal encode_for_destination_internal( tmp_content_buffer = pad_message(content); array_uc64 pro_sig; bool was_signed = crypto_sign_ed25519_detached( - pro_sig.data(), - nullptr, - tmp_content_buffer.data(), - tmp_content_buffer.size(), - dest_pro_rotating_ed25519_privkey.data()) == 0; + pro_sig.data(), + nullptr, + tmp_content_buffer.data(), + tmp_content_buffer.size(), + dest_pro_rotating_ed25519_privkey.data()) == 0; assert(was_signed); // Now assign the community specific pro signature field, reserialize it and we have @@ -839,7 +840,8 @@ DecodedCommunityMessage decode_for_community( // Parse the content blob SessionProtos::Content content = {}; - if (!content.ParseFromArray(result.content_plaintext.data(), result.content_plaintext_unpadded_size)) + if (!content.ParseFromArray( + result.content_plaintext.data(), result.content_plaintext_unpadded_size)) throw std::runtime_error{ "Decoding community message failed, could not interpret blob as content or " "envelope"}; diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 3e907fe5..35db94cb 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -86,7 +86,6 @@ static SerialisedProtobufContentWithProForTesting build_protobuf_content_with_se result.plaintext_padded.size(), user_rotating_privkey.data()); - // Setup the C versions for convenience std::memcpy( result.sig_over_plaintext_with_user_pro_key_c.data, @@ -391,10 +390,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); - REQUIRE(std::memcmp( - hash.data, - protobuf_content.pro_proof_hash.data(), - sizeof(hash.data)) == 0); + REQUIRE(std::memcmp(hash.data, protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == + 0); REQUIRE(decrypt_result.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested @@ -464,10 +461,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); - REQUIRE(std::memcmp( - hash.data, - protobuf_content.pro_proof_hash.data(), - sizeof(hash.data)) == 0); + REQUIRE(std::memcmp(hash.data, protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == + 0); REQUIRE(decrypt_result.pro_features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); @@ -602,9 +597,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); REQUIRE(std::memcmp( - hash.data, - protobuf_content.pro_proof_hash.data(), - sizeof(hash.data)) == 0); + hash.data, protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == + 0); REQUIRE(decrypt_result.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested From e6ec4aa069157a375f2c0d429dd4431256ad6e28 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 29 Sep 2025 15:28:52 +1000 Subject: [PATCH 101/171] Implement C wrappers for encode_for_community/inbox --- include/session/session_protocol.h | 216 ++++++++++++++++++------- include/session/session_protocol.hpp | 16 +- src/session_protocol.cpp | 225 ++++++++++++++++++++------- tests/test_pro_backend.cpp | 9 -- tests/test_session_protocol.cpp | 221 +++++++++++++++++++------- tests/utils.hpp | 9 ++ 6 files changed, 508 insertions(+), 188 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index e646741b..6dc44878 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -32,7 +32,7 @@ typedef enum SESSION_PROTOCOL_PRO_STATUS { // See session::ProStatus SESSION_PROTOCOL_PRO_STATUS_INVALID_USER_SIG, SESSION_PROTOCOL_PRO_STATUS_VALID, SESSION_PROTOCOL_PRO_STATUS_EXPIRED, -} PRO_STATUS; +} SESSION_PROTOCOL_PRO_STATUS; typedef struct session_protocol_pro_signed_message { span_u8 sig; @@ -113,7 +113,13 @@ typedef struct session_protocol_decode_envelope_keys { size_t ed25519_privkeys_len; } session_protocol_decode_envelope_keys; -typedef struct session_protocol_decode_envelope { +struct session_protocol_decoded_pro { + SESSION_PROTOCOL_PRO_STATUS status; + session_protocol_pro_proof proof; + SESSION_PROTOCOL_PRO_FEATURES features; +}; + +typedef struct session_protocol_decoded_envelope { // Indicates if the decryption was successful. If the decryption step failed and threw an // exception, this is false. bool success; @@ -121,9 +127,7 @@ typedef struct session_protocol_decode_envelope { span_u8 content_plaintext; bytes32 sender_ed25519_pubkey; bytes32 sender_x25519_pubkey; - PRO_STATUS pro_status; - session_protocol_pro_proof pro_proof; - SESSION_PROTOCOL_PRO_FEATURES pro_features; + session_protocol_decoded_pro pro; size_t error_len_incl_null_terminator; } session_protocol_decoded_envelope; @@ -135,6 +139,18 @@ typedef struct session_protocol_encoded_for_destination { size_t error_len_incl_null_terminator; } session_protocol_encoded_for_destination; +struct session_protocol_decoded_community_message { + bool success; + bool has_envelope; + session_protocol_envelope envelope; + span_u8 content_plaintext; + size_t content_plaintext_unpadded_size; + bool has_pro; + bytes64 pro_sig; + session_protocol_decoded_pro pro; + size_t error_len_incl_null_terminator; +}; + /// API: session_protocol/session_protocol_pro_proof_hash /// /// Generate the 32 byte hash that is to be signed by the rotating key or Session Pro Backend key to @@ -192,12 +208,12 @@ LIBSESSION_EXPORT bool session_protocol_pro_proof_verify_message( /// API: session_protocol/session_protocol_pro_proof_is_active /// -/// Check if the Pro proof is currently entitled to Pro given the `unix_ts` with respect to the +/// Check if the Pro proof is currently entitled to Pro given the `unix_ts_ms` with respect to the /// proof's `expiry_unix_ts` /// /// Inputs: /// - `proof` -- Proof to verify -/// - `unix_ts_s` -- The unix timestamp in seconds to check the proof expiry time against +/// - `unix_ts_ms` -- The unix timestamp to check the proof expiry time against /// /// Outputs: /// - `bool` -- True if expired, false otherwise @@ -207,7 +223,7 @@ LIBSESSION_EXPORT bool session_protocol_pro_proof_is_active( /// API: session_protocol/session_protocol_pro_proof_status /// /// Evaluate the status of the pro proof by checking it is signed by the `verify_pubkey`, it has -/// not expired via `unix_ts_s` and optionally verify that the `signed_msg` was signed by the +/// not expired via `unix_ts_ms` and optionally verify that the `signed_msg` was signed by the /// `rotating_pubkey` embedded in the proof. /// /// Internally this function calls `pro_proof_verify_signature`, `pro_proof_verify_message` and @@ -221,7 +237,7 @@ LIBSESSION_EXPORT bool session_protocol_pro_proof_is_active( /// they are the original signatory of the proof. /// - `verify_pubkey_len` -- Length of the `verify_pubkey` should be 32 bytes /// they are the original signatory of the proof. -/// - `unix_ts` -- Unix timestamp in seconds to compared against the embedded `expiry_unix_ts` +/// - `unix_ts_ms` -- Unix timestamp to compared against the embedded `expiry_unix_ts` /// to determine if the proof has expired or not /// - `signed_msg` -- Optionally set the payload to the message with the signature to verify if /// the embedded `rotating_pubkey` in the proof signed the given message. @@ -230,11 +246,11 @@ LIBSESSION_EXPORT bool session_protocol_pro_proof_is_active( /// - `status` - The derived status given the components of the message. If `signed_msg` is /// not set then this function can never return `PRO_STATUS_INVALID_USER_SIG` from the set of /// possible enum values. Otherwise this funtion can return all possible values. -LIBSESSION_EXPORT PRO_STATUS session_protocol_pro_proof_status( +LIBSESSION_EXPORT SESSION_PROTOCOL_PRO_STATUS session_protocol_pro_proof_status( session_protocol_pro_proof const* proof, const uint8_t* verify_pubkey, size_t verify_pubkey_len, - uint64_t unix_ts_s, + uint64_t unix_ts_ms, OPTIONAL const session_protocol_pro_signed_message* signed_msg) NON_NULL_ARG(1, 2); /// API: session_protocol/session_protocol_get_pro_features_for_msg @@ -295,13 +311,13 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( /// API: session_protocol_encode_for_1o1 /// -/// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session +/// Encode a plaintext message for a one-on-one (1o1) conversation or sync message in the Session /// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for /// transmission to a single recipient. /// /// See: session_protocol/encode_for_1o1 for more information /// -/// The encryption result must be freed with session_protocol_encrypt_for_destination_free when +/// The encoded result must be freed with session_protocol_encrypt_for_destination_free when /// the caller is done with the result. /// /// Inputs: @@ -327,7 +343,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( /// character reserved for the null-terminator. /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// - `success` -- True if encoding was successful, if the underlying implementation threw /// an exception then this is caught internally and success is set to false. All remaining fields /// are to be ignored in the result on failure. /// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for @@ -336,8 +352,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( /// the user passes in a non-NULL error buffer this is the amount of characters written to the /// error buffer. If the user passes in a NULL error buffer, this is the amount of characters /// required to write the error. Both counts include the null-terminator. The user must allocate -/// at minimum the requested length, including the null-terminator in order for the error message -/// to be preserved in full. +/// at minimum the requested length for the error message to be preserved in full. LIBSESSION_EXPORT session_protocol_encoded_for_destination session_protocol_encode_for_1o1( const void* plaintext, @@ -353,13 +368,13 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( /// API: session_protocol_encode_for_community_inbox /// -/// Encrypt a plaintext message for a community inbox in the Session Protocol. This function wraps +/// Encode a plaintext message for a community inbox in the Session Protocol. This function wraps /// the plaintext in the necessary structures and encrypts it for transmission to a community inbox /// server. /// /// See: session_protocol/encode_for_community_inbox for more information /// -/// The encryption result must be freed with session_protocol_encrypt_for_destination_free when +/// The encoded result must be freed with session_protocol_encrypt_for_destination_free when /// the caller is done with the result. /// /// Inputs: @@ -377,7 +392,6 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( /// If provided, the corresponding proof must be set in the `Content`. The signature must not be /// set in `Content`. /// - `pro_rotating_ed25519_privkey_len` -- The length of the Session Pro Ed25519 key -// TODO: Pro sig is not incorporated into community/inbox messages yet. /// - `error` -- Pointer to the character buffer to be populated with the error message if the /// returned success was false, untouched otherwise. If this is set to NULL, then on failure, /// the returned error_len_incl_null_terminator is the number of bytes required by the user to @@ -389,7 +403,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( /// last character reserved for the null-terminator. /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// - `success` -- True if encoding was successful, if the underlying implementation threw /// an exception then this is caught internally and success is set to false. All remaining fields /// are to be ignored in the result on failure. /// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for @@ -398,8 +412,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_1o1( /// the user passes in a non-NULL error buffer this is the amount of characters written to the /// error buffer. If the user passes in a NULL error buffer, this is the amount of characters /// required to write the error. Both counts include the null-terminator. The user must allocate -/// at minimum the requested length, including the null-terminator in order for the error message -/// to be preserved in full. +/// at minimum the requested length in order for the error message to be preserved in full. LIBSESSION_EXPORT session_protocol_encoded_for_destination session_protocol_encode_for_community_inbox( @@ -415,16 +428,67 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i OPTIONAL char* error, size_t error_len) NON_NULL_ARG(1, 3, 6, 7); +/// API: session_protocol_encode_for_community +/// +/// Encode a plaintext `Content` message for a community in the Session Protocol. This function +/// encodes Session Pro metadata including generating and embedding the Session Pro signature, when +/// given a Session Pro rotating Ed25519 key into the final payload suitable for transmission on the +/// wire. +/// +/// See: session_protocol/encode_for_community for more information +/// +/// The encoded result must be freed with session_protocol_encrypt_for_destination_free when +/// the caller is done with the result. +/// +/// Inputs: +/// - `plaintext `-- The protobuf serialized payload containing the Content to be encrypted. Must +/// not be already encrypted. +/// - `plaintext_len` -- The length of the plaintext buffer in bytes. +/// - `pro_rotating_ed25519_privkey` -- Optional rotating Session Pro Ed25519 key (64-bytes or +/// 32-byte seed) to sign the encoded content if you wish to entitle the message to Session Pro. +/// If provided, the corresponding proof must be set in the `Content`. The signature must not be +/// set in `Content`. +/// - `pro_rotating_ed25519_privkey_len` -- The length of the Session Pro Ed25519 key +/// - `error` -- Pointer to the character buffer to be populated with the error message if the +/// returned success was false, untouched otherwise. If this is set to NULL, then on failure, +/// the returned error_len_incl_null_terminator is the number of bytes required by the user to +/// receive the error. The message may be truncated if the buffer is too small, but it's always +/// guaranteed that error is null-terminated on failure when a buffer is passed in even if the +/// error must be truncated to fit in the buffer. +/// - `error_len` -- The capacity of the character buffer passed by the user. This should be 0 if +/// error is NULL. This function will fill the buffer up to error_len - 1 characters with the +/// last character reserved for the null-terminator. +/// +/// Outputs: +/// - `success` -- True if encoding was successful, if the underlying implementation threw +/// an exception then this is caught internally and success is set to false. All remaining fields +/// are to be ignored in the result on failure. +/// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for +/// sending on the wire (i.e: it has been protobuf encoded/wrapped if necessary). +/// - `error_len_incl_null_terminator` -- The length of the error message if success was false. If +/// the user passes in a non-NULL error buffer this is the amount of characters written to the +/// error buffer. If the user passes in a NULL error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested length in order for the error message to be preserved in full. +LIBSESSION_EXPORT +session_protocol_encoded_for_destination session_protocol_encode_for_community( + const void* plaintext, + size_t plaintext_len, + OPTIONAL const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, + OPTIONAL char* err, + size_t error_len) NON_NULL_ARG(1); + /// API: session_protocol_encode_for_group /// -/// Encrypt a plaintext message for a group in the Session Protocol. This function wraps the +/// Encode a plaintext message for a group in the Session Protocol. This function wraps the /// plaintext in the necessary structures and encrypts it for transmission to a group, using the /// group's encryption key. Only v2 groups, (0x03) prefixed keys are supported. Passing a legacy /// group (0x05) prefixed key will cause the function to return a failure with an error message. /// /// See: session_protocol/encode_for_group for more information /// -/// The encryption result must be freed with session_protocol_encrypt_for_destination_free when +/// The encoded result must be freed with session_protocol_encrypt_for_destination_free when /// the caller is done with the result. /// /// Inputs: @@ -454,7 +518,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i /// last character reserved for the null-terminator. /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// - `success` -- True if encoding was successful, if the underlying implementation threw /// an exception then this is caught internally and success is set to false. All remaining fields /// are to be ignored in the result on failure. /// - `ciphertext` -- Encryption result for the plaintext. The returned payload is suitable for @@ -463,8 +527,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i /// the user passes in a non-NULL error buffer this is the amount of characters written to the /// error buffer. If the user passes in a NULL error buffer, this is the amount of characters /// required to write the error. Both counts include the null-terminator. The user must allocate -/// at minimum the requested length, including the null-terminator in order for the error message -/// to be preserved in full. +/// at minimum the requested length in order for the error message to be preserved in full. LIBSESSION_EXPORT session_protocol_encoded_for_destination session_protocol_encode_for_group( const void* plaintext, @@ -487,7 +550,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( /// /// See: session_protocol/encrypt_for_destination for more information /// -/// The encryption result must be freed with `session_protocol_encrypt_for_destination_free` when +/// The encoded result must be freed with `session_protocol_encrypt_for_destination_free` when /// the caller is done with the result. /// /// Inputs: @@ -508,7 +571,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( /// last character reserved for the null-terminator. /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// - `success` -- True if encoding was successful, if the underlying implementation threw /// an exception then this is caught internally and success is set to false. All remaining fields /// are to be ignored in the result on failure. /// - `ciphertext` -- Encryption result for the plaintext. The retured payload is suitable for @@ -517,17 +580,16 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( /// the user passes in an non-`NULL` error buffer this is amount of characters written to the /// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters /// required to write the error. Both counts include the null-terminator. The user must allocate -/// at minimum the requested length, including the null-terminator in order for the error message -/// to be preserved in full. +/// at minimum the requested length for the error message to be preserved in full. LIBSESSION_EXPORT session_protocol_encoded_for_destination session_protocol_encode_for_destination( const void* plaintext, size_t plaintext_len, - const void* ed25519_privkey, + OPTIONAL const void* ed25519_privkey, size_t ed25519_privkey_len, const session_protocol_destination* dest, OPTIONAL char* error, - size_t error_len) NON_NULL_ARG(1, 3, 5); + size_t error_len) NON_NULL_ARG(1, 5); /// API: session_protocol/session_protocol_encrypt_for_destination_free /// @@ -549,21 +611,11 @@ LIBSESSION_EXPORT void session_protocol_encode_for_destination_free( /// /// See: session_protocol/decode_envelope for more information /// -/// The encryption result must be freed with `session_protocol_decode_envelope_free` when the +/// The decoded result must be freed with `session_protocol_decode_for_community_free` when the /// caller is done with the result. /// /// Inputs: -/// - `keys` -- the keys to decrypt either the envelope or the envelope contents. Groups v2 -/// envelopes where the envelope is encrypted must set the group key. Envelopes with an encrypted -/// content must set the the libsodium-style secret key of the receiver, 64 bytes. Can also be -/// passed as a 32-byte seed. -/// -/// If a group decryption key is specified, the recipient key is ignored and vice versa. Only one -/// of the keys should be set depending on the type of envelope. -/// -/// - `envelope_payload` -- the envelope payload either encrypted (groups v2 style) or unencrypted -/// (1o1 or legacy groups). -/// - `unix_ts` -- pass in the current system time in seconds which is used to determine, whether or +/// - `unix_ts_ms` -- pass in the current system time which is used to determine, whether or /// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no /// proof in the message. /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in @@ -580,7 +632,7 @@ LIBSESSION_EXPORT void session_protocol_encode_for_destination_free( /// last character reserved for the null-terminator. /// /// Outputs: -/// - `success` -- True if encryption was successful, if the underlying implementation threw +/// - `success` -- True if encoding was successful, if the underlying implementation threw /// an exception then this is caught internally and success is set to false. All remaining fields /// in the result are to be ignored on failure. /// - `envelope` -- Envelope structure that was decrypted/parsed from the `envelope_plaintext` @@ -610,32 +662,86 @@ LIBSESSION_EXPORT void session_protocol_encode_for_destination_free( /// the user passes in an non-`NULL` error buffer this is amount of characters written to the /// error buffer. If the user passes in a `NULL` error buffer, this is the amount of characters /// required to write the error. Both counts include the null-terminator. The user must allocate -/// at minimum the requested length, including the null-terminator in order for the error message -/// to be preserved in full. +/// at minimum the requested length for the error message to be preserved in full. LIBSESSION_EXPORT session_protocol_decoded_envelope session_protocol_decode_envelope( const session_protocol_decode_envelope_keys* keys, const void* envelope_plaintext, size_t envelope_plaintext_len, - uint64_t unix_ts, + uint64_t unix_ts_ms, OPTIONAL const void* pro_backend_pubkey, size_t pro_backend_pubkey_len, OPTIONAL char* error, size_t error_len) NON_NULL_ARG(1, 2); -/// API: session_protocol/session_protocol_decrypt_envelope_free +/// API: session_protocol/session_protocol_decode_envelope_free /// -/// Free the decryption result produced by `session_protocol_decrypt_envelope`. It is safe to pass a -/// `NULL` or any result returned by the decrypt function irrespective of if the function succeeded +/// Free the decoded result produced by `session_protocol_decode_envelope`. It is safe to pass a +/// `NULL` or any result returned by the decode function irrespective of if the function succeeded /// or failed. /// /// Inputs: -/// - `envelope` -- Decryption result to free. This object is zeroed out on free and should no -/// longer -/// be used after it is freed. +/// - `envelope` -- decoded result to free. This object is zeroed out on free and should no +/// longer be used after it is freed. LIBSESSION_EXPORT void session_protocol_decode_envelope_free( session_protocol_decoded_envelope* envelope); +/// API: session_protocol/session_protocol_decode_for_community +/// +/// Given an unencrypted content or envelope payload extract the plaintext to the content and any +/// associated pro metadata if there was any in the message. +/// +/// Inputs: +/// - `content_or_envelope_payload` -- the unencrypted content or envelope payload containing the +/// community message +/// - `unix_ts_ms` -- pass in the current system time which is used to determine, whether or +/// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no +/// proof in the message. +/// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in +/// the proof, validating whether or not the attached proof was indeed issued by an authorised +/// issuer +/// +/// Outputs: +/// - `envelope` -- Envelope structure that was parsed from the `content_or_envelope_payload` if the +/// payload was an envelope. Nil otherwise. +/// - `content_plaintext` -- The protobuf encoded stream that can be parsed into a protobuf +/// `Content` structure that was extracted from the `content_or_envelope_payload` +/// - `has_pro` -- Flag that indicates if the `pro` struct was populated or not. +/// - `pro_sig` -- Optional pro signature if there was one located in the +/// `content_or_envelope_payload`. This is the same signature as the one located in the `envelope` +/// object if the original payload was an envelope. +/// - `pro` -- Optional object that is set if there was pro metadata associatd with the envelope, if +/// any. The `status` field in the decrypted pro object should be used to determine whether or not +/// the caller can respect the contents of the `proof` and `features`. +/// - `error_len_incl_null_terminator` -- The length of the error message if success was false. If +/// the user passes in a non-NULL error buffer this is the amount of characters written to the +/// error buffer. If the user passes in a NULL error buffer, this is the amount of characters +/// required to write the error. Both counts include the null-terminator. The user must allocate +/// at minimum the requested lengthin order for the error message to be preserved in full. +/// +/// If the `status` is set to valid the the caller can proceed with entitling the envelope with +/// access to pro features if it's using any. +session_protocol_decoded_community_message session_protocol_decode_for_community( + const void* content_or_envelope_payload, + size_t content_or_envelope_payload_len, + uint64_t unix_ts_ms, + OPTIONAL const void* pro_backend_pubkey, + size_t pro_backend_pubkey_len, + OPTIONAL char* error, + size_t error_len) NON_NULL_ARG(1); + +/// API: session_protocol/session_protocol_decode_for_community_free +/// +/// Free the decoded result produced by `session_protocol_decode_for_community`. It is safe to pass +/// a `NULL` or any result returned by the decode function irrespective of if the function +/// succeeded or failed. +/// +/// Inputs: +/// - `community_msg` -- decoded result to free. This object is zeroed out on free and should no +/// longer be used after it is freed. +LIBSESSION_EXPORT void session_protocol_decode_for_community_free( + session_protocol_decoded_community_message* community_msg); + #ifdef __cplusplus } #endif diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 63801c2a..00e86acf 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -360,7 +360,7 @@ std::vector pad_message(std::span payload); /// API: session_protocol/encode_for_1o1 /// -/// Encrypt a plaintext message for a one-on-one (1o1) conversation or sync message in the Session +/// Encode a plaintext message for a one-on-one (1o1) conversation or sync message in the Session /// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for /// transmission to a single recipient. /// @@ -392,7 +392,7 @@ std::vector encode_for_1o1( /// API: session_protocol/encode_for_community_inbox /// -/// Encrypt a plaintext message for a community inbox in the Session Protocol. This function wraps +/// Encode a plaintext message for a community inbox in the Session Protocol. This function wraps /// the plaintext in the necessary structures and encrypts it for transmission to a community inbox /// server. /// @@ -426,7 +426,7 @@ std::vector encode_for_community_inbox( /// API: session_protocol/encode_for_community /// -/// Encrypt a plaintext `Content` message for a community for the Session Protocol. This function +/// Encode a plaintext `Content` message for a community in the Session Protocol. This function /// encodes Session Pro metadata including generating and embedding the Session Pro signature, when /// given a Session Pro rotating Ed25519 key into the final payload suitable for transmission on the /// wire. @@ -449,7 +449,7 @@ std::vector encode_for_community( /// API: session_protocol/encode_for_group /// -/// Encrypt a plaintext message for a group in the Session Protocol. This function wraps the +/// Encode a plaintext message for a group in the Session Protocol. This function wraps the /// plaintext in the necessary structures and encrypts it for transmission to a group, using the /// group's encryption key. Only v2 groups, (0x03) prefixed keys are supported. Passing a legacy /// group (0x05) prefixed key will cause the function to throw. @@ -545,7 +545,7 @@ std::vector encode_for_destination( /// /// - `envelope_payload` -- the envelope payload either encrypted (groups v2 style) or unencrypted /// (1o1 or legacy groups). -/// - `unix_ts` -- pass in the current system time in seconds which is used to determine, whether or +/// - `unix_ts` -- pass in the current system time which is used to determine, whether or /// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no /// proof in the message. /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in @@ -571,7 +571,7 @@ std::vector encode_for_destination( DecodedEnvelope decode_envelope( const DecodeEnvelopeKey& keys, std::span envelope_payload, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, const array_uc32& pro_backend_pubkey); /// API: session_protocol/decode_for_community @@ -582,7 +582,7 @@ DecodedEnvelope decode_envelope( /// Inputs: /// - `content_or_envelope_payload` -- the unencrypted content or envelope payload containing the /// community message -/// - `unix_ts` -- pass in the current system time in seconds which is used to determine, whether or +/// - `unix_ts` -- pass in the current system time which is used to determine, whether or /// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no /// proof in the message. /// - `pro_backend_pubkey` -- the Session Pro backend public key to verify the signature embedded in @@ -605,6 +605,6 @@ DecodedEnvelope decode_envelope( /// access to pro features if it's using any. DecodedCommunityMessage decode_for_community( std::span content_or_envelope_payload, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, const array_uc32& pro_backend_pubkey); } // namespace session diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index b87b03d3..8460e160 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -20,7 +20,7 @@ session::array_uc32 proof_hash_internal( std::uint8_t version, std::span gen_index_hash, std::span rotating_pubkey, - std::uint64_t expiry_unix_ts) { + std::uint64_t expiry_unix_ts_ms) { // This must match the hashing routine at // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 session::array_uc32 result = {}; @@ -30,7 +30,7 @@ session::array_uc32 proof_hash_internal( crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); crypto_generichash_blake2b_update( - &state, reinterpret_cast(&expiry_unix_ts), sizeof(expiry_unix_ts)); + &state, reinterpret_cast(&expiry_unix_ts_ms), sizeof(expiry_unix_ts_ms)); crypto_generichash_blake2b_final(&state, result.data(), result.size()); return result; } @@ -73,6 +73,53 @@ bool proof_is_active_internal(uint64_t expiry_unix_ts_ms, uint64_t unix_ts_ms) { bool result = unix_ts_ms <= expiry_unix_ts_ms; return result; } + +struct array_uc32_from_ptr_result { + bool success; + session::array_uc32 data; +}; + +static array_uc32_from_ptr_result array_uc32_from_ptr(const void* ptr, size_t len) { + array_uc32_from_ptr_result result = {}; + if (ptr) { + if (len != result.data.max_size()) + return result; + std::memcpy(result.data.data(), ptr, len); + } + result.success = true; + return result; +} + +static session_protocol_envelope envelope_from_cpp(const session::Envelope& cpp) { + session_protocol_envelope result = {}; + result.flags = cpp.flags; + result.timestamp_ms = static_cast(cpp.timestamp.count()); + std::memcpy(result.source.data, cpp.source.data(), sizeof(result.source.data)); + result.server_timestamp = cpp.server_timestamp; + result.source_device = cpp.source_device; + std::memcpy(result.pro_sig.data, cpp.pro_sig.data(), sizeof(result.pro_sig.data)); + return result; +} + +static session_protocol_decoded_pro decoded_pro_from_cpp(const session::DecodedPro& cpp) { + session_protocol_decoded_pro result = {}; + result.status = static_cast(cpp.status); + result.proof.version = cpp.proof.version; + std::memcpy( + result.proof.gen_index_hash.data, + cpp.proof.gen_index_hash.data(), + cpp.proof.gen_index_hash.max_size()); + std::memcpy( + result.proof.rotating_pubkey.data, + cpp.proof.rotating_pubkey.data(), + cpp.proof.rotating_pubkey.max_size()); + result.proof.expiry_unix_ts_ms = std::chrono::duration_cast( + cpp.proof.expiry_unix_ts.time_since_epoch()) + .count(); + std::memcpy(result.proof.sig.data, cpp.proof.sig.data(), cpp.proof.sig.max_size()); + result.features = cpp.features; + return result; +} } // namespace namespace session { @@ -309,6 +356,15 @@ static EncryptedForDestinationInternal encode_for_destination_internal( assert(dest_group_ed25519_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_privkey.size() == 32 || dest_group_ed25519_privkey.size() == 64); + bool is_group = dest_type == DestinationType::Group; + bool is_1o1 = dest_type == DestinationType::SyncOr1o1; + bool is_community_inbox = dest_type == DestinationType::CommunityInbox; + bool is_community = dest_type == DestinationType::Community; + if (!is_community) { + assert(ed25519_privkey.size() == crypto_sign_ed25519_SECRETKEYBYTES || + ed25519_privkey.size() == crypto_sign_ed25519_SEEDBYTES); + } + // Ensure the Session Pro rotating key is a 64 byte key if given cleared_uc64 pro_ed_sk_from_seed; if (dest_pro_rotating_ed25519_privkey.size()) { @@ -329,10 +385,6 @@ static EncryptedForDestinationInternal encode_for_destination_internal( } } - bool is_group = dest_type == DestinationType::Group; - bool is_1o1 = dest_type == DestinationType::SyncOr1o1; - bool is_community_inbox = dest_type == DestinationType::CommunityInbox; - bool is_community = dest_type == DestinationType::Community; std::span content = plaintext; EncryptedForDestinationInternal result = {}; @@ -537,7 +589,7 @@ std::vector encode_for_destination( DecodedEnvelope decode_envelope( const DecodeEnvelopeKey& keys, std::span envelope_payload, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, const array_uc32& pro_backend_pubkey) { DecodedEnvelope result = {}; SessionProtos::Envelope envelope = {}; @@ -767,7 +819,7 @@ DecodedEnvelope decode_envelope( DecodedCommunityMessage decode_for_community( std::span content_or_envelope_payload, - std::chrono::sys_seconds unix_ts, + std::chrono::sys_time unix_ts, const array_uc32& pro_backend_pubkey) { // TODO: Community message parsing requires a custom code path for now as we are planning to // migrate from sending plain `Content` to `Content` with a pro signature embedded in `Content` @@ -1002,13 +1054,13 @@ LIBSESSION_C_API bool session_protocol_pro_proof_is_active( return result; } -LIBSESSION_C_API PRO_STATUS session_protocol_pro_proof_status( +LIBSESSION_C_API SESSION_PROTOCOL_PRO_STATUS session_protocol_pro_proof_status( session_protocol_pro_proof const* proof, const uint8_t* verify_pubkey, size_t verify_pubkey_len, - uint64_t unix_ts_s, + uint64_t unix_ts_ms, const session_protocol_pro_signed_message* signed_msg) { - PRO_STATUS result = SESSION_PROTOCOL_PRO_STATUS_VALID; + SESSION_PROTOCOL_PRO_STATUS result = SESSION_PROTOCOL_PRO_STATUS_VALID; if (!session_protocol_pro_proof_verify_signature(proof, verify_pubkey, verify_pubkey_len)) result = SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG; @@ -1025,7 +1077,7 @@ LIBSESSION_C_API PRO_STATUS session_protocol_pro_proof_status( // Check if the proof has expired if (result == SESSION_PROTOCOL_PRO_STATUS_VALID && - !session_protocol_pro_proof_is_active(proof, unix_ts_s)) + !session_protocol_pro_proof_is_active(proof, unix_ts_ms)) result = SESSION_PROTOCOL_PRO_STATUS_EXPIRED; return result; } @@ -1122,6 +1174,25 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community_i return result; } +LIBSESSION_C_API +session_protocol_encoded_for_destination session_protocol_encode_for_community( + const void* plaintext, + size_t plaintext_len, + const void* pro_rotating_ed25519_privkey, + size_t pro_rotating_ed25519_privkey_len, + char* error, + size_t error_len) { + + session_protocol_destination dest = {}; + dest.type = SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey_len = pro_rotating_ed25519_privkey_len; + + session_protocol_encoded_for_destination result = session_protocol_encode_for_destination( + plaintext, plaintext_len, nullptr, 0, &dest, error, error_len); + return result; +} + LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encode_for_group( const void* plaintext, @@ -1218,7 +1289,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( const session_protocol_decode_envelope_keys* keys, const void* envelope_plaintext, size_t envelope_plaintext_len, - uint64_t unix_ts, + uint64_t unix_ts_ms, const void* pro_backend_pubkey, size_t pro_backend_pubkey_len, char* error, @@ -1226,19 +1297,17 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( session_protocol_decoded_envelope result = {}; // Setup the pro backend pubkey - array_uc32 pro_backend_pubkey_cpp = {}; - if (pro_backend_pubkey) { - if (pro_backend_pubkey_len != sizeof(pro_backend_pubkey_cpp)) { - result.error_len_incl_null_terminator = snprintf_clamped( - error, - error_len, - "Invalid pro_backend_pubkey: Key was " - "set but was not 32 bytes, was: %zu", - pro_backend_pubkey_len) + - 1; - return result; - } - std::memcpy(pro_backend_pubkey_cpp.data(), pro_backend_pubkey, pro_backend_pubkey_len); + array_uc32_from_ptr_result pro_backend_pubkey_cpp = + array_uc32_from_ptr(pro_backend_pubkey, pro_backend_pubkey_len); + if (!pro_backend_pubkey_cpp.success) { + result.error_len_incl_null_terminator = snprintf_clamped( + error, + error_len, + "Invalid pro_backend_pubkey: Key was " + "set but was not 32 bytes, was: %zu", + pro_backend_pubkey_len) + + 1; + return result; } // Setup decryption keys and decrypt @@ -1257,8 +1326,9 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( result_cpp = decode_envelope( keys_cpp, {static_cast(envelope_plaintext), envelope_plaintext_len}, - std::chrono::sys_seconds(std::chrono::seconds(unix_ts)), - pro_backend_pubkey_cpp); + std::chrono::sys_time( + std::chrono::milliseconds(unix_ts_ms)), + pro_backend_pubkey_cpp.data); result.success = true; break; } catch (const std::exception& e) { @@ -1294,28 +1364,9 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( 1; } - result.envelope.flags = result_cpp.envelope.flags; - result.envelope.timestamp_ms = static_cast(result_cpp.envelope.timestamp.count()); - result.envelope.source_device = result_cpp.envelope.source_device; - result.envelope.server_timestamp = result_cpp.envelope.server_timestamp; - + result.envelope = envelope_from_cpp(result_cpp.envelope); if (result_cpp.pro) { - const DecodedPro& pro = *result_cpp.pro; - result.pro_status = static_cast(pro.status); - result.pro_proof.version = pro.proof.version; - result.pro_proof.expiry_unix_ts_ms = - static_cast(pro.proof.expiry_unix_ts.time_since_epoch().count()); - result.pro_features = pro.features; - - std::memcpy( - result.pro_proof.gen_index_hash.data, - pro.proof.gen_index_hash.data(), - sizeof(result.pro_proof.gen_index_hash)); - std::memcpy( - result.pro_proof.rotating_pubkey.data, - pro.proof.rotating_pubkey.data(), - sizeof(result.pro_proof.rotating_pubkey)); - std::memcpy(result.pro_proof.sig.data, pro.proof.sig.data(), sizeof(pro.proof.sig)); + result.pro = decoded_pro_from_cpp(*result_cpp.pro); } // Since we support multiple keys, if some of the keys failed but one of them succeeded, we will @@ -1324,15 +1375,6 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( if (result.success) result.error_len_incl_null_terminator = 0; - std::memcpy( - result.envelope.source.data, - result_cpp.envelope.source.data(), - sizeof(result.envelope.source.data)); - std::memcpy( - result.envelope.pro_sig.data, - result_cpp.envelope.pro_sig.data(), - sizeof(result.envelope.pro_sig.data)); - std::memcpy( result.sender_ed25519_pubkey.data, result_cpp.sender_ed25519_pubkey.data(), @@ -1352,3 +1394,70 @@ void session_protocol_decode_envelope_free(session_protocol_decoded_envelope* en *envelope = {}; } } + +LIBSESSION_C_API +session_protocol_decoded_community_message session_protocol_decode_for_community( + const void* content_or_envelope_payload, + size_t content_or_envelope_payload_len, + uint64_t unix_ts_ms, + OPTIONAL const void* pro_backend_pubkey, + size_t pro_backend_pubkey_len, + OPTIONAL char* error, + size_t error_len) { + session_protocol_decoded_community_message result = {}; + auto content_or_envelope_payload_span = std::span( + reinterpret_cast(content_or_envelope_payload), + content_or_envelope_payload_len); + auto unix_ts = + std::chrono::sys_time(std::chrono::milliseconds(unix_ts_ms)); + array_uc32_from_ptr_result pro_backend_pubkey_cpp = + array_uc32_from_ptr(pro_backend_pubkey, pro_backend_pubkey_len); + if (!pro_backend_pubkey_cpp.success) { + result.error_len_incl_null_terminator = snprintf_clamped( + error, + error_len, + "Invalid pro_backend_pubkey: Key was " + "set but was not 32 bytes, was: %zu", + pro_backend_pubkey_len) + + 1; + return result; + } + + try { + DecodedCommunityMessage decoded = decode_for_community( + content_or_envelope_payload_span, unix_ts, pro_backend_pubkey_cpp.data); + result.has_envelope = decoded.envelope.has_value(); + if (result.has_envelope) + result.envelope = envelope_from_cpp(*decoded.envelope); + + result.content_plaintext = span_u8_copy_or_throw( + decoded.content_plaintext.data(), decoded.content_plaintext.size()); + result.content_plaintext_unpadded_size = decoded.content_plaintext_unpadded_size; + result.has_pro = decoded.pro.has_value(); + if (decoded.pro_sig) + std::memcpy(result.pro_sig.data, decoded.pro_sig->data(), decoded.pro_sig->max_size()); + if (decoded.pro) + result.pro = decoded_pro_from_cpp(*decoded.pro); + result.success = true; + } catch (const std::exception& e) { + std::string error_cpp = e.what(); + result.success = false; + result.error_len_incl_null_terminator = snprintf_clamped( + error, + error_len, + "%.*s", + static_cast(error_cpp.size()), + error_cpp.data()) + + 1; + } + + return result; +} + +LIBSESSION_EXPORT void session_protocol_decode_for_community_free( + session_protocol_decoded_community_message* community_msg) { + if (community_msg) { + free(community_msg->content_plaintext.data); + *community_msg = {}; + } +} diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 8018e028..18d4617e 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -12,15 +12,6 @@ #include "utils.hpp" -struct scope_exit { - explicit scope_exit(std::function func) : cleanup(func) {} - std::function cleanup; - ~scope_exit() { - if (cleanup) - cleanup(); - } -}; - using namespace session::pro_backend; // NOTE: This is defined in main.cpp because it accepts a value from the CLI diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 35db94cb..b21c0bb6 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -156,9 +157,9 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { TestKeys keys = get_deterministic_test_keys(); // Tuesday, 12 August 2025 03:58:21 UTC - const std::chrono::milliseconds timestamp_ms = std::chrono::seconds(1754971101); - const std::chrono::sys_seconds timestamp_s = std::chrono::sys_seconds( - std::chrono::duration_cast(timestamp_ms)); + const std::chrono::sys_seconds timestamp_s = + std::chrono::sys_seconds(std::chrono::seconds(1754971101)); + const std::chrono::sys_time timestamp_ms = timestamp_s; const std::string_view data_body = "hello"; // Generate the user's Session Pro rotating key for testing encrypted payloads with Session @@ -184,7 +185,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { data_body.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - timestamp_ms.count(), + timestamp_ms.time_since_epoch().count(), &recipient_pubkey, nullptr, 0, @@ -200,7 +201,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { data_body.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - timestamp_ms.count(), + timestamp_ms.time_since_epoch().count(), &recipient_pubkey, keys.ed_sk0.data(), // Use random key, doesn't matter, we're checking size keys.ed_sk0.size(), @@ -242,7 +243,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { plaintext.size(), keys.ed_sk0.data(), keys.ed_sk0.size(), - timestamp_ms.count(), + timestamp_ms.time_since_epoch().count(), &recipient_pubkey, nullptr, 0, @@ -260,11 +261,12 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - timestamp_s.time_since_epoch().count(), + timestamp_ms.time_since_epoch().count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, sizeof(error)); + INFO("ERROR: " << error); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_encode_for_destination_free(&encrypt_result); @@ -273,10 +275,10 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { ProProof nil_proof = {}; array_uc32 nil_hash = nil_proof.hash(); bytes32 decrypt_result_pro_hash = - session_protocol_pro_proof_hash(&decrypt_result.pro_proof); - REQUIRE(decrypt_result.pro_status == + session_protocol_pro_proof_hash(&decrypt_result.pro.proof); + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_NIL); // Pro was not attached - REQUIRE(decrypt_result.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); + REQUIRE(decrypt_result.pro.features == SESSION_PROTOCOL_PRO_FEATURES_NIL); REQUIRE(std::memcmp( decrypt_result_pro_hash.data, nil_hash.data(), @@ -310,7 +312,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { sizeof(base_pro_sig.data)); session_protocol_destination base_dest = {}; - base_dest.sent_timestamp_ms = timestamp_ms.count(); + base_dest.sent_timestamp_ms = timestamp_ms.time_since_epoch().count(); base_dest.pro_rotating_ed25519_privkey = user_pro_ed_sk.data(); base_dest.pro_rotating_ed25519_privkey_len = user_pro_ed_sk.size(); @@ -346,7 +348,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &dest, error, sizeof(error)); - + INFO("ERROR: " << error); REQUIRE(encrypt_result.ciphertext.size > 0); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); session_protocol_encode_for_destination_free(&encrypt_result); @@ -377,7 +379,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - timestamp_s.time_since_epoch().count(), + timestamp_ms.time_since_epoch().count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, @@ -387,12 +389,12 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro - REQUIRE(decrypt_result.pro_status == + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached - bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); + bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro.proof); REQUIRE(std::memcmp(hash.data, protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == + REQUIRE(decrypt_result.pro.features == SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested // Verify the content can be parsed w/ protobufs @@ -406,7 +408,6 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { } SECTION("Encrypt/decrypt for contact in default namespace with Pro + features") { - std::string large_message; large_message.resize(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT + 1); @@ -437,6 +438,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { user_pro_ed_sk.size(), error, sizeof(error)); + INFO("ERROR: " << error); REQUIRE(encrypt_result.error_len_incl_null_terminator == 0); // Decrypt envelope @@ -448,22 +450,23 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - timestamp_s.time_since_epoch().count(), + timestamp_ms.time_since_epoch().count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, sizeof(error)); + INFO("ERROR: " << error); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro - REQUIRE(decrypt_result.pro_status == + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached - bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); + bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro.proof); REQUIRE(std::memcmp(hash.data, protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | + REQUIRE(decrypt_result.pro.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); // Verify the content can be parsed w/ protobufs @@ -545,14 +548,14 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - timestamp_s.time_since_epoch().count(), + timestamp_ms.time_since_epoch().count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, sizeof(error)); INFO("Decrypt for group error: " << error); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_VALID); + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_encode_for_destination_free(&encrypt_result); @@ -584,7 +587,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { &decrypt_keys, encrypt_result.ciphertext.data, encrypt_result.ciphertext.size, - timestamp_s.time_since_epoch().count(), + timestamp_ms.time_since_epoch().count(), pro_backend_ed_pk.data(), pro_backend_ed_pk.size(), error, @@ -593,13 +596,13 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); // Verify pro - REQUIRE(decrypt_result.pro_status == + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); // Pro was attached - bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro_proof); + bytes32 hash = session_protocol_pro_proof_hash(&decrypt_result.pro.proof); REQUIRE(std::memcmp( hash.data, protobuf_content.pro_proof_hash.data(), sizeof(hash.data)) == 0); - REQUIRE(decrypt_result.pro_features == + REQUIRE(decrypt_result.pro.features == SESSION_PROTOCOL_PRO_FEATURES_NIL); // No features requested // Verify the content can be parsed w/ protobufs @@ -624,7 +627,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_EXPIRED); + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_EXPIRED); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_decode_envelope_free(&decrypt_result); } @@ -643,7 +646,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_decode_envelope_free(&decrypt_result); @@ -690,7 +693,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { error, sizeof(error)); REQUIRE(decrypt_result.success); - REQUIRE(decrypt_result.pro_status == SESSION_PROTOCOL_PRO_STATUS_VALID); + REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); session_protocol_decode_envelope_free(&decrypt_result); } @@ -698,46 +701,77 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { } SECTION("Encode/decode for community (content message)") { - std::vector encoded = - encode_for_community(to_span(protobuf_content.plaintext), {}); - REQUIRE(encoded.size() % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); - - DecodedCommunityMessage decode_comm_msg = - decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); - REQUIRE(!decode_comm_msg.pro_sig); - REQUIRE(!decode_comm_msg.pro); + session_protocol_encoded_for_destination encoded = session_protocol_encode_for_community( + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), + nullptr, + 0, + error, + sizeof(error)); + scope_exit encoded_free{[&]() { session_protocol_encode_for_destination_free(&encoded); }}; + REQUIRE(encoded.ciphertext.size % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); + + session_protocol_decoded_community_message decoded = session_protocol_decode_for_community( + encoded.ciphertext.data, + encoded.ciphertext.size, + timestamp_ms.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + scope_exit decoded_free{[&]() { session_protocol_decode_for_community_free(&decoded); }}; + REQUIRE(!decoded.has_pro); } SECTION("Encode/decode for community (content message+pro)") { - std::vector encoded = - encode_for_community(to_span(protobuf_content.plaintext), user_pro_ed_sk); - REQUIRE(encoded.size() % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); - - DecodedCommunityMessage decode_comm_msg = - decode_for_community(encoded, timestamp_s, pro_backend_ed_pk); - REQUIRE(decode_comm_msg.pro_sig); - REQUIRE(decode_comm_msg.pro); - REQUIRE(decode_comm_msg.pro->status == ProStatus::Valid); + session_protocol_encoded_for_destination encoded = session_protocol_encode_for_community( + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), + user_pro_ed_sk.data(), + user_pro_ed_sk.size(), + error, + sizeof(error)); + scope_exit encoded_free{[&]() { session_protocol_encode_for_destination_free(&encoded); }}; + REQUIRE(encoded.ciphertext.size % SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING == 0); + + session_protocol_decoded_community_message decoded = session_protocol_decode_for_community( + encoded.ciphertext.data, + encoded.ciphertext.size, + timestamp_ms.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + scope_exit decoded_free{[&]() { session_protocol_decode_for_community_free(&decoded); }}; + REQUIRE(decoded.has_pro); + REQUIRE(decoded.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); } SECTION("Decode for community (envelope)") { SessionProtos::Envelope envelope; envelope.set_type(SessionProtos::Envelope_Type_SESSION_MESSAGE); - envelope.set_timestamp(timestamp_s.time_since_epoch().count()); + envelope.set_timestamp(timestamp_ms.time_since_epoch().count()); envelope.set_content( protobuf_content.plaintext_padded.data(), protobuf_content.plaintext_padded.size()); std::string envelope_plaintext = envelope.SerializeAsString(); - DecodedCommunityMessage decode_comm_msg = - decode_for_community(to_span(envelope_plaintext), timestamp_s, pro_backend_ed_pk); - REQUIRE(!decode_comm_msg.pro_sig); - REQUIRE(!decode_comm_msg.pro); + session_protocol_decoded_community_message decoded = session_protocol_decode_for_community( + envelope_plaintext.data(), + envelope_plaintext.size(), + timestamp_ms.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + scope_exit decoded_free{[&]() { session_protocol_decode_for_community_free(&decoded); }}; + REQUIRE(decoded.has_envelope); + REQUIRE(!decoded.has_pro); } SECTION("Decode for community (envelope+pro)") { SessionProtos::Envelope envelope; envelope.set_type(SessionProtos::Envelope_Type_SESSION_MESSAGE); - envelope.set_timestamp(timestamp_s.time_since_epoch().count()); + envelope.set_timestamp(timestamp_ms.time_since_epoch().count()); envelope.set_content( protobuf_content.plaintext_padded.data(), protobuf_content.plaintext_padded.size()); envelope.set_prosig( @@ -745,10 +779,81 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { protobuf_content.sig_over_plaintext_padded_with_user_pro_key.size()); std::string envelope_plaintext = envelope.SerializeAsString(); - DecodedCommunityMessage decode_comm_msg = - decode_for_community(to_span(envelope_plaintext), timestamp_s, pro_backend_ed_pk); - REQUIRE(decode_comm_msg.pro_sig); - REQUIRE(decode_comm_msg.pro); - REQUIRE(decode_comm_msg.pro->status == ProStatus::Valid); + session_protocol_decoded_community_message decoded = session_protocol_decode_for_community( + envelope_plaintext.data(), + envelope_plaintext.size(), + timestamp_ms.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + scope_exit decoded_free{[&]() { session_protocol_decode_for_community_free(&decoded); }}; + REQUIRE(decoded.has_envelope); + REQUIRE(decoded.has_pro); + REQUIRE(decoded.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); + } + + SECTION("Encode/decode for community inbox (content message)") { + const auto community_seed = + "0123456789abcdef0123456789abcdeff00baadeadb33f000000000000000000"_hexbytes; + array_uc64 community_sk = {}; + array_uc32 community_pk = {}; + crypto_sign_ed25519_seed_keypair( + community_pk.data(), community_sk.data(), community_seed.data()); + + bytes32 session_blind15_sk0 = {}; + bytes33 session_blind15_pk0 = {}; + session_blind15_pk0.data[0] = 0x15; + session_blind15_key_pair( + keys.ed_sk0.data(), + community_pk.data(), + session_blind15_pk0.data + 1, + session_blind15_sk0.data); + + bytes32 session_blind15_sk1 = {}; + bytes33 session_blind15_pk1 = {}; + session_blind15_pk1.data[0] = 0x15; + session_blind15_key_pair( + keys.ed_sk1.data(), + community_pk.data(), + session_blind15_pk1.data + 1, + session_blind15_sk1.data); + + bytes33 recipient_pubkey = session_blind15_pk1; + bytes32 community_pubkey = {}; + std::memcpy(community_pubkey.data, community_pk.data(), community_pk.size()); + + session_protocol_encoded_for_destination encoded = + session_protocol_encode_for_community_inbox( + protobuf_content.plaintext.data(), + protobuf_content.plaintext.size(), + keys.ed_sk0.data(), + keys.ed_sk0.size(), + timestamp_ms.time_since_epoch().count(), + &recipient_pubkey, + &community_pubkey, + nullptr, + 0, + error, + sizeof(error)); + scope_exit encoded_free{[&]() { session_protocol_encode_for_destination_free(&encoded); }}; + + auto [decrypted_cipher, sender_id] = session::decrypt_from_blinded_recipient( + keys.ed_sk1, + community_pk, + {session_blind15_pk0.data, sizeof(session_blind15_pk0.data)}, + {session_blind15_pk1.data, sizeof(session_blind15_pk1.data)}, + {encoded.ciphertext.data, encoded.ciphertext.size}); + + session_protocol_decoded_community_message decoded = session_protocol_decode_for_community( + decrypted_cipher.data(), + decrypted_cipher.size(), + timestamp_ms.time_since_epoch().count(), + pro_backend_ed_pk.data(), + pro_backend_ed_pk.size(), + error, + sizeof(error)); + scope_exit decoded_free{[&]() { session_protocol_decode_for_community_free(&decoded); }}; + REQUIRE(!decoded.has_pro); } } diff --git a/tests/utils.hpp b/tests/utils.hpp index ce801905..4cd8f0c7 100644 --- a/tests/utils.hpp +++ b/tests/utils.hpp @@ -190,3 +190,12 @@ static inline TestKeys get_deterministic_test_keys() { // clang-format on return result; } + +struct scope_exit { + explicit scope_exit(std::function func) : cleanup(func) {} + std::function cleanup; + ~scope_exit() { + if (cleanup) + cleanup(); + } +}; From cee1201c06c0ff5962bd283a7f081bcf3e8d4369 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 29 Sep 2025 15:35:23 +1000 Subject: [PATCH 102/171] Add missing stdint include for uint64_t in blinding.h --- include/session/blinding.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/session/blinding.h b/include/session/blinding.h index aa689e35..aafee1ed 100644 --- a/include/session/blinding.h +++ b/include/session/blinding.h @@ -5,6 +5,7 @@ extern "C" { #endif #include +#include #include "export.h" #include "platform.h" From 1a1d91c621febfb2c57c57745ea5fc35f60f2845 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 29 Sep 2025 16:46:24 +1000 Subject: [PATCH 103/171] Clarify padding requirement in interface --- include/session/session_protocol.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 00e86acf..214023c8 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -403,7 +403,7 @@ std::vector encode_for_1o1( /// /// Inputs: /// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must -/// not be already encrypted. +/// not be already encrypted and must not be padded. /// - ed25519_privkey -- The sender's libsodium-style secret key (64 bytes). Can also be passed as /// a 32-byte seed. Used to encrypt the plaintext. /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. @@ -437,7 +437,7 @@ std::vector encode_for_community_inbox( /// /// Inputs: /// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must -/// not be already encrypted. +/// not be already encrypted and must not be padded. /// - pro_rotating_ed25519_privkey -- The sender's Session Pro rotating libsodium-style secret key /// (64 bytes). Can also be passed as a 32-byte seed. Used to sign the payload. /// @@ -461,7 +461,7 @@ std::vector encode_for_community( /// /// Inputs: /// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must -/// not be already encrypted. +/// not be already encrypted and must not be padded. /// - ed25519_privkey -- The sender's libsodium-style secret key (64 bytes). Can also be passed as /// a 32-byte seed. Used to encrypt the plaintext. /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. @@ -580,8 +580,8 @@ DecodedEnvelope decode_envelope( /// associated pro metadata if there was any in the message. /// /// Inputs: -/// - `content_or_envelope_payload` -- the unencrypted content or envelope payload containing the -/// community message +/// - `content_or_envelope_payload` -- the padded unencrypted content or envelope payload containing +/// the community message /// - `unix_ts` -- pass in the current system time which is used to determine, whether or /// not the Session Pro proof has expired or not if it is in the payload. Ignored if there's no /// proof in the message. From 35fc097f4101cf61d1a651d5f84732602941cc70 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 29 Sep 2025 19:38:08 +1000 Subject: [PATCH 104/171] Fix outdated reference to pro data instead of pro config --- include/session/config/user_profile.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index a59c191e..f987671f 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -24,7 +24,7 @@ using namespace std::literals; /// M - set to 1 if blinded message request retrieval is enabled, 0 if retrieval is *disabled*, and /// omitted if the setting has not been explicitly set (or has been explicitly cleared for some /// reason). -/// s - session pro data +/// s - session pro config /// t - The unix timestamp (seconds) that the user last explicitly updated their profile information /// (automatically updates when changing `name`, `profile_pic` or `set_blinded_msgreqs`). /// P - user profile url after re-uploading (should take precedence over `p` when `T > t`). @@ -243,15 +243,15 @@ class UserProfile : public ConfigBase { bool accepts_protobuf() const override { return true; } - /// API: user_profile/UserProfile::get_pro_data + /// API: user_profile/UserProfile::get_pro_config /// /// Get the Session Pro data if any, for the current user profile. This may be missing if the - /// user does not have any entitlement to Session Pro data. + /// user does not have any entitlement to Session Pro config. /// /// Inputs: None std::optional get_pro_config() const; - /// API: user_profile/UserProfile::set_pro_data + /// API: user_profile/UserProfile::set_pro_config /// /// Attach the Session Pro components to the user profile including the proof entitling the user /// to use Session Pro features as well as the Ed25519 key pair known as the Rotating Session @@ -259,7 +259,7 @@ class UserProfile : public ConfigBase { /// /// Inputs: /// - `pro` -- The Session Pro components to assign to the current user profile. This will - /// overwrite any existing Session Pro data if it exists. No verification of `pro` is done. + /// overwrite any existing Session Pro config if it exists. No verification of `pro` is done. void set_pro_config(const ProConfig& pro); }; From 44722100ae5057a98ec5d18edde7bf1fb0a19415 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 30 Sep 2025 12:29:03 +1000 Subject: [PATCH 105/171] Update outdated doc comments for session encrypt --- include/session/session_protocol.hpp | 37 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 214023c8..661599c7 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -364,7 +364,7 @@ std::vector pad_message(std::span payload); /// Protocol. This function wraps the plaintext in the necessary structures and encrypts it for /// transmission to a single recipient. /// -/// This is a high-level convenience function that internally calls encrypt_for_destination with +/// This is a high-level convenience function that internally calls encode_for_destination with /// the appropriate Destination configuration for a 1o1 or sync message. /// /// This function throws if any input argument is invalid (e.g., incorrect key sizes). @@ -376,9 +376,10 @@ std::vector pad_message(std::span payload); /// a 32-byte seed. Used to encrypt the plaintext. /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. /// - recipient_pubkey -- The recipient's Session public key (33 bytes). -/// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro -/// rotating public key, if using Session Pro features. If provided, the corresponding proof must -/// be set in the Content protobuf. +/// - pro_rotating_ed25519_privkey -- Optional libsodium-style secret key (64 bytes) that is the +/// secret component of the user's Session Pro Proof `rotating_pubkey`. This key is authorised to +/// entitle the message with Pro features by signing it. Can also be passed as a 32-byte seed. +/// Pass in the empty span to opt-out of Pro feature entitlement. /// /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire @@ -388,7 +389,7 @@ std::vector encode_for_1o1( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, - const std::optional& pro_sig); + std::span pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_community_inbox /// @@ -396,7 +397,7 @@ std::vector encode_for_1o1( /// the plaintext in the necessary structures and encrypts it for transmission to a community inbox /// server. /// -/// This is a high-level convenience function that internally calls encrypt_for_destination with +/// This is a high-level convenience function that internally calls encode_for_destination with /// the appropriate Destination configuration for a community inbox message. /// /// This function throws if any input argument is invalid (e.g., incorrect key sizes). @@ -409,9 +410,10 @@ std::vector encode_for_1o1( /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. /// - recipient_pubkey -- The recipient's Session public key (33 bytes). /// - community_pubkey -- The community inbox server's public key (32 bytes). -/// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro -/// rotating public key, if using Session Pro features. If provided, the corresponding proof must -/// be set in the Content protobuf. +/// - pro_rotating_ed25519_privkey -- Optional libsodium-style secret key (64 bytes) that is the +/// secret component of the user's Session Pro Proof `rotating_pubkey`. This key is authorised to +/// entitle the message with Pro features by signing it. Can also be passed as a 32-byte seed. +/// Pass in the empty span to opt-out of Pro feature entitlement. /// /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire @@ -438,8 +440,10 @@ std::vector encode_for_community_inbox( /// Inputs: /// - plaintext -- The protobuf serialized payload containing the Content to be encrypted. Must /// not be already encrypted and must not be padded. -/// - pro_rotating_ed25519_privkey -- The sender's Session Pro rotating libsodium-style secret key -/// (64 bytes). Can also be passed as a 32-byte seed. Used to sign the payload. +/// - pro_rotating_ed25519_privkey -- Optional libsodium-style secret key (64 bytes) that is the +/// secret component of the user's Session Pro Proof `rotating_pubkey`. This key is authorised to +/// entitle the message with Pro features by signing it. Can also be passed as a 32-byte seed. +/// Pass in the empty span to opt-out of Pro feature entitlement. /// /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire @@ -454,7 +458,7 @@ std::vector encode_for_community( /// group's encryption key. Only v2 groups, (0x03) prefixed keys are supported. Passing a legacy /// group (0x05) prefixed key will cause the function to throw. /// -/// This is a high-level convenience function that internally calls encrypt_for_destination with +/// This is a high-level convenience function that internally calls encode_for_destination with /// the appropriate Destination configuration for a group message. /// /// This function throws if any input argument is invalid (e.g., incorrect key sizes). @@ -468,9 +472,10 @@ std::vector encode_for_community( /// - group_ed25519_pubkey -- The group's public key (33 bytes) for encryption with a 0x03 prefix /// - group_ed25519_privkey -- The group's private key (32 bytes) for groups v2 messages, typically /// the latest encryption key for the group (e.g., Keys::group_enc_key). -/// - pro_sig -- Optional signature over the unencrypted plaintext with the user's Session Pro -/// rotating public key, if using Session Pro features. If provided, the corresponding proof must -/// be set in the Content protobuf. +/// - pro_rotating_ed25519_privkey -- Optional libsodium-style secret key (64 bytes) that is the +/// secret component of the user's Session Pro Proof `rotating_pubkey`. This key is authorised to +/// entitle the message with Pro features by signing it. Can also be passed as a 32-byte seed. +/// Pass in the empty span to opt-out of Pro feature entitlement. /// /// Outputs: /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire @@ -483,7 +488,7 @@ std::vector encode_for_group( const cleared_uc32& group_ed25519_privkey, std::span pro_rotating_ed25519_privkey); -/// API: session_protocol/encrypt_for_destination +/// API: session_protocol/encode_for_destination /// /// Given an unencrypted plaintext representation of the content (i.e.: protobuf encoded stream of /// `Content`), encrypt and/or wrap the plaintext in the necessary structures for transmission on From 3a96f8c56ae04b36420fd5c505af6a4f64a90eaf Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 2 Oct 2025 15:58:24 +1000 Subject: [PATCH 106/171] Correctly handle envelope source from ios/android and parse timestamps --- include/session/session_protocol.h | 1 + src/session_protocol.cpp | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 6dc44878..9681d17e 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -96,6 +96,7 @@ enum ENVELOPE_FLAGS_ { SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE_DEVICE = 1 << 1, SESSION_PROTOCOL_ENVELOPE_FLAGS_SERVER_TIMESTAMP = 1 << 2, SESSION_PROTOCOL_ENVELOPE_FLAGS_PRO_SIG = 1 << 3, + SESSION_PROTOCOL_ENVELOPE_FLAGS_TIMESTAMP = 1 << 4, }; typedef struct session_protocol_envelope { diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 8460e160..2a14683f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -652,16 +652,39 @@ DecodedEnvelope decode_envelope( // When the type is removed, we can remove this TODO. This is just a reminder as to why we skip // over that field but it's still in the schema and still being set on the sending side. + // Parse timestamp + if (envelope.has_timestamp()) { + result.envelope.timestamp = std::chrono::milliseconds(envelope.timestamp()); + result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_TIMESTAMP; + } + // Parse source (optional) if (envelope.has_source()) { // Libsession is now responsible for creating the envelope. The only data that we send in // the source is a Session public key (see: encode_for_destination) + + // TODO: For backwards compatibility, iOS and Android does not set the source sender's + // public key for 1o1s but marks the field as present. So we accept either a 0 sized string + // or a 32 byte public key. + // + // iOS + // https://github.com/session-foundation/session-ios/blob/7dc430ed548ce844f10f9a28c69fb8ccac13d8c3/SessionMessagingKit/Sending%20%26%20Receiving/MessageSender.swift#L472 + // https://github.com/session-foundation/session-ios/blob/7dc430ed548ce844f10f9a28c69fb8ccac13d8c3/SessionMessagingKit/Utilities/MessageWrapper.swift#L56 + // + // Android + // https://github.com/session-foundation/session-android/blob/403c5f6b0e402279f25d55c0d492bdcf006608e5/app/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt#L147 + // https://github.com/session-foundation/session-android/blob/403c5f6b0e402279f25d55c0d492bdcf006608e5/app/src/main/java/org/session/libsession/messaging/utilities/MessageWrapper.kt#L40 + // + // This can be removed after a while once we want to stop supporting old clients. const std::string& source = envelope.source(); - if (source.size() != result.envelope.source.max_size()) + if (source.size() != 0 && source.size() != (result.envelope.source.max_size() * 2) /*hex*/) throw std::runtime_error(fmt::format( "Parse envelope failed, source had unexpected size ({} bytes)", source.size())); - std::memcpy(result.envelope.source.data(), source.data(), source.size()); - result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE; + + if (source.size()) { + oxenc::from_hex(source.begin(), source.end(), result.envelope.source.data()); + result.envelope.flags |= SESSION_PROTOCOL_ENVELOPE_FLAGS_SOURCE; + } } // Parse source device (optional) From 17e6cd5702a5c8847b702eacd7fe7011629c6375 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 2 Oct 2025 16:18:40 +1000 Subject: [PATCH 107/171] Verify the timestamp is decoded in unit tests --- tests/test_session_protocol.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index b21c0bb6..c127e062 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -458,6 +458,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { INFO("ERROR: " << error); REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + REQUIRE(decrypt_result.envelope.timestamp_ms == base_dest.sent_timestamp_ms); session_protocol_encode_for_destination_free(&encrypt_result); // Verify pro From 59146350f72264d0ec39a0767a569add1ddc1173 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 3 Oct 2025 16:09:31 +1000 Subject: [PATCH 108/171] Update payment provider metadata table with new required fields --- include/session/pro_backend.h | 41 ++++++++++++++++++++++++++------- include/session/pro_backend.hpp | 7 ++++++ src/pro_backend.cpp | 3 +++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index c4e8c0a7..028b3716 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -45,9 +45,17 @@ typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT, } SESSION_PRO_BACKEND_USER_PRO_STATUS; +/// Bundle of hard-coded strings that are associated with each platform for clients to use for +/// string substitution typically. This structure is stored in a global table +/// `SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA` that is can be indexed into using the +/// SESSION_PRO_BACKEND_PAYMENT_PROVIDER value directly. typedef struct session_pro_backend_payment_provider_metadata { - string8 request_refund_support_url; - string8 subscription_page_url; + string8 device; + string8 store; + string8 platform; + string8 platformAccount; + string8 refund_url; + string8 subscription_url; } session_pro_backend_payment_provider_metadata; /// The centralised list of common URLs and properties for handling payment provider specific @@ -55,16 +63,28 @@ typedef struct session_pro_backend_payment_provider_metadata { // clang-format off const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA[SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT] = { /*SESSION_PRO_PAYMENT_PROVIDER_NIL*/ { - .request_refund_support_url = string8_literal(""), - .subscription_page_url = string8_literal(""), + .device = string8_literal(""), + .store = string8_literal(""), + .platform = string8_literal(""), + .platformAccount = string8_literal(""), + .refund_url = string8_literal(""), + .subscription_url = string8_literal(""), }, /*SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE*/ { - .request_refund_support_url = string8_literal("https://support.google.com/googleplay/workflow/9813244"), - .subscription_page_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger"), + .device = string8_literal("Android"), + .store = string8_literal("Google Play Store"), + .platform = string8_literal("Google"), + .platformAccount = string8_literal("Google account"), + .refund_url = string8_literal("https://getsession.org/android-refund"), + .subscription_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger&sku=SESSION_PRO_MONTHLY"), }, /*SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE*/ { - .request_refund_support_url = string8_literal("https://support.apple.com/118223"), - .subscription_page_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions") + .device = string8_literal("iOS"), + .store = string8_literal("Apple App Store"), + .platform = string8_literal("Apple"), + .platformAccount = string8_literal("Apple account"), + .refund_url = string8_literal("https://support.apple.com/118223"), + .subscription_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions") } }; // clang-format on @@ -160,6 +180,11 @@ typedef struct session_pro_backend_pro_payment_item { uint64_t refunded_unix_ts_ms; uint64_t redeemed_unix_ts_ms; SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; + + /// Pointer to payment provider metadata. This pointer is always defined to be pointing to valid + /// memory when the structure is received through the pro_backend APIs. + const session_pro_backend_payment_provider_metadata* payment_provider_metadata; + char google_payment_token[128]; size_t google_payment_token_count; char google_order_id[128]; diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index e8f54630..6df0f36f 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -326,6 +326,12 @@ struct ProPaymentItem { /// Store front that this particular payment came from SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; + /// Strings associated with platform's payment provider from + /// `SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA`, provided for convenience. This pointer is + /// always pointing to valid memory. + const session_pro_backend_payment_provider_metadata *payment_provider_metadata = + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA; + /// When payment provider is set to Google Play Store, this is the platform-specific purchase /// token std::string google_payment_token; @@ -340,6 +346,7 @@ struct ProPaymentItem { /// When payment provider is set to iOS App Store, this is the platform-specific web line order /// ID std::string apple_web_line_order_id; + }; struct GetProStatusResponse : public ResponseHeader { diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 3200c79f..47a9c12d 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -503,6 +503,8 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { item.payment_provider = static_cast(payment_provider); + item.payment_provider_metadata = + SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA + payment_provider; } else { result.errors.push_back( fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); @@ -960,6 +962,7 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ src.redeemed_unix_ts.time_since_epoch()) .count(); dest.payment_provider = src.payment_provider; + dest.payment_provider_metadata = src.payment_provider_metadata; switch (dest.payment_provider) { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; From 0bc7787334bd8dbef1e92642628545e86e67a7aa Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 15 Oct 2025 15:10:07 +1100 Subject: [PATCH 109/171] Switch to forward declared typedefs, remove illegal number separator literal Ensure that the websocket request has dummy fields set which is required for iOS. --- include/session/pro_backend.hpp | 3 +-- include/session/session_protocol.h | 37 +++++++++++++++++++----------- include/session/types.h | 6 +++++ src/session_protocol.cpp | 3 +++ 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 6df0f36f..71406073 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -329,7 +329,7 @@ struct ProPaymentItem { /// Strings associated with platform's payment provider from /// `SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA`, provided for convenience. This pointer is /// always pointing to valid memory. - const session_pro_backend_payment_provider_metadata *payment_provider_metadata = + const session_pro_backend_payment_provider_metadata* payment_provider_metadata = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA; /// When payment provider is set to Google Play Store, this is the platform-specific purchase @@ -346,7 +346,6 @@ struct ProPaymentItem { /// When payment provider is set to iOS App Store, this is the platform-specific web line order /// ID std::string apple_web_line_order_id; - }; struct GetProStatusResponse : public ResponseHeader { diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 9681d17e..59506ab7 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -16,12 +16,12 @@ enum { /// Maximum number of UTF16 code points that a standard message can use. If the message exceeds /// this then the message must activate the higher character limit feature provided by Session /// Pro which allows messages up to 10k characters. - SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT = 2'000, + SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT = 2000, /// Maximum number of UTF16 code points that a Session Pro entitled user can send in a message. /// This is not used in the codebase, but is provided for convenience to centralise protocol /// definitions for users of the library to consume. - SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT = 10'000, + SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT = 10000, SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING = 160, }; @@ -34,10 +34,11 @@ typedef enum SESSION_PROTOCOL_PRO_STATUS { // See session::ProStatus SESSION_PROTOCOL_PRO_STATUS_EXPIRED, } SESSION_PROTOCOL_PRO_STATUS; -typedef struct session_protocol_pro_signed_message { +typedef struct session_protocol_pro_signed_message session_protocol_pro_signed_message; +struct session_protocol_pro_signed_message { span_u8 sig; span_u8 msg; -} session_protocol_pro_signed_message; +}; typedef struct session_protocol_pro_proof { uint8_t version; @@ -77,7 +78,8 @@ typedef enum SESSION_PROTOCOL_DESTINATION_TYPE { // See session::DestinationTyp SESSION_PROTOCOL_DESTINATION_TYPE_COMMUNITY, } SESSION_PROTOCOL_DESTINATION_TYPE; -typedef struct session_protocol_destination { // See session::Destination +typedef struct session_protocol_destination session_protocol_destination; +struct session_protocol_destination { // See session::Destination SESSION_PROTOCOL_DESTINATION_TYPE type; const void* pro_rotating_ed25519_privkey; size_t pro_rotating_ed25519_privkey_len; @@ -86,7 +88,7 @@ typedef struct session_protocol_destination { // See session::Destination bytes32 community_inbox_server_pubkey; bytes33 group_ed25519_pubkey; bytes32 group_ed25519_privkey; -} session_protocol_destination; +}; // Indicates which optional fields in the envelope has been populated out of the optional fields in // an envelope after it has been parsed off the wire. @@ -99,28 +101,32 @@ enum ENVELOPE_FLAGS_ { SESSION_PROTOCOL_ENVELOPE_FLAGS_TIMESTAMP = 1 << 4, }; -typedef struct session_protocol_envelope { +typedef struct session_protocol_envelope session_protocol_envelope; +struct session_protocol_envelope { SESSION_PROTOCOL_ENVELOPE_FLAGS flags; uint64_t timestamp_ms; bytes33 source; uint32_t source_device; uint64_t server_timestamp; bytes64 pro_sig; -} session_protocol_envelope; +}; -typedef struct session_protocol_decode_envelope_keys { +typedef struct session_protocol_decode_envelope_keys session_protocol_decode_envelope_keys; +struct session_protocol_decode_envelope_keys { span_u8 group_ed25519_pubkey; const span_u8* ed25519_privkeys; size_t ed25519_privkeys_len; -} session_protocol_decode_envelope_keys; +}; +typedef struct session_protocol_decoded_pro session_protocol_decoded_pro; struct session_protocol_decoded_pro { SESSION_PROTOCOL_PRO_STATUS status; session_protocol_pro_proof proof; SESSION_PROTOCOL_PRO_FEATURES features; }; -typedef struct session_protocol_decoded_envelope { +typedef struct session_protocol_decoded_envelope session_protocol_decoded_envelope; +struct session_protocol_decoded_envelope { // Indicates if the decryption was successful. If the decryption step failed and threw an // exception, this is false. bool success; @@ -130,16 +136,19 @@ typedef struct session_protocol_decoded_envelope { bytes32 sender_x25519_pubkey; session_protocol_decoded_pro pro; size_t error_len_incl_null_terminator; -} session_protocol_decoded_envelope; +}; -typedef struct session_protocol_encoded_for_destination { +typedef struct session_protocol_encoded_for_destination session_protocol_encoded_for_destination; +struct session_protocol_encoded_for_destination { // Indicates if the encryption was successful. If any step failed and threw an exception, this // is false. bool success; span_u8 ciphertext; size_t error_len_incl_null_terminator; -} session_protocol_encoded_for_destination; +}; +typedef struct session_protocol_decoded_community_message + session_protocol_decoded_community_message; struct session_protocol_decoded_community_message { bool success; bool has_envelope; diff --git a/include/session/types.h b/include/session/types.h index a9923d20..4db935e6 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -15,11 +15,13 @@ extern "C" { #endif /// C friendly buffer structure that is a pointer and length to a span of bytes. +typedef struct span_u8 span_u8; struct span_u8 { uint8_t* data; size_t size; }; +typedef struct string8 string8; struct string8 { char* data; size_t size; @@ -27,19 +29,23 @@ struct string8 { #define string8_literal(literal) {(char*)literal, sizeof(literal) - 1} +typedef struct bytes32 bytes32; struct bytes32 { uint8_t data[32]; }; +typedef struct bytes33 bytes33; struct bytes33 { uint8_t data[33]; }; +typedef struct bytes64 bytes64; struct bytes64 { uint8_t data[64]; }; /// Basic bump allocating arena +typedef struct arena_t arena_t; struct arena_t { uint8_t* data; size_t size; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 2a14683f..d5cab84e 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -462,6 +462,9 @@ static EncryptedForDestinationInternal encode_for_destination_internal( // Make request WebSocketProtos::WebSocketRequestMessage* req_msg = msg.mutable_request(); + req_msg->set_verb(""); // Required but unused on iOS + req_msg->set_path(""); // Required but unused on iOS + req_msg->set_requestid(0); // Required but unused on iOS req_msg->set_body(envelope.SerializeAsString()); // Write message as ciphertext From 5c5575ab4b3c5f41dc8ec789ba388d832c7864e6 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 15 Oct 2025 15:50:28 +1100 Subject: [PATCH 110/171] Ensure simdutf is included in the static library bundler --- external/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 56268c77..25f42b8e 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -204,3 +204,4 @@ function(simdutf_subdir) add_subdirectory(simdutf) endfunction() simdutf_subdir() +libsession_static_bundle(simdutf) From 8210d1b3c20b830151a3ab47db16fd38f1c21257 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 15 Oct 2025 15:59:20 +1100 Subject: [PATCH 111/171] Make pro rotating ed25519 span in high-level interface optional --- include/session/session_protocol.hpp | 9 +++++---- src/session_protocol.cpp | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 661599c7..90434dc5 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -389,7 +389,7 @@ std::vector encode_for_1o1( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, - std::span pro_rotating_ed25519_privkey); + std::optional> pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_community_inbox /// @@ -424,7 +424,7 @@ std::vector encode_for_community_inbox( std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const array_uc32& community_pubkey, - std::span pro_rotating_ed25519_privkey); + std::optional> pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_community /// @@ -449,7 +449,8 @@ std::vector encode_for_community_inbox( /// - Encryption result for the plaintext. The retured payload is suitable for sending on the wire /// (i.e: it has been protobuf encoded/wrapped if necessary). std::vector encode_for_community( - std::span plaintext, std::span pro_rotating_ed25519_privkey); + std::span plaintext, + std::optional> pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_group /// @@ -486,7 +487,7 @@ std::vector encode_for_group( std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, const cleared_uc32& group_ed25519_privkey, - std::span pro_rotating_ed25519_privkey); + std::optional> pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_destination /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index d5cab84e..74e46184 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -231,10 +231,11 @@ std::vector encode_for_1o1( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, - std::span pro_rotating_ed25519_privkey) { + std::optional> pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::SyncOr1o1; - dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey ? *pro_rotating_ed25519_privkey + : std::span{}; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); @@ -247,10 +248,11 @@ std::vector encode_for_community_inbox( std::chrono::milliseconds sent_timestamp, const array_uc33& recipient_pubkey, const array_uc32& community_pubkey, - std::span pro_rotating_ed25519_privkey) { + std::optional> pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::CommunityInbox; - dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey ? *pro_rotating_ed25519_privkey + : std::span{}; dest.sent_timestamp_ms = sent_timestamp; dest.recipient_pubkey = recipient_pubkey; dest.community_inbox_server_pubkey = community_pubkey; @@ -259,10 +261,12 @@ std::vector encode_for_community_inbox( } std::vector encode_for_community( - std::span plaintext, std::span pro_rotating_ed25519_privkey) { + std::span plaintext, + std::optional> pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::Community; - dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey ? *pro_rotating_ed25519_privkey + : std::span{}; std::span nil_ed25519_privkey; std::vector result = encode_for_destination(plaintext, nil_ed25519_privkey, dest); return result; @@ -274,10 +278,11 @@ std::vector encode_for_group( std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, const cleared_uc32& group_ed25519_privkey, - std::span pro_rotating_ed25519_privkey) { + std::optional> pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::Group; - dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; + dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey ? *pro_rotating_ed25519_privkey + : std::span{}; dest.sent_timestamp_ms = sent_timestamp; dest.group_ed25519_pubkey = group_ed25519_pubkey; dest.group_ed25519_privkey = group_ed25519_privkey; From c86d052007fdb3360b95e0c8a9415189407a01a0 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 15 Oct 2025 16:30:37 +1100 Subject: [PATCH 112/171] Disambiguate a group ed25519 privkey from the pubkey arg by labelling it 'enc' --- include/session/session_encrypt.h | 7 ++++--- include/session/session_encrypt.hpp | 9 +++++---- include/session/session_protocol.h | 6 +++--- include/session/session_protocol.hpp | 8 ++++---- src/session_encrypt.cpp | 14 +++++++------- src/session_protocol.cpp | 19 ++++++++++--------- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index 5e062905..1efecf93 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -93,7 +93,8 @@ typedef struct session_encrypt_group_message { /// - `user_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte /// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey /// - `group_ed25519_pubkey` -- the 32 byte public key of the group -/// - `group_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte +/// - `group_ed25519_enc_privkey` -- The group's private key (32 bytes) for groups v2 messages, +/// typically the latest encryption key for the group (e.g., groups_keys_group_enc_key). /// libsodium secret key /// - `plaintext` -- the binary message to encrypt. /// - `compress` -- can be specified as `false` to forcibly disable compression. Normally @@ -126,8 +127,8 @@ LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( size_t user_ed25519_privkey_len, const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char* group_ed25519_privkey, - size_t group_ed25519_privkey_len, + const unsigned char* group_ed25519_enc_privkey, + size_t group_ed25519_enc_privkey_len, const unsigned char* plaintext, size_t plaintext_len, bool compress, diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index 78d23528..108778ce 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -165,9 +165,10 @@ static constexpr size_t GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE = 1'000'000; /// Inputs: /// - `user_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte /// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey -/// - `group_ed25519_pubkey` -- the 32 byte public key of the group -/// - `group_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte -/// libsodium secret key +/// - `group_ed25519_pubkey` -- The 32 byte public key of the group +/// - group_ed25519_enc_privkey -- The group's private key (32 bytes or 64-byte libsodium key) for +/// groups v2 messages, typically the latest encryption key for the group (e.g., +/// Keys::group_enc_key). /// - `plaintext` -- the binary message to encrypt. /// - `compress` -- can be specified as `false` to forcibly disable compression. Normally /// omitted, to use compression if and only if it reduces the size. @@ -180,7 +181,7 @@ static constexpr size_t GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE = 1'000'000; std::vector encrypt_for_group( std::span user_ed25519_privkey, std::span group_ed25519_pubkey, - std::span group_ed25519_privkey, + std::span group_ed25519_enc_privkey, std::span plaintext, bool compress, size_t padding); diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 59506ab7..4c58fa27 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -87,7 +87,7 @@ struct session_protocol_destination { // See session::Destination uint64_t sent_timestamp_ms; bytes32 community_inbox_server_pubkey; bytes33 group_ed25519_pubkey; - bytes32 group_ed25519_privkey; + bytes32 group_ed25519_enc_privkey; }; // Indicates which optional fields in the envelope has been populated out of the optional fields in @@ -510,7 +510,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community( /// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). /// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. /// - `group_ed25519_pubkey` -- The group's public key (33 bytes) for encryption with a 0x03 prefix. -/// - `group_ed25519_privkey` -- The group's private key (32 bytes) for groups v2 messages, +/// - `group_ed25519_enc_privkey` -- The group's private key (32 bytes) for groups v2 messages, /// typically the latest encryption key for the group (e.g., Keys::group_enc_key). /// - `pro_rotating_ed25519_privkey` -- Optional rotating Session Pro Ed25519 key (64-bytes or /// 32-byte seed) to sign the encoded content if you wish to entitle the message to Session Pro. @@ -546,7 +546,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* group_ed25519_pubkey, - const bytes32* group_ed25519_privkey, + const bytes32* group_ed25519_enc_privkey, OPTIONAL const void* pro_rotating_ed25519_privkey, size_t pro_rotating_ed25519_privkey_len, OPTIONAL char* error, diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 90434dc5..766875b4 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -210,7 +210,7 @@ struct Destination { // When type => Group: Set the private key of the group for groups v2 messages. Typically // the latest encryption key for the group, e.g: `Keys::group_enc_key` or // `groups_keys_group_enc_key` - cleared_uc32 group_ed25519_privkey; + cleared_uc32 group_ed25519_enc_privkey; }; struct Envelope { @@ -471,8 +471,8 @@ std::vector encode_for_community( /// a 32-byte seed. Used to encrypt the plaintext. /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. /// - group_ed25519_pubkey -- The group's public key (33 bytes) for encryption with a 0x03 prefix -/// - group_ed25519_privkey -- The group's private key (32 bytes) for groups v2 messages, typically -/// the latest encryption key for the group (e.g., Keys::group_enc_key). +/// - group_ed25519_enc_privkey -- The group's private key (32 bytes) for groups v2 messages, +/// typically the latest encryption key for the group (e.g., Keys::group_enc_key). /// - pro_rotating_ed25519_privkey -- Optional libsodium-style secret key (64 bytes) that is the /// secret component of the user's Session Pro Proof `rotating_pubkey`. This key is authorised to /// entitle the message with Pro features by signing it. Can also be passed as a 32-byte seed. @@ -486,7 +486,7 @@ std::vector encode_for_group( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, - const cleared_uc32& group_ed25519_privkey, + const cleared_uc32& group_ed25519_enc_privkey, std::optional> pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_destination diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 2317281c..9eff3f55 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -369,7 +369,7 @@ static constexpr size_t GROUPS_ENCRYPT_OVERHEAD = std::vector encrypt_for_group( std::span user_ed25519_privkey, std::span group_ed25519_pubkey, - std::span group_ed25519_privkey, + std::span group_ed25519_enc_privkey, std::span plaintext, bool compress, size_t padding) { @@ -391,8 +391,8 @@ std::vector encrypt_for_group( throw std::invalid_argument{"Invalid user_ed25519_privkey: expected 32 or 64 bytes"}; } - if (group_ed25519_privkey.size() != 32 && group_ed25519_privkey.size() != 64) - throw std::invalid_argument{"Invalid group_ed25519_privkey: expected 32 or 64 bytes"}; + if (group_ed25519_enc_privkey.size() != 32 && group_ed25519_enc_privkey.size() != 64) + throw std::invalid_argument{"Invalid group_ed25519_enc_privkey: expected 32 or 64 bytes"}; if (group_ed25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) throw std::invalid_argument{"Invalid group_ed25519_pubkey: expected 32 bytes"}; @@ -470,7 +470,7 @@ std::vector encrypt_for_group( 0, nullptr, nonce.data(), - group_ed25519_privkey.data())) + group_ed25519_enc_privkey.data())) throw std::runtime_error{"Encryption failed"}; return ciphertext; @@ -1119,8 +1119,8 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( size_t user_ed25519_privkey_len, const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char* group_ed25519_privkey, - size_t group_ed25519_privkey_len, + const unsigned char* group_ed25519_enc_privkey, + size_t group_ed25519_enc_privkey_len, const unsigned char* plaintext, size_t plaintext_len, bool compress, @@ -1132,7 +1132,7 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( std::vector result_cpp = encrypt_for_group( {user_ed25519_privkey, user_ed25519_privkey_len}, {group_ed25519_pubkey, group_ed25519_pubkey_len}, - {group_ed25519_privkey, group_ed25519_privkey_len}, + {group_ed25519_enc_privkey, group_ed25519_enc_privkey_len}, {plaintext, plaintext_len}, compress, padding); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 74e46184..4fe3dca7 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -277,7 +277,7 @@ std::vector encode_for_group( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, - const cleared_uc32& group_ed25519_privkey, + const cleared_uc32& group_ed25519_enc_privkey, std::optional> pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::Group; @@ -285,7 +285,7 @@ std::vector encode_for_group( : std::span{}; dest.sent_timestamp_ms = sent_timestamp; dest.group_ed25519_pubkey = group_ed25519_pubkey; - dest.group_ed25519_privkey = group_ed25519_privkey; + dest.group_ed25519_enc_privkey = group_ed25519_enc_privkey; std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); return result; } @@ -349,7 +349,7 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::chrono::milliseconds dest_sent_timestamp_ms, std::span dest_community_inbox_server_pubkey, std::span dest_group_ed25519_pubkey, - std::span dest_group_ed25519_privkey, + std::span dest_group_ed25519_enc_privkey, UseMalloc use_malloc) { // The following arguments are passed in from structs with fixed-sized arrays so we expect the // sizes to be correct. It being wrong would be a development error @@ -359,7 +359,8 @@ static EncryptedForDestinationInternal encode_for_destination_internal( assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); - assert(dest_group_ed25519_privkey.size() == 32 || dest_group_ed25519_privkey.size() == 64); + assert(dest_group_ed25519_enc_privkey.size() == 32 || + dest_group_ed25519_enc_privkey.size() == 64); bool is_group = dest_type == DestinationType::Group; bool is_1o1 = dest_type == DestinationType::SyncOr1o1; @@ -449,7 +450,7 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::vector ciphertext = encrypt_for_group( ed25519_privkey, dest_group_ed25519_pubkey, - dest_group_ed25519_privkey, + dest_group_ed25519_enc_privkey, to_span(bytes), /*compress*/ true, /*padding*/ 256); @@ -587,7 +588,7 @@ std::vector encode_for_destination( /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, /*dest_community_inbox_server_pubkey=*/dest.community_inbox_server_pubkey, /*dest_group_ed25519_pubkey=*/dest.group_ed25519_pubkey, - /*dest_group_ed25519_privkey=*/dest.group_ed25519_privkey, + /*dest_group_ed25519_enc_privkey=*/dest.group_ed25519_enc_privkey, /*use_malloc=*/UseMalloc::No); std::vector result = std::move(result_internal.ciphertext_cpp); @@ -1232,7 +1233,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* group_ed25519_pubkey, - const bytes32* group_ed25519_privkey, + const bytes32* group_ed25519_enc_privkey, const void* pro_rotating_ed25519_privkey, size_t pro_rotating_ed25519_privkey_len, char* error, @@ -1243,7 +1244,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; dest.pro_rotating_ed25519_privkey_len = pro_rotating_ed25519_privkey_len; dest.group_ed25519_pubkey = *group_ed25519_pubkey; - dest.group_ed25519_privkey = *group_ed25519_privkey; + dest.group_ed25519_enc_privkey = *group_ed25519_enc_privkey; dest.sent_timestamp_ms = sent_timestamp_ms; session_protocol_encoded_for_destination result = session_protocol_encode_for_destination( @@ -1286,7 +1287,7 @@ LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encod /*dest_community_inbox_server_pubkey=*/ dest->community_inbox_server_pubkey.data, /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey.data, - /*dest_group_ed25519_privkey=*/dest->group_ed25519_privkey.data, + /*dest_group_ed25519_enc_privkey=*/dest->group_ed25519_enc_privkey.data, /*use_malloc=*/UseMalloc::Yes); result = { From a3c36f24e46083cbdf1f4515cb96eb2585a51933 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 16 Oct 2025 13:39:03 +1100 Subject: [PATCH 113/171] Groups v2 key is not ed25519, it's a xchacha20-poly1305 aead construction key --- include/session/config/groups/keys.h | 3 --- include/session/session_encrypt.h | 8 ++++---- include/session/session_encrypt.hpp | 7 +++---- include/session/session_protocol.h | 8 ++++---- include/session/session_protocol.hpp | 13 ++++++------- src/session_encrypt.cpp | 14 +++++++------- src/session_protocol.cpp | 19 +++++++++---------- 7 files changed, 33 insertions(+), 39 deletions(-) diff --git a/include/session/config/groups/keys.h b/include/session/config/groups/keys.h index 102436b1..bba564af 100644 --- a/include/session/config/groups/keys.h +++ b/include/session/config/groups/keys.h @@ -140,9 +140,6 @@ LIBSESSION_EXPORT const unsigned char* groups_keys_get_key(const config_group_ke /// /// 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 diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index 1efecf93..a08c4612 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -93,8 +93,8 @@ typedef struct session_encrypt_group_message { /// - `user_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte /// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey /// - `group_ed25519_pubkey` -- the 32 byte public key of the group -/// - `group_ed25519_enc_privkey` -- The group's private key (32 bytes) for groups v2 messages, -/// typically the latest encryption key for the group (e.g., groups_keys_group_enc_key). +/// - `group_enc_key` -- The group's encryption key (32 bytes) for groups v2 messages, typically the +/// latest key for the group (e.g., groups_keys_group_enc_key). /// libsodium secret key /// - `plaintext` -- the binary message to encrypt. /// - `compress` -- can be specified as `false` to forcibly disable compression. Normally @@ -127,8 +127,8 @@ LIBSESSION_EXPORT session_encrypt_group_message session_encrypt_for_group( size_t user_ed25519_privkey_len, const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char* group_ed25519_enc_privkey, - size_t group_ed25519_enc_privkey_len, + const unsigned char* group_enc_key, + size_t group_enc_key_len, const unsigned char* plaintext, size_t plaintext_len, bool compress, diff --git a/include/session/session_encrypt.hpp b/include/session/session_encrypt.hpp index 108778ce..7d528088 100644 --- a/include/session/session_encrypt.hpp +++ b/include/session/session_encrypt.hpp @@ -166,9 +166,8 @@ static constexpr size_t GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE = 1'000'000; /// - `user_ed25519_privkey` -- the private key of the user. Can be a 32-byte seed, or a 64-byte /// libsodium secret key. The latter is a bit faster as it doesn't have to re-compute the pubkey /// - `group_ed25519_pubkey` -- The 32 byte public key of the group -/// - group_ed25519_enc_privkey -- The group's private key (32 bytes or 64-byte libsodium key) for -/// groups v2 messages, typically the latest encryption key for the group (e.g., -/// Keys::group_enc_key). +/// - group_enc_key -- The group's encryption key (32 bytes or 64-byte libsodium key) for groups v2 +/// messages, typically the latest key for the group (e.g., Keys::group_enc_key). /// - `plaintext` -- the binary message to encrypt. /// - `compress` -- can be specified as `false` to forcibly disable compression. Normally /// omitted, to use compression if and only if it reduces the size. @@ -181,7 +180,7 @@ static constexpr size_t GROUPS_MAX_PLAINTEXT_MESSAGE_SIZE = 1'000'000; std::vector encrypt_for_group( std::span user_ed25519_privkey, std::span group_ed25519_pubkey, - std::span group_ed25519_enc_privkey, + std::span group_enc_key, std::span plaintext, bool compress, size_t padding); diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 4c58fa27..914396d2 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -87,7 +87,7 @@ struct session_protocol_destination { // See session::Destination uint64_t sent_timestamp_ms; bytes32 community_inbox_server_pubkey; bytes33 group_ed25519_pubkey; - bytes32 group_ed25519_enc_privkey; + bytes32 group_enc_key; }; // Indicates which optional fields in the envelope has been populated out of the optional fields in @@ -510,8 +510,8 @@ session_protocol_encoded_for_destination session_protocol_encode_for_community( /// - `ed25519_privkey_len` -- The length of the ed25519_privkey buffer in bytes (32 or 64). /// - `sent_timestamp_ms` -- The timestamp to assign to the message envelope, in milliseconds. /// - `group_ed25519_pubkey` -- The group's public key (33 bytes) for encryption with a 0x03 prefix. -/// - `group_ed25519_enc_privkey` -- The group's private key (32 bytes) for groups v2 messages, -/// typically the latest encryption key for the group (e.g., Keys::group_enc_key). +/// - `group_enc_key` -- The group's encryption key (32 bytes) for groups v2 messages, typically the +// latest key for the group (e.g., Keys::group_enc_key). /// - `pro_rotating_ed25519_privkey` -- Optional rotating Session Pro Ed25519 key (64-bytes or /// 32-byte seed) to sign the encoded content if you wish to entitle the message to Session Pro. /// If provided, the corresponding proof must be set in the `Content`. The signature must not be @@ -546,7 +546,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* group_ed25519_pubkey, - const bytes32* group_ed25519_enc_privkey, + const bytes32* group_enc_key, OPTIONAL const void* pro_rotating_ed25519_privkey, size_t pro_rotating_ed25519_privkey_len, OPTIONAL char* error, diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 766875b4..8f1d2192 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -207,10 +207,9 @@ struct Destination { // `group_pubkey` to encrypt the message for. array_uc33 group_ed25519_pubkey; - // When type => Group: Set the private key of the group for groups v2 messages. Typically - // the latest encryption key for the group, e.g: `Keys::group_enc_key` or - // `groups_keys_group_enc_key` - cleared_uc32 group_ed25519_enc_privkey; + // When type => Group: Set the encryption key of the group for groups v2 messages. Typically + // the latest key for the group, e.g: `Keys::group_enc_key` or `groups_keys_group_enc_key` + cleared_uc32 group_enc_key; }; struct Envelope { @@ -471,8 +470,8 @@ std::vector encode_for_community( /// a 32-byte seed. Used to encrypt the plaintext. /// - sent_timestamp -- The timestamp to assign to the message envelope, in milliseconds. /// - group_ed25519_pubkey -- The group's public key (33 bytes) for encryption with a 0x03 prefix -/// - group_ed25519_enc_privkey -- The group's private key (32 bytes) for groups v2 messages, -/// typically the latest encryption key for the group (e.g., Keys::group_enc_key). +/// - group_enc_key -- The group's encryption key (32 bytes) for groups v2 messages, typically the +/// latest key for the group (e.g., Keys::group_enc_key). /// - pro_rotating_ed25519_privkey -- Optional libsodium-style secret key (64 bytes) that is the /// secret component of the user's Session Pro Proof `rotating_pubkey`. This key is authorised to /// entitle the message with Pro features by signing it. Can also be passed as a 32-byte seed. @@ -486,7 +485,7 @@ std::vector encode_for_group( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, - const cleared_uc32& group_ed25519_enc_privkey, + const cleared_uc32& group_enc_key, std::optional> pro_rotating_ed25519_privkey); /// API: session_protocol/encode_for_destination diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 9eff3f55..3246f8b8 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -369,7 +369,7 @@ static constexpr size_t GROUPS_ENCRYPT_OVERHEAD = std::vector encrypt_for_group( std::span user_ed25519_privkey, std::span group_ed25519_pubkey, - std::span group_ed25519_enc_privkey, + std::span group_enc_key, std::span plaintext, bool compress, size_t padding) { @@ -391,8 +391,8 @@ std::vector encrypt_for_group( throw std::invalid_argument{"Invalid user_ed25519_privkey: expected 32 or 64 bytes"}; } - if (group_ed25519_enc_privkey.size() != 32 && group_ed25519_enc_privkey.size() != 64) - throw std::invalid_argument{"Invalid group_ed25519_enc_privkey: expected 32 or 64 bytes"}; + if (group_enc_key.size() != 32 && group_enc_key.size() != 64) + throw std::invalid_argument{"Invalid group_enc_key: expected 32 or 64 bytes"}; if (group_ed25519_pubkey.size() != crypto_sign_ed25519_PUBLICKEYBYTES) throw std::invalid_argument{"Invalid group_ed25519_pubkey: expected 32 bytes"}; @@ -470,7 +470,7 @@ std::vector encrypt_for_group( 0, nullptr, nonce.data(), - group_ed25519_enc_privkey.data())) + group_enc_key.data())) throw std::runtime_error{"Encryption failed"}; return ciphertext; @@ -1119,8 +1119,8 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( size_t user_ed25519_privkey_len, const unsigned char* group_ed25519_pubkey, size_t group_ed25519_pubkey_len, - const unsigned char* group_ed25519_enc_privkey, - size_t group_ed25519_enc_privkey_len, + const unsigned char* group_enc_key, + size_t group_enc_key_len, const unsigned char* plaintext, size_t plaintext_len, bool compress, @@ -1132,7 +1132,7 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( std::vector result_cpp = encrypt_for_group( {user_ed25519_privkey, user_ed25519_privkey_len}, {group_ed25519_pubkey, group_ed25519_pubkey_len}, - {group_ed25519_enc_privkey, group_ed25519_enc_privkey_len}, + {group_enc_key, group_enc_key_len}, {plaintext, plaintext_len}, compress, padding); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 4fe3dca7..7880e2f7 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -277,7 +277,7 @@ std::vector encode_for_group( std::span ed25519_privkey, std::chrono::milliseconds sent_timestamp, const array_uc33& group_ed25519_pubkey, - const cleared_uc32& group_ed25519_enc_privkey, + const cleared_uc32& group_enc_key, std::optional> pro_rotating_ed25519_privkey) { Destination dest = {}; dest.type = DestinationType::Group; @@ -285,7 +285,7 @@ std::vector encode_for_group( : std::span{}; dest.sent_timestamp_ms = sent_timestamp; dest.group_ed25519_pubkey = group_ed25519_pubkey; - dest.group_ed25519_enc_privkey = group_ed25519_enc_privkey; + dest.group_enc_key = group_enc_key; std::vector result = encode_for_destination(plaintext, ed25519_privkey, dest); return result; } @@ -349,7 +349,7 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::chrono::milliseconds dest_sent_timestamp_ms, std::span dest_community_inbox_server_pubkey, std::span dest_group_ed25519_pubkey, - std::span dest_group_ed25519_enc_privkey, + std::span dest_group_enc_key, UseMalloc use_malloc) { // The following arguments are passed in from structs with fixed-sized arrays so we expect the // sizes to be correct. It being wrong would be a development error @@ -359,8 +359,7 @@ static EncryptedForDestinationInternal encode_for_destination_internal( assert(dest_recipient_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_community_inbox_server_pubkey.size() == crypto_sign_ed25519_PUBLICKEYBYTES); assert(dest_group_ed25519_pubkey.size() == 1 + crypto_sign_ed25519_PUBLICKEYBYTES); - assert(dest_group_ed25519_enc_privkey.size() == 32 || - dest_group_ed25519_enc_privkey.size() == 64); + assert(dest_group_enc_key.size() == 32 || dest_group_enc_key.size() == 64); bool is_group = dest_type == DestinationType::Group; bool is_1o1 = dest_type == DestinationType::SyncOr1o1; @@ -450,7 +449,7 @@ static EncryptedForDestinationInternal encode_for_destination_internal( std::vector ciphertext = encrypt_for_group( ed25519_privkey, dest_group_ed25519_pubkey, - dest_group_ed25519_enc_privkey, + dest_group_enc_key, to_span(bytes), /*compress*/ true, /*padding*/ 256); @@ -588,7 +587,7 @@ std::vector encode_for_destination( /*dest_sent_timestamp_ms=*/dest.sent_timestamp_ms, /*dest_community_inbox_server_pubkey=*/dest.community_inbox_server_pubkey, /*dest_group_ed25519_pubkey=*/dest.group_ed25519_pubkey, - /*dest_group_ed25519_enc_privkey=*/dest.group_ed25519_enc_privkey, + /*dest_group_enc_key=*/dest.group_enc_key, /*use_malloc=*/UseMalloc::No); std::vector result = std::move(result_internal.ciphertext_cpp); @@ -1233,7 +1232,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( size_t ed25519_privkey_len, uint64_t sent_timestamp_ms, const bytes33* group_ed25519_pubkey, - const bytes32* group_ed25519_enc_privkey, + const bytes32* group_enc_key, const void* pro_rotating_ed25519_privkey, size_t pro_rotating_ed25519_privkey_len, char* error, @@ -1244,7 +1243,7 @@ session_protocol_encoded_for_destination session_protocol_encode_for_group( dest.pro_rotating_ed25519_privkey = pro_rotating_ed25519_privkey; dest.pro_rotating_ed25519_privkey_len = pro_rotating_ed25519_privkey_len; dest.group_ed25519_pubkey = *group_ed25519_pubkey; - dest.group_ed25519_enc_privkey = *group_ed25519_enc_privkey; + dest.group_enc_key = *group_enc_key; dest.sent_timestamp_ms = sent_timestamp_ms; session_protocol_encoded_for_destination result = session_protocol_encode_for_destination( @@ -1287,7 +1286,7 @@ LIBSESSION_C_API session_protocol_encoded_for_destination session_protocol_encod /*dest_community_inbox_server_pubkey=*/ dest->community_inbox_server_pubkey.data, /*dest_group_ed25519_pubkey=*/dest->group_ed25519_pubkey.data, - /*dest_group_ed25519_enc_privkey=*/dest->group_ed25519_enc_privkey.data, + /*dest_group_enc_key=*/dest->group_enc_key.data, /*use_malloc=*/UseMalloc::Yes); result = { From 1bdc4e91256086901e6890cb62f517634890fa29 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 16 Oct 2025 13:48:32 +1100 Subject: [PATCH 114/171] Update envelop decode keys reference to ed25519 privkeys --- include/session/session_protocol.h | 4 ++-- include/session/session_protocol.hpp | 10 +++++----- src/session_protocol.cpp | 14 +++++++------- tests/test_session_protocol.cpp | 28 ++++++++++++++-------------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 914396d2..c9af003f 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -114,8 +114,8 @@ struct session_protocol_envelope { typedef struct session_protocol_decode_envelope_keys session_protocol_decode_envelope_keys; struct session_protocol_decode_envelope_keys { span_u8 group_ed25519_pubkey; - const span_u8* ed25519_privkeys; - size_t ed25519_privkeys_len; + const span_u8* decrypt_keys; + size_t decrypt_keys_len; }; typedef struct session_protocol_decoded_pro session_protocol_decoded_pro; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 8f1d2192..1ef4de29 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -298,15 +298,15 @@ struct DecodeEnvelopeKey { // encrypted and must be decrypted by the group keys associated with it (of which there may be // many candidate keys depending on how many times the group has been rekeyed). It's recommended // to pass `Keys::group_keys()` or in the C API use the `groups_keys_size` and - // `group_keys_get_key` combo to retrieve the keys to attempt to use to decrypt this message. + // `group_keys_get_keys` combo to retrieve the keys to attempt to use to decrypt this message. // // If `group_ed25519_pubkey` is _not_ set then this function assumes the envelope is unencrypted // but the content is encrypted (e.g.: 1o1 and legacy group messages). The function will attempt // to decrypt the envelope's contents with the given keys. Typically in these cases you will - // pass exactly 1 key for decryption but this function makes no pre-existing assumptions on the - // number of keys and will attempt all given keys specified regardless until it finds one that - // successfully decrypts the envelope contents. - std::span> ed25519_privkeys; + // pass exactly 1 ed25519 private key for decryption but this function makes no pre + // existing assumptions on the number of keys and will attempt all given keys specified + // regardless until it finds one that successfully decrypts the envelope contents. + std::span> decrypt_keys; }; /// API: session_protocol/pro_features_for_utf8 diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 7880e2f7..b558c426 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -611,7 +611,7 @@ DecodedEnvelope decode_envelope( if (keys.group_ed25519_pubkey) { // Decrypt using the keys DecryptGroupMessage decrypt = decrypt_group_message( - keys.ed25519_privkeys, *keys.group_ed25519_pubkey, envelope_plaintext); + keys.decrypt_keys, *keys.group_ed25519_pubkey, envelope_plaintext); if (decrypt.session_id.size() != ((crypto_sign_ed25519_PUBLICKEYBYTES + 1) * 2)) throw std::runtime_error{fmt::format( @@ -725,7 +725,7 @@ DecodedEnvelope decode_envelope( bool decrypt_success = false; std::vector content_plaintext; std::vector sender_ed25519_pubkey; - for (const auto& privkey_it : keys.ed25519_privkeys) { + for (const auto& privkey_it : keys.decrypt_keys) { try { std::tie(content_plaintext, sender_ed25519_pubkey) = session::decrypt_incoming(privkey_it, to_span(content)); @@ -739,7 +739,7 @@ DecodedEnvelope decode_envelope( if (!decrypt_success) { throw std::runtime_error{fmt::format( "Envelope content decryption failed, tried {} key(s)", - keys.ed25519_privkeys.size())}; + keys.decrypt_keys.size())}; } // Strip padding from content @@ -1349,10 +1349,10 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( } DecodedEnvelope result_cpp = {}; - for (size_t index = 0; index < keys->ed25519_privkeys_len; index++) { + for (size_t index = 0; index < keys->decrypt_keys_len; index++) { std::span key = { - keys->ed25519_privkeys[index].data, keys->ed25519_privkeys[index].size}; - keys_cpp.ed25519_privkeys = {&key, 1}; + keys->decrypt_keys[index].data, keys->decrypt_keys[index].size}; + keys_cpp.decrypt_keys = {&key, 1}; try { result_cpp = decode_envelope( keys_cpp, @@ -1374,7 +1374,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( } } - if (keys->ed25519_privkeys_len == 0) { + if (keys->decrypt_keys_len == 0) { result.error_len_incl_null_terminator = snprintf_clamped(error, error_len, "No keys ed25519_privkeys were provided") + 1; } diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index c127e062..8e7ce863 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -255,8 +255,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; session_protocol_decode_envelope_keys decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; + decrypt_keys.decrypt_keys = &key; + decrypt_keys.decrypt_keys_len = 1; session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, @@ -373,8 +373,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; session_protocol_decode_envelope_keys decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; + decrypt_keys.decrypt_keys = &key; + decrypt_keys.decrypt_keys_len = 1; session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, @@ -444,8 +444,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Decrypt envelope span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; session_protocol_decode_envelope_keys decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; + decrypt_keys.decrypt_keys = &key; + decrypt_keys.decrypt_keys_len = 1; session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, encrypt_result.ciphertext.data, @@ -540,8 +540,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { span_u8 key = {group_v2_sk.data(), group_v2_sk.size()}; session_protocol_decode_envelope_keys decrypt_keys = {}; decrypt_keys.group_ed25519_pubkey = {group_v2_pk.data(), group_v2_pk.size()}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; + decrypt_keys.decrypt_keys = &key; + decrypt_keys.decrypt_keys_len = 1; // TODO: Finish setting up a group so we can check the decrypted result for now this will // throw because the keys aren't setup correctly. @@ -581,8 +581,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { // Decrypt span_u8 key = {keys.ed_sk1.data(), keys.ed_sk1.size()}; session_protocol_decode_envelope_keys decrypt_keys = {}; - decrypt_keys.ed25519_privkeys = &key; - decrypt_keys.ed25519_privkeys_len = 1; + decrypt_keys.decrypt_keys = &key; + decrypt_keys.decrypt_keys_len = 1; { session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &decrypt_keys, @@ -657,8 +657,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { span_u8 bad_key = {keys.ed_sk0.data(), keys.ed_sk0.size()}; { session_protocol_decode_envelope_keys bad_decrypt_keys = {}; - bad_decrypt_keys.ed25519_privkeys = &bad_key; - bad_decrypt_keys.ed25519_privkeys_len = 1; + bad_decrypt_keys.decrypt_keys = &bad_key; + bad_decrypt_keys.decrypt_keys_len = 1; session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &bad_decrypt_keys, encrypt_result.ciphertext.data, @@ -680,8 +680,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { { auto key_list = std::array{bad_key, key}; session_protocol_decode_envelope_keys multi_decrypt_keys = {}; - multi_decrypt_keys.ed25519_privkeys = key_list.data(); - multi_decrypt_keys.ed25519_privkeys_len = key_list.size(); + multi_decrypt_keys.decrypt_keys = key_list.data(); + multi_decrypt_keys.decrypt_keys_len = key_list.size(); session_protocol_decoded_envelope decrypt_result = session_protocol_decode_envelope( &multi_decrypt_keys, encrypt_result.ciphertext.data, From 2e5c1eefd9579c0ecbd80075a708bfc4b2aa0668 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 16 Oct 2025 14:10:48 +1100 Subject: [PATCH 115/171] Add get bulk group enc keys in the C api --- include/session/config/groups/keys.h | 25 ++++++++++++++++++++++++- src/config/groups/keys.cpp | 16 ++++++++++++++++ tests/test_group_keys.cpp | 22 ++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/include/session/config/groups/keys.h b/include/session/config/groups/keys.h index bba564af..7e7217a3 100644 --- a/include/session/config/groups/keys.h +++ b/include/session/config/groups/keys.h @@ -109,7 +109,7 @@ LIBSESSION_EXPORT size_t groups_keys_size(const config_group_keys* conf); /// API: groups/groups_keys_get_key /// /// Accesses the Nth encryption key, ordered from most-to-least recent starting from index 0. -/// Calling this with 0 thus returns the most-current key (which is also the current _en_cryption +/// Calling this with 0 thus returns the most-current key (which is also the current encryption /// key). /// /// This function is not particularly efficient and is not typically needed except for diagnostics: @@ -133,6 +133,29 @@ 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_get_keys +/// +/// Retrieve multiple keys for the group consisting of [offset, offset + dest_size). This function +/// clamps the `offset` and `dest_size` such that no out-of-bounds reads are executed. See +/// `groups_keys_get_key` for more information on semantics provided by this function. +/// +/// The returned pointer points at a 32-byte binary value containing the key; it should be copied or +/// used at once as it may not remain valid past other calls to the keys object. It should *not* be +/// freed or modified. +/// +/// Inputs: +/// - `conf` -- the groups config object +/// - `offset` -- the offset to retrieve keys for, ordered from most-to-least recent starting from +/// offset 0 (e.g. offset=0; dest_size=1, returns the most-current key) +/// - `dest` -- the buffer to write the loaded keys into +/// - `dest_size` -- the maximum number of keys that can be written into the buffer +/// +/// Outputs: +/// - `size_t` the number of keys that were written to the buffer. This can be less than the +/// `dest_size` if the user requested a range of keys that is smaller than the given buffer. +LIBSESSION_EXPORT size_t groups_keys_group_get_keys( + const config_group_keys* conf, size_t offset, span_u8* dest, size_t dest_size); + /// API: groups/groups_keys_group_enc_key /// /// Accesses the current encryption key: that is, the most current group decryption key. Returns the diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index a09c8d88..3abb2162 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -1364,6 +1364,22 @@ LIBSESSION_C_API const unsigned char* groups_keys_get_key(const config_group_key return keys[N].data(); } +LIBSESSION_C_API size_t groups_keys_group_get_keys( + const config_group_keys* conf, size_t offset, span_u8* dest, size_t dest_size) { + size_t result = 0; + if (dest) { + auto keys = unbox(conf).group_keys(); + size_t clamped_offset = std::min(keys.size(), offset); + for (size_t index = clamped_offset; index < keys.size() && result < dest_size; index++) { + const std::span& src_key = keys[index]; + span_u8* dest_key = dest + result++; + dest_key->data = const_cast(src_key.data()); + dest_key->size = src_key.size(); + } + } + return result; +} + LIBSESSION_C_API const span_u8 groups_keys_group_enc_key(const config_group_keys* conf) { span_u8 result = {}; try { diff --git a/tests/test_group_keys.cpp b/tests/test_group_keys.cpp index b10d9ae2..7a4d33e9 100644 --- a/tests/test_group_keys.cpp +++ b/tests/test_group_keys.cpp @@ -823,6 +823,28 @@ TEST_CASE("Group Keys - C API", "[config][groups][keys][c]") { REQUIRE(groups_members_size(a.members) == 5); } + { + // Test get keys bulk API + { + size_t keys_size = groups_keys_size(admins[0].keys); + std::vector keys_list; + keys_list.resize(keys_size); + size_t keys_read = groups_keys_group_get_keys( + admins[0].keys, 0, keys_list.data(), keys_list.size()); + REQUIRE(keys_read == keys_size); + } + + // Test get keys OOB + { + size_t keys_size = groups_keys_size(admins[0].keys); + std::vector keys_list; + keys_list.resize(keys_size); + size_t keys_read = groups_keys_group_get_keys( + admins[0].keys, keys_size, keys_list.data(), keys_list.size()); + REQUIRE(keys_read == 0); + } + } + free(new_info_config2); free(new_mem_config2); } From 9b7359167cfff59c40a9ae82b67f92beae855155 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 16 Oct 2025 14:14:36 +1100 Subject: [PATCH 116/171] Remove extraneous group prefix on bulk get keys api --- include/session/config/groups/keys.h | 4 ++-- src/config/groups/keys.cpp | 2 +- tests/test_group_keys.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/session/config/groups/keys.h b/include/session/config/groups/keys.h index 7e7217a3..13466051 100644 --- a/include/session/config/groups/keys.h +++ b/include/session/config/groups/keys.h @@ -153,8 +153,8 @@ LIBSESSION_EXPORT const unsigned char* groups_keys_get_key(const config_group_ke /// Outputs: /// - `size_t` the number of keys that were written to the buffer. This can be less than the /// `dest_size` if the user requested a range of keys that is smaller than the given buffer. -LIBSESSION_EXPORT size_t groups_keys_group_get_keys( - const config_group_keys* conf, size_t offset, span_u8* dest, size_t dest_size); +LIBSESSION_EXPORT size_t +groups_keys_get_keys(const config_group_keys* conf, size_t offset, span_u8* dest, size_t dest_size); /// API: groups/groups_keys_group_enc_key /// diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index 3abb2162..86a7fd14 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -1364,7 +1364,7 @@ LIBSESSION_C_API const unsigned char* groups_keys_get_key(const config_group_key return keys[N].data(); } -LIBSESSION_C_API size_t groups_keys_group_get_keys( +LIBSESSION_C_API size_t groups_keys_get_keys( const config_group_keys* conf, size_t offset, span_u8* dest, size_t dest_size) { size_t result = 0; if (dest) { diff --git a/tests/test_group_keys.cpp b/tests/test_group_keys.cpp index 7a4d33e9..0af36f31 100644 --- a/tests/test_group_keys.cpp +++ b/tests/test_group_keys.cpp @@ -829,8 +829,8 @@ TEST_CASE("Group Keys - C API", "[config][groups][keys][c]") { size_t keys_size = groups_keys_size(admins[0].keys); std::vector keys_list; keys_list.resize(keys_size); - size_t keys_read = groups_keys_group_get_keys( - admins[0].keys, 0, keys_list.data(), keys_list.size()); + size_t keys_read = + groups_keys_get_keys(admins[0].keys, 0, keys_list.data(), keys_list.size()); REQUIRE(keys_read == keys_size); } @@ -839,7 +839,7 @@ TEST_CASE("Group Keys - C API", "[config][groups][keys][c]") { size_t keys_size = groups_keys_size(admins[0].keys); std::vector keys_list; keys_list.resize(keys_size); - size_t keys_read = groups_keys_group_get_keys( + size_t keys_read = groups_keys_get_keys( admins[0].keys, keys_size, keys_list.data(), keys_list.size()); REQUIRE(keys_read == 0); } From f73c50becf4d09fcbfa460df0b8ca8c99e56ddc0 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 16 Oct 2025 14:15:39 +1100 Subject: [PATCH 117/171] Update outdated doc name for group_keys_get_keys --- include/session/config/groups/keys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/session/config/groups/keys.h b/include/session/config/groups/keys.h index 13466051..33c42368 100644 --- a/include/session/config/groups/keys.h +++ b/include/session/config/groups/keys.h @@ -133,7 +133,7 @@ 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_get_keys +/// API: groups/groups_keys_get_keys /// /// Retrieve multiple keys for the group consisting of [offset, offset + dest_size). This function /// clamps the `offset` and `dest_size` such that no out-of-bounds reads are executed. See From 8131df6a82acc91fa14601f5f29b42fdef10d19f Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 17 Oct 2025 10:10:50 +1100 Subject: [PATCH 118/171] Fix GroupsV2 decoded deriving incorrect x25519 key bytes --- src/session_protocol.cpp | 2 +- tests/test_session_protocol.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index b558c426..b139699a 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -627,7 +627,7 @@ DecodedEnvelope decode_envelope( assert(decrypt.session_id.starts_with("05")); oxenc::from_hex( decrypt.session_id.begin() + 2, - decrypt.session_id.end() - 2, + decrypt.session_id.end(), result.sender_x25519_pubkey.begin()); } else { // Assumed to be a 1o1/sync message which is wrapped in a websocket message diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 8e7ce863..d6357f05 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -558,6 +558,11 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(decrypt_result.success); REQUIRE(decrypt_result.pro.status == SESSION_PROTOCOL_PRO_STATUS_VALID); REQUIRE(decrypt_result.error_len_incl_null_terminator == 0); + static_assert( + sizeof(decrypt_result.sender_x25519_pubkey.data) == keys.curve_pk0.max_size()); + REQUIRE(memcmp(decrypt_result.sender_x25519_pubkey.data, + keys.curve_pk0.data(), + keys.curve_pk0.size()) == 0); session_protocol_encode_for_destination_free(&encrypt_result); session_protocol_decode_envelope_free(&decrypt_result); From 0342879c7b3896c3e286535b69ed4541f13c8907 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 17 Oct 2025 13:58:43 +1100 Subject: [PATCH 119/171] Update pro backend to accomodate new API changes from the server --- include/session/pro_backend.h | 30 +++++++--- include/session/pro_backend.hpp | 97 +++++++++++++++++++++++--------- src/pro_backend.cpp | 98 ++++++++++++++++++++------------- tests/test_pro_backend.cpp | 68 ++++++++++++++--------- 4 files changed, 197 insertions(+), 96 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 028b3716..1f567ce6 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -36,6 +36,16 @@ typedef enum SESSION_PRO_BACKEND_PAYMENT_STATUS { SESSION_PRO_BACKEND_PAYMENT_STATUS_COUNT, } SESSION_PRO_BACKEND_PAYMENT_STATUS; +/// Must match: +/// https://github.com/Doy-lee/session-pro-backend/blob/b9fb4301fecbd82e4631536fa378d4c1220b1a4d/base.py#L53 +typedef enum SESSION_PRO_BACKEND_PLAN { + SESSION_PRO_BACKEND_PLAN_NIL, + SESSION_PRO_BACKEND_PLAN_ONE_MONTH, + SESSION_PRO_BACKEND_PLAN_THREE_MONTHS, + SESSION_PRO_BACKEND_PLAN_TWELVE_MONTHS, + SESSION_PRO_BACKEND_PLAN_COUNT, +} SESSION_PRO_BACKEND_PLAN; + /// Must match: /// https://github.com/Doy-lee/session-pro-backend/blob/a0e0ba24bc4ab3a062465d861aa57df2269b6dde/server.py#L373 typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { @@ -174,17 +184,20 @@ typedef struct session_pro_backend_get_pro_status_request { typedef struct session_pro_backend_pro_payment_item { SESSION_PRO_BACKEND_PAYMENT_STATUS status; - uint64_t subscription_duration_s; - uint64_t grace_unix_ts_ms; - uint64_t expiry_unix_ts_ms; - uint64_t refunded_unix_ts_ms; - uint64_t redeemed_unix_ts_ms; + SESSION_PRO_BACKEND_PLAN plan; SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; - /// Pointer to payment provider metadata. This pointer is always defined to be pointing to valid /// memory when the structure is received through the pro_backend APIs. const session_pro_backend_payment_provider_metadata* payment_provider_metadata; + bool auto_renewing; + uint64_t unredeemed_unix_ts_ms; + uint64_t redeemed_unix_ts_ms; + uint64_t expiry_unix_ts_ms; + uint64_t grace_period_duration_ms; + uint64_t platform_refund_expiry_unix_ts_ms; + uint64_t revoked_unix_ts_ms; + char google_payment_token[128]; size_t google_payment_token_count; char google_order_id[128]; @@ -202,9 +215,10 @@ typedef struct session_pro_backend_get_pro_status_response { /// Array of payment items, with items_count elements session_pro_backend_pro_payment_item* items; size_t items_count; - uint64_t latest_expiry_unix_ts_ms; - uint64_t latest_grace_unix_ts_ms; SESSION_PRO_BACKEND_USER_PRO_STATUS status; + bool auto_renewing; + uint64_t expiry_unix_ts_ms; + uint64_t grace_period_duration_ms; } session_pro_backend_get_pro_status_response; /// API: session_pro_backend/add_pro_payment_request_build_sigs diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 71406073..cff44b32 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -304,24 +304,15 @@ struct GetProStatusRequest { struct ProPaymentItem { /// Describes the current status of the consumption of the payment for Session Pro entitlement + /// The status should be used to determine which timestamps should be used. + /// + /// For example, a payment can be in a redeemed state whilst also have a refunded timestamp set + /// if the payment was refunded and then the refund was reversed. We preserve all timestamps for + /// book-keeping purposes. SESSION_PRO_BACKEND_PAYMENT_STATUS status; - /// Unix timestamp of when the payment was expiry. 0 if not activated - std::chrono::sys_time expiry_unix_ts; - - /// Unix timestamp when the payment provider will start to attempt to renew the Session Pro - /// subscription. During the period between [grace_unix_ts, expiry_unix_ts] the user continues - /// to have entitlement to Session Pro. This is set to 0 if auto-renewal is not enabled. - std::chrono::sys_time grace_unix_ts; - - /// Unix timestamp of when the payment was redeemed. 0 if not activated - std::chrono::sys_time redeemed_unix_ts; - - /// Unix timestamp of when the payment was refunded. 0 if not activated - std::chrono::sys_time refunded_unix_ts; - - /// Subscription duration in seconds - std::chrono::seconds subscription_duration; + /// Session Pro product/plan item that was purchased + SESSION_PRO_BACKEND_PLAN plan; /// Store front that this particular payment came from SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; @@ -332,19 +323,47 @@ struct ProPaymentItem { const session_pro_backend_payment_provider_metadata* payment_provider_metadata = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA; + /// Flag indicating whether or not this payment will automatically bill itself at the end of the + /// billing cycle. + bool auto_renewing; + + /// Unix timestamp of when the payment was witnessed by the Pro Backend. Always set + std::chrono::sys_time unredeemed_unix_ts; + + /// Unix timestamp of when the payment was redeemed. 0 if not activated + std::chrono::sys_time redeemed_unix_ts; + + /// Unix timestamp of when the payment was expiry. 0 if not activated + std::chrono::sys_time expiry_unix_ts; + + /// Duration of the grace period, e.g. when the payment provider will start to attempt to renew + /// the Session Pro subscription. During the period between + /// [expiry_unix_ts, expiry_unix_ts + grace_period_duration_ms] the user continues to have + /// entitlement to Session Pro. This value is only applicable if `auto_renewing` is `true`. + std::chrono::milliseconds grace_period_duration_ms; + + /// Unix deadline timestamp of when the user is able to refund the subscription via the payment + /// provider. Thereafter the user must initiate a refund manually via Session support. + std::chrono::sys_time platform_refund_expiry_unix_ts; + + /// Unix timestamp of when the payment was revoked or refunded. 0 if not applicable. + std::chrono::sys_time revoked_unix_ts; + /// When payment provider is set to Google Play Store, this is the platform-specific purchase - /// token + /// token. This information should be considered as confidential and stored appropriately. std::string google_payment_token; /// When payment provider is set to iOS App Store, this is the platform-specific original - /// transaction ID + /// transaction ID. This information should be considered as confidential and stored + /// appropriately. std::string apple_original_tx_id; /// When payment provider is set to iOS App Store, this is the platform-specific transaction ID + /// This information should be considered as confidential and stored appropriately. std::string apple_tx_id; /// When payment provider is set to iOS App Store, this is the platform-specific web line order - /// ID + /// ID. This information should be considered as confidential and stored appropriately. std::string apple_web_line_order_id; }; @@ -355,14 +374,40 @@ struct GetProStatusResponse : public ResponseHeader { /// Current Session Pro entitlement status for the master public key SESSION_PRO_BACKEND_USER_PRO_STATUS user_status; - /// Unix timestamp of when the the latest payment will expire. 0 if no payments are available - /// for the requested Session Pro master public key. - std::chrono::sys_time latest_expiry_unix_ts; + /// Flag to indicate if the user will automatically renew their subscription. + bool auto_renewing; - /// Unix timestamp when the payment provider will start to attempt to renew the Session Pro - /// subscription. During the period between [grace_unix_ts, expiry_unix_ts] the user continues - /// to have entitlement to Session Pro. This is set to 0 if auto-renewal is not enabled. - std::chrono::sys_time latest_grace_unix_ts; + /// Deadline UNIX timestamp that a user is entitled to Session Pro Proofs. The user is allowed + /// to request a Session Pro Proof from the Pro Backend up until this timestamp. Thereafter + /// the user is no longer entitled to Session Pro. This deadline includes the grace period if + /// applicable. + /// + /// The grace period is enabled when `auto_renewing` is `true` and is the extra period after a + /// user's subscription has elapsed that the payment provider allocates to continue entitlement + /// to Session Pro whilst attempting to execute the billing of a Session Pro subscription. + /// + /// This allows a user to maintain entitlement to Session Pro across billing cycles by giving + /// some leeway as to the time required for the payment provider to successfully bill the user. + /// This expiry timestamp is hence calculated as: + /// + /// expiry_unix_ts_ms = (subscription_expiry_unix_ts + grace_period_duration_ms) + /// + /// E.g. The subscription expiry timestamp can be calculated by subtracting + /// `grace_period_duration_ms` to determine if the user is currently in a grace period. Some + /// platforms do not support a grace period so this value can be 0. + /// + /// Finally, a reminder that the grace period is not activated or included in this deadline + /// timestamp if they have configured subscription `auto_renewing` to be off. + /// + /// This timestamp may be in the past if the user no longer has active payments. Overtime the + /// Pro Backend may prune user history and so after long lapses of activity, a user's + /// subscription history may be deleted. + std::chrono::sys_time expiry_unix_ts_ms; + + /// Duration that a user is entitled to for their grace period. This value is to be ignored if + /// `auto_renewing` is false. It can be used to calculate the subscription expiry timestamp by + /// subtracting `expiry_unix_ts_ms` from this value. + std::chrono::milliseconds grace_period_duration_ms; /// API: pro/GetProPaymentsResponse::parse /// diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 47a9c12d..b2d15b17 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -54,6 +54,9 @@ const T json_require( } else if constexpr (session::is_one_of) { type = "an array"; success = it->is_array(); + } else if constexpr (session::is_one_of) { + type = "a boolean"; + success = it->is_boolean(); } else { static_assert(session::is_one_of); type = "an object"; @@ -452,15 +455,15 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { return result; } result.user_status = static_cast(user_status); + result.auto_renewing = json_require(result_obj, "auto_renewing", result.errors); - uint64_t latest_grace_ts = - json_require(result_obj, "latest_grace_unix_ts_ms", result.errors); - uint64_t latest_expiry_ts = - json_require(result_obj, "latest_expiry_unix_ts_ms", result.errors); - result.latest_grace_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(latest_grace_ts)); - result.latest_expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(latest_expiry_ts)); + uint64_t expiry_unix_ts_ms = + json_require(result_obj, "expiry_unix_ts_ms", result.errors); + uint64_t grace_period_duration_ms = + json_require(result_obj, "grace_period_duration_ms", result.errors); + result.expiry_unix_ts_ms = std::chrono::sys_time( + std::chrono::milliseconds(expiry_unix_ts_ms)); + result.grace_period_duration_ms = std::chrono::milliseconds(grace_period_duration_ms); auto array = json_require(result_obj, "items", result.errors); result.items.reserve(array.size()); @@ -475,12 +478,17 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { // Parse payment item auto obj = it.get(); auto status = json_require(obj, "status", result.errors); - auto grace_ts = json_require(obj, "grace_unix_ts_ms", result.errors); - auto expiry_ts = json_require(obj, "expiry_unix_ts_ms", result.errors); - auto redeemed_ts = json_require(obj, "redeemed_unix_ts_ms", result.errors); - auto refunded_ts = json_require(obj, "refunded_unix_ts_ms", result.errors); - auto sub_duration_s = json_require(obj, "subscription_duration_s", result.errors); + auto plan = json_require(obj, "plan", result.errors); auto payment_provider = json_require(obj, "payment_provider", result.errors); + auto auto_renewing = json_require(obj, "auto_renewing", result.errors); + auto unredeemed_ts = json_require(obj, "unredeemed_unix_ts_ms", result.errors); + auto redeemed_ts = json_require(obj, "redeemed_unix_ts_ms", result.errors); + auto expiry_ts = json_require(obj, "expiry_unix_ts_ms", result.errors); + auto grace_period_duration_ms = + json_require(obj, "grace_period_duration_ms", result.errors); + auto platform_refund_expiry_ts = + json_require(obj, "platform_refund_expiry_unix_ts_ms", result.errors); + auto revoked_ts = json_require(obj, "revoked_unix_ts_ms", result.errors); ProPaymentItem item = {}; if (status > SESSION_PRO_BACKEND_PAYMENT_STATUS_NIL && @@ -490,15 +498,12 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { result.errors.push_back(fmt::format("Status value was out-of-bounds: {}", status)); } - item.grace_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(grace_ts)); - item.expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(expiry_ts)); - item.redeemed_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(redeemed_ts)); - item.refunded_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(refunded_ts)); - item.subscription_duration = std::chrono::seconds(sub_duration_s); + if (plan > SESSION_PRO_BACKEND_PLAN_NIL && plan < SESSION_PRO_BACKEND_PLAN_COUNT) { + item.plan = static_cast(plan); + } else { + result.errors.push_back(fmt::format("Plan value was out-of-bounds: {}", plan)); + } + if (payment_provider > SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL && payment_provider < SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT) { item.payment_provider = @@ -510,6 +515,18 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { fmt::format("Payment provider value was out-of-bounds: {}", payment_provider)); } + item.auto_renewing = auto_renewing; + item.unredeemed_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(unredeemed_ts)); + item.redeemed_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(redeemed_ts)); + item.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(expiry_ts)); + item.grace_period_duration_ms = std::chrono::milliseconds(grace_period_duration_ms); + item.platform_refund_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(platform_refund_expiry_ts)); + item.revoked_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(revoked_ts)); switch (item.payment_provider) { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: [[fallthrough]]; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: { @@ -940,29 +957,36 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ result.items_count = cpp.items.size(); result.items = (session_pro_backend_pro_payment_item*)arena_alloc( &arena, result.items_count * sizeof(*result.items)); - result.latest_expiry_unix_ts_ms = cpp.latest_expiry_unix_ts.time_since_epoch().count(); - result.latest_grace_unix_ts_ms = cpp.latest_grace_unix_ts.time_since_epoch().count(); + result.auto_renewing = cpp.auto_renewing; + result.expiry_unix_ts_ms = cpp.expiry_unix_ts_ms.time_since_epoch().count(); + result.grace_period_duration_ms = cpp.grace_period_duration_ms.count(); for (size_t index = 0; index < result.items_count; ++index) { const ProPaymentItem& src = cpp.items[index]; session_pro_backend_pro_payment_item& dest = result.items[index]; dest.status = src.status; - dest.subscription_duration_s = - std::chrono::duration_cast(src.subscription_duration).count(); - dest.grace_unix_ts_ms = std::chrono::duration_cast( - src.grace_unix_ts.time_since_epoch()) - .count(); - dest.expiry_unix_ts_ms = std::chrono::duration_cast( - src.expiry_unix_ts.time_since_epoch()) - .count(); - dest.refunded_unix_ts_ms = std::chrono::duration_cast( - src.refunded_unix_ts.time_since_epoch()) - .count(); + dest.plan = src.plan; + dest.payment_provider = src.payment_provider; + dest.payment_provider_metadata = src.payment_provider_metadata; + dest.unredeemed_unix_ts_ms = std::chrono::duration_cast( + src.unredeemed_unix_ts.time_since_epoch()) + .count(); dest.redeemed_unix_ts_ms = std::chrono::duration_cast( src.redeemed_unix_ts.time_since_epoch()) .count(); - dest.payment_provider = src.payment_provider; - dest.payment_provider_metadata = src.payment_provider_metadata; + dest.expiry_unix_ts_ms = std::chrono::duration_cast( + src.expiry_unix_ts.time_since_epoch()) + .count(); + dest.grace_period_duration_ms = + std::chrono::duration_cast(src.grace_period_duration_ms) + .count(); + dest.platform_refund_expiry_unix_ts_ms = + std::chrono::duration_cast( + src.platform_refund_expiry_unix_ts.time_since_epoch()) + .count(); + dest.revoked_unix_ts_ms = std::chrono::duration_cast( + src.revoked_unix_ts.time_since_epoch()) + .count(); switch (dest.payment_provider) { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 18d4617e..8d424662 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -32,12 +32,20 @@ static bool string8_equals(string8 s8, std::string_view str) { [[maybe_unused]] static void dump_pro_payment_item( const session_pro_backend_pro_payment_item& item) { - fprintf(stderr, "item.expiry_unix_ts_ms: %" PRIu64 "\n", item.expiry_unix_ts_ms); - fprintf(stderr, "item.grace_unix_ts_ms: %" PRIu64 "zu\n", item.grace_unix_ts_ms); + fprintf(stderr, "item.status: %d\n", item.status); + fprintf(stderr, "item.plan: %d\n", item.plan); + fprintf(stderr, "item.payment_provider: %d\n", item.payment_provider); + fprintf(stderr, "item.auto_renewing: %d\n", item.auto_renewing); + fprintf(stderr, "item.unredeemed_unix_ts_ms: %" PRIu64 "zu\n", item.unredeemed_unix_ts_ms); fprintf(stderr, "item.redeemed_unix_ts_ms: %" PRIu64 "zu\n", item.redeemed_unix_ts_ms); - fprintf(stderr, "item.refunded_unix_ts_ms: %" PRIu64 "zu\n", item.refunded_unix_ts_ms); - fprintf(stderr, "item.subscription_duration: %" PRIu64 "zu\n", item.subscription_duration_s); - fprintf(stderr, "item.payment_provider: %u\n", item.payment_provider); + fprintf(stderr, "item.expiry_unix_ts_ms: %" PRIu64 "\n", item.expiry_unix_ts_ms); + fprintf(stderr, + "item.grace_period_duration_ms: %" PRIu64 "zu\n", + item.grace_period_duration_ms); + fprintf(stderr, + "item.platform_refund_expiry_unix_ts_ms: %" PRIu64 "zu\n", + item.platform_refund_expiry_unix_ts_ms); + fprintf(stderr, "item.revoked_unix_ts_ms: %" PRIu64 "zu\n", item.revoked_unix_ts_ms); fprintf(stderr, "item.google_payment_token: %.*s\n", (int)item.google_payment_token_count, @@ -540,18 +548,22 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { {"status", SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED}, - {"latest_grace_unix_ts_ms", unix_ts_ms + 1}, - {"latest_expiry_unix_ts_ms", unix_ts_ms + 2}, + {"auto_renewing", true}, + {"expiry_unix_ts_ms", unix_ts_ms + 2}, + {"grace_period_duration_ms", 1000}, {"items", nlohmann::json::array( {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED}, - {"subscription_duration_s", 86400}, - {"grace_unix_ts_ms", unix_ts_ms}, - {"expiry_unix_ts_ms", unix_ts_ms}, - {"refunded_unix_ts_ms", unix_ts_ms + 3600}, - {"redeemed_unix_ts_ms", unix_ts_ms - 3600}, + {"plan", SESSION_PRO_BACKEND_PLAN_ONE_MONTH}, {"payment_provider", SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE}, + {"auto_renewing", false}, + {"unredeemed_unix_ts_ms", unix_ts_ms - 3600}, + {"redeemed_unix_ts_ms", unix_ts_ms - 3600}, + {"expiry_unix_ts_ms", unix_ts_ms}, + {"grace_period_duration_ms", 1001}, + {"platform_refund_expiry_unix_ts_ms", unix_ts_ms + 1}, + {"revoked_unix_ts_ms", unix_ts_ms + 3600}, {"google_payment_token", std::string( payment_tx.payment_id, payment_tx.payment_id_count)}}})}}; @@ -565,22 +577,26 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { [&]() { session_pro_backend_get_pro_status_response_free(&result); }}; for (size_t index = 0; index < result.header.errors_count; index++) INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count == 0); REQUIRE(result.header.errors == nullptr); REQUIRE(result.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED); REQUIRE(result.items_count == 1); - REQUIRE(result.latest_grace_unix_ts_ms == unix_ts_ms + 1); - REQUIRE(result.latest_expiry_unix_ts_ms == unix_ts_ms + 2); + REQUIRE(result.auto_renewing == true); + REQUIRE(result.grace_period_duration_ms == 1000); + REQUIRE(result.expiry_unix_ts_ms == unix_ts_ms + 2); REQUIRE(result.items != nullptr); REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED); - REQUIRE(result.items[0].subscription_duration_s == 86400); - REQUIRE(result.items[0].grace_unix_ts_ms == unix_ts_ms); - REQUIRE(result.items[0].expiry_unix_ts_ms == unix_ts_ms); - REQUIRE(result.items[0].refunded_unix_ts_ms == unix_ts_ms + 3600); - REQUIRE(result.items[0].redeemed_unix_ts_ms == unix_ts_ms - 3600); + REQUIRE(result.items[0].plan == SESSION_PRO_BACKEND_PLAN_ONE_MONTH); REQUIRE(result.items[0].payment_provider == SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE); + REQUIRE(result.items[0].unredeemed_unix_ts_ms == unix_ts_ms - 3600); + REQUIRE(result.items[0].redeemed_unix_ts_ms == unix_ts_ms - 3600); + REQUIRE(result.items[0].expiry_unix_ts_ms == unix_ts_ms); + REQUIRE(result.items[0].grace_period_duration_ms == 1001); + REQUIRE(result.items[0].platform_refund_expiry_unix_ts_ms == unix_ts_ms + 1); + REQUIRE(result.items[0].revoked_unix_ts_ms == unix_ts_ms + 3600); REQUIRE(result.items[0].google_payment_token_count == payment_tx.payment_id_count); REQUIRE(std::memcmp( result.items[0].google_payment_token, @@ -771,6 +787,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { }); for (size_t index = 0; index < response.header.errors_count; index++) { + if (index == 0) + fprintf(stderr, "ERROR: JSON response: %s\n", response_json.c_str()); string8 error = response.header.errors[index]; fprintf(stderr, "ERROR: %s\n", error.data); } @@ -828,12 +846,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { scope_exit response_free{ [&]() { session_pro_backend_get_pro_status_response_free(&response); }}; + // Verify the response for (size_t index = 0; index < response.header.errors_count; index++) { + if (index == 0) + fprintf(stderr, "ERROR: JSON response: %s\n", response_json.c_str()); string8 error = response.header.errors[index]; fprintf(stderr, "ERROR: %s\n", error.data); } - - // Verify the response REQUIRE(response.header.errors_count == 0); REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(response.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_ACTIVE); @@ -878,6 +897,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { [&]() { session_pro_backend_get_pro_status_response_free(&response); }}; for (size_t index = 0; index < response.header.errors_count; index++) { + if (index == 0) + fprintf(stderr, "ERROR: JSON response: %s\n", response_json.c_str()); string8 error = response.header.errors[index]; fprintf(stderr, "ERROR: %s\n", error.data); } @@ -982,11 +1003,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { [&]() { session_pro_backend_get_pro_revocations_response_free(&response); }}; // Verify response + INFO("ERROR: JSON response: " << response_json.c_str()); for (size_t index = 0; index < response.header.errors_count; index++) { string8 error = response.header.errors[index]; fprintf(stderr, "ERROR: %s\n", error.data); } - INFO("RESPONSE: " << response_json); // Verify the response REQUIRE(response.header.errors_count == 0); @@ -1000,9 +1021,6 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { response.items[response.items_count - 1].gen_index_hash.data, first_pro_proof.gen_index_hash.data, sizeof(first_pro_proof.gen_index_hash)) == 0); - - REQUIRE(response.items[response.items_count - 1].expiry_unix_ts_ms == - first_pro_proof.expiry_unix_ts_ms); } } #endif From b9dbc01a797cdc17885ad2a0e9ac72faa89a9fd3 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 17 Oct 2025 14:16:54 +1100 Subject: [PATCH 120/171] Update documentation for the pro backend --- include/session/pro_backend.hpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index cff44b32..04b7649c 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -11,17 +11,17 @@ /// Helper functions to construct payloads to communicate with the Session Pro Backend. The data /// structures here are largely bindings to the endpoints exposed on the Session Pro Backend: /// -/// github.com/Doy-lee/session-pro-backend/blob/2afe310adad52f211e3b2cfcbdfc9eda6ff1778e/server.py#L24 +/// https://github.com/Doy-lee/session-pro-backend/blob/06e82c9d5b5a0a881d12d0182358219a4081acf5/server.py#L2 /// /// The high level summary of the functionality in this file. Clients can: /// /// 1. Build a request with `AddProPaymentRequest::to_json` from a Session Pro payment and submit it /// to the backend to register the specified Ed25519 keys for Session Pro. /// -/// Server responds JSON to be parsed with `GetProPaymentsRequest::parse`. Clients should +/// Server responds JSON to be parsed with `GetProPaymentRequest::parse`. Clients should /// validate the response and update their `UserProfile` by constructing a `ProConfig` with the -/// proof from the response by using `ProProof::from_pro_backend_response()` and filling in the -/// relevant private key that the proof was authorised for. +/// `proof` from the response and filling in the relevant rotating private key that the proof was +/// authorised for. /// /// The server will only respond successfully if it can also independently verify the purchase /// otherwise an error is returned and can be read from the `ResponseHeader` after parsing the @@ -29,7 +29,14 @@ /// /// 2. Attach the `ProProof` constructed from (1) into their messages. Libsession has helper /// functions to embed the proof into their messages via the helper functions in the Session -/// Protocol header file. +/// Protocol header file. This is done by assigning the `ProProof` into the +/// `Content.proMessage.proof` protobuf structure. Additionally the caller will use +/// `pro_features_for_utf8/16` to determine the correct flags to assign the `features` to +/// `Content.proMessage.flags` in the protobuf structure. +/// +/// Lastly the high-level libsession encoding functions accept the rotating private key to which +/// the protobuf encoded plaintext content will be signed and the payload augmented as necessary +/// to enable pro features for that message. /// /// 3. Periodically poll the global revocation list which overrides the validity of current /// circulating proofs. This is done by constructing the request via @@ -409,7 +416,7 @@ struct GetProStatusResponse : public ResponseHeader { /// subtracting `expiry_unix_ts_ms` from this value. std::chrono::milliseconds grace_period_duration_ms; - /// API: pro/GetProPaymentsResponse::parse + /// API: pro/GetProStatusResponse::parse /// /// Parses a JSON string into the response struct. /// From 6743c1da93be594f95728cefe8269fe46b2ade9f Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 17 Oct 2025 14:24:40 +1100 Subject: [PATCH 121/171] Outdated reference to AddProPayment in docs --- include/session/pro_backend.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 04b7649c..29ce1d94 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -18,10 +18,10 @@ /// 1. Build a request with `AddProPaymentRequest::to_json` from a Session Pro payment and submit it /// to the backend to register the specified Ed25519 keys for Session Pro. /// -/// Server responds JSON to be parsed with `GetProPaymentRequest::parse`. Clients should -/// validate the response and update their `UserProfile` by constructing a `ProConfig` with the -/// `proof` from the response and filling in the relevant rotating private key that the proof was -/// authorised for. +/// Server responds JSON to be parsed with `AddProPaymentOrGetProProofResponse::parse`. Clients +/// should validate the response and update their `UserProfile` by constructing a `ProConfig` +/// with the `proof` from the response and filling in the relevant rotating private key that the +/// proof was authorised for. /// /// The server will only respond successfully if it can also independently verify the purchase /// otherwise an error is returned and can be read from the `ResponseHeader` after parsing the From 78024d3e7c5620880b356d764f15fb477fc77d22 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 22 Oct 2025 11:07:30 +1100 Subject: [PATCH 122/171] Revise the hardcoded platform strings w/ latest additions --- include/session/pro_backend.h | 76 ++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 1f567ce6..d3f9fefe 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -55,6 +55,26 @@ typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT, } SESSION_PRO_BACKEND_USER_PRO_STATUS; +/// Bundle of hard-coded URLs that an application may want to redirect users to in various +/// scenarios. +typedef struct session_pro_urls { + string8 roadmap; + string8 privacy_policy; + string8 terms_of_conditions; + string8 pro_access_not_found; + string8 support_url; +} session_pro_urls; + +// clang-format off +const session_pro_urls SESSION_PRO_URLS = { + .roadmap = string8_literal("https://getsession.org/pro-roadmap"), + .privacy_policy = string8_literal("https://getsession.org/pro/privacy"), + .terms_of_conditions = string8_literal("https://getsession.org/pro/terms"), + .pro_access_not_found = string8_literal("https://sessionapp.zendesk.com/hc/sections/4416517450649-Support"), + .support_url = string8_literal("https://getsession.org/pro-form"), +}; +// clang-format on + /// Bundle of hard-coded strings that are associated with each platform for clients to use for /// string substitution typically. This structure is stored in a global table /// `SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA` that is can be indexed into using the @@ -63,9 +83,18 @@ typedef struct session_pro_backend_payment_provider_metadata { string8 device; string8 store; string8 platform; - string8 platformAccount; + string8 platform_account; string8 refund_url; - string8 subscription_url; + + /// Some platforms disallow a refund via their native support channels after some time period + /// (e.g. 48 hours after a purchase on Google, refunds must be dealt by the developers + /// themselves). If a platform does not have this restriction, this URL is typically the same as + /// the `refund_url`. + string8 refund_after_platform_deadline_url; + + string8 refund_support_url; + string8 update_subscription_url; + string8 cancel_subscription_url; } session_pro_backend_payment_provider_metadata; /// The centralised list of common URLs and properties for handling payment provider specific @@ -73,28 +102,35 @@ typedef struct session_pro_backend_payment_provider_metadata { // clang-format off const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA[SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT] = { /*SESSION_PRO_PAYMENT_PROVIDER_NIL*/ { - .device = string8_literal(""), - .store = string8_literal(""), - .platform = string8_literal(""), - .platformAccount = string8_literal(""), - .refund_url = string8_literal(""), - .subscription_url = string8_literal(""), + .device = string8_literal(""), + .store = string8_literal(""), + .platform = string8_literal(""), + .platform_account = string8_literal(""), + .refund_url = string8_literal(""), + .update_subscription_url = string8_literal(""), + .cancel_subscription_url = string8_literal(""), }, /*SESSION_PRO_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE*/ { - .device = string8_literal("Android"), - .store = string8_literal("Google Play Store"), - .platform = string8_literal("Google"), - .platformAccount = string8_literal("Google account"), - .refund_url = string8_literal("https://getsession.org/android-refund"), - .subscription_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger&sku=SESSION_PRO_MONTHLY"), + .device = string8_literal("Android"), + .store = string8_literal("Google Play Store"), + .platform = string8_literal("Google"), + .platform_account = string8_literal("Google account"), + .refund_url = string8_literal("https://support.google.com/googleplay/workflow/9813244?"), + .refund_after_platform_deadline_url = string8_literal("https://getsession.org/android-refund"), + .refund_support_url = string8_literal("https://getsession.org/android-refund"), + .update_subscription_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger"), + .cancel_subscription_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger"), }, /*SESSION_PRO_PAYMENT_PROVIDER_IOS_APP_STORE*/ { - .device = string8_literal("iOS"), - .store = string8_literal("Apple App Store"), - .platform = string8_literal("Apple"), - .platformAccount = string8_literal("Apple account"), - .refund_url = string8_literal("https://support.apple.com/118223"), - .subscription_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions") + .device = string8_literal("iOS"), + .store = string8_literal("Apple App Store"), + .platform = string8_literal("Apple"), + .platform_account = string8_literal("Apple account"), + .refund_url = string8_literal("https://support.apple.com/118223"), + .refund_after_platform_deadline_url = string8_literal("https://support.apple.com/118223"), + .refund_support_url = string8_literal("https://support.apple.com/118224"), + .update_subscription_url = string8_literal("https://apps.apple.com/account/subscriptions"), + .cancel_subscription_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions"), } }; // clang-format on From c5d9b659d1df8e7eed921bceb9249355a7e0ef6e Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 22 Oct 2025 11:14:16 +1100 Subject: [PATCH 123/171] Use fwd declared typedefs which are better and match all other pro code Forward declared typedefs let you make self-referential structures (e.g. linked lists) without needing to prefix the self-reference with a `struct` prefix due to how C/C++ compiler works. --- include/session/config/pro.h | 5 +- include/session/pro_backend.h | 89 +++++++++++++++++++----------- include/session/session_protocol.h | 5 +- tests/test_config_pro.cpp | 2 +- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/include/session/config/pro.h b/include/session/config/pro.h index 13ce5273..dcf2a264 100644 --- a/include/session/config/pro.h +++ b/include/session/config/pro.h @@ -11,10 +11,11 @@ extern "C" { #include "../export.h" #include "session/session_protocol.h" -typedef struct pro_config { +typedef struct pro_pro_config pro_pro_config; +struct pro_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. diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index d3f9fefe..1ab1e6cd 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -57,13 +57,14 @@ typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { /// Bundle of hard-coded URLs that an application may want to redirect users to in various /// scenarios. -typedef struct session_pro_urls { +typedef struct session_pro_urls session_pro_urls; +struct session_pro_urls { string8 roadmap; string8 privacy_policy; string8 terms_of_conditions; string8 pro_access_not_found; string8 support_url; -} session_pro_urls; +}; // clang-format off const session_pro_urls SESSION_PRO_URLS = { @@ -79,7 +80,9 @@ const session_pro_urls SESSION_PRO_URLS = { /// string substitution typically. This structure is stored in a global table /// `SESSION_PRO_BACKEND_PAYMENT_PROVIDER_METADATA` that is can be indexed into using the /// SESSION_PRO_BACKEND_PAYMENT_PROVIDER value directly. -typedef struct session_pro_backend_payment_provider_metadata { +typedef struct session_pro_backend_payment_provider_metadata + session_pro_backend_payment_provider_metadata; +struct session_pro_backend_payment_provider_metadata { string8 device; string8 store; string8 platform; @@ -95,7 +98,7 @@ typedef struct session_pro_backend_payment_provider_metadata { string8 refund_support_url; string8 update_subscription_url; string8 cancel_subscription_url; -} session_pro_backend_payment_provider_metadata; +}; /// The centralised list of common URLs and properties for handling payment provider specific /// integrations. Especially useful for cross-device management of Session Pro subscriptions. @@ -135,90 +138,110 @@ const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_ }; // clang-format on -typedef struct session_pro_backend_response_header { +typedef struct session_pro_backend_response_header session_pro_backend_response_header; +struct session_pro_backend_response_header { uint32_t status; /// Array of error messages (NULL if no errors), with errors_count elements string8* errors; size_t errors_count; uint8_t* internal_arena_buf_; /// Internal buffer for all the memory allocations, do not touch -} session_pro_backend_response_header; +}; -typedef struct { +typedef struct session_pro_backend_to_json session_pro_backend_to_json; +struct session_pro_backend_to_json { bool success; /// True if conversion to JSON was successful, false if out-of-memory string8 json; -} session_pro_backend_to_json; +}; -typedef struct session_pro_backend_master_rotating_signatures { +typedef struct session_pro_backend_master_rotating_signatures + session_pro_backend_master_rotating_signatures; +struct session_pro_backend_master_rotating_signatures { bool success; char error[256]; size_t error_count; bytes64 master_sig; bytes64 rotating_sig; -} session_pro_backend_master_rotating_signatures; +}; -typedef struct session_pro_backend_signature { +typedef struct session_pro_backend_signature session_pro_backend_signature; +struct session_pro_backend_signature { bool success; char error[256]; size_t error_count; bytes64 sig; -} session_pro_backend_signature; +}; -typedef struct session_pro_backend_add_pro_payment_user_transaction { +typedef struct session_pro_backend_add_pro_payment_user_transaction + session_pro_backend_add_pro_payment_user_transaction; +struct session_pro_backend_add_pro_payment_user_transaction { SESSION_PRO_BACKEND_PAYMENT_PROVIDER provider; char payment_id[128]; size_t payment_id_count; -} session_pro_backend_add_pro_payment_user_transaction; +}; -typedef struct session_pro_backend_add_pro_payment_request { +typedef struct session_pro_backend_add_pro_payment_request + session_pro_backend_add_pro_payment_request; +struct session_pro_backend_add_pro_payment_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; session_pro_backend_add_pro_payment_user_transaction payment_tx; bytes64 master_sig; bytes64 rotating_sig; -} session_pro_backend_add_pro_payment_request; +}; -typedef struct session_pro_backend_get_pro_proof_request { +typedef struct session_pro_backend_get_pro_proof_request session_pro_backend_get_pro_proof_request; +struct session_pro_backend_get_pro_proof_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; uint64_t unix_ts_ms; bytes64 master_sig; bytes64 rotating_sig; -} session_pro_backend_get_pro_proof_request; +}; -typedef struct session_pro_backend_add_pro_payment_or_get_pro_proof_response { +typedef struct session_pro_backend_add_pro_payment_or_get_pro_proof_response + session_pro_backend_add_pro_payment_or_get_pro_proof_response; +struct session_pro_backend_add_pro_payment_or_get_pro_proof_response { session_pro_backend_response_header header; session_protocol_pro_proof proof; -} session_pro_backend_add_pro_payment_or_get_pro_proof_response; +}; -typedef struct session_pro_backend_get_pro_revocations_request { +typedef struct session_pro_backend_get_pro_revocations_request + session_pro_backend_get_pro_revocations_request; +struct session_pro_backend_get_pro_revocations_request { uint8_t version; uint32_t ticket; -} session_pro_backend_get_pro_revocations_request; +}; -typedef struct session_pro_backend_pro_revocation_item { +typedef struct session_pro_backend_pro_revocation_item session_pro_backend_pro_revocation_item; +struct session_pro_backend_pro_revocation_item { bytes32 gen_index_hash; uint64_t expiry_unix_ts_ms; -} session_pro_backend_pro_revocation_item; +}; -typedef struct session_pro_backend_get_pro_revocations_response { +typedef struct session_pro_backend_get_pro_revocations_response + session_pro_backend_get_pro_revocations_response; +struct session_pro_backend_get_pro_revocations_response { session_pro_backend_response_header header; uint32_t ticket; /// Array of items, with items_count elements session_pro_backend_pro_revocation_item* items; size_t items_count; -} session_pro_backend_get_pro_revocations_response; +}; -typedef struct session_pro_backend_get_pro_status_request { +typedef struct session_pro_backend_get_pro_status_request + session_pro_backend_get_pro_status_request; +struct session_pro_backend_get_pro_status_request { uint8_t version; bytes32 master_pkey; bytes64 master_sig; uint64_t unix_ts_ms; bool history; -} session_pro_backend_get_pro_status_request; +}; -typedef struct session_pro_backend_pro_payment_item { +typedef struct session_pro_backend_pro_payment_item session_pro_backend_pro_payment_item; +struct session_pro_backend_pro_payment_item { SESSION_PRO_BACKEND_PAYMENT_STATUS status; SESSION_PRO_BACKEND_PLAN plan; SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_provider; @@ -244,9 +267,11 @@ typedef struct session_pro_backend_pro_payment_item { size_t apple_tx_id_count; char apple_web_line_order_id[128]; size_t apple_web_line_order_id_count; -} session_pro_backend_pro_payment_item; +}; -typedef struct session_pro_backend_get_pro_status_response { +typedef struct session_pro_backend_get_pro_status_response + session_pro_backend_get_pro_status_response; +struct session_pro_backend_get_pro_status_response { session_pro_backend_response_header header; /// Array of payment items, with items_count elements session_pro_backend_pro_payment_item* items; @@ -255,7 +280,7 @@ typedef struct session_pro_backend_get_pro_status_response { bool auto_renewing; uint64_t expiry_unix_ts_ms; uint64_t grace_period_duration_ms; -} session_pro_backend_get_pro_status_response; +}; /// API: session_pro_backend/add_pro_payment_request_build_sigs /// diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index c9af003f..e8b743d5 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -40,13 +40,14 @@ struct session_protocol_pro_signed_message { span_u8 msg; }; -typedef struct session_protocol_pro_proof { +typedef struct session_protocol_pro_proof session_protocol_pro_proof; +struct session_protocol_pro_proof { uint8_t version; bytes32 gen_index_hash; bytes32 rotating_pubkey; uint64_t expiry_unix_ts_ms; bytes64 sig; -} session_protocol_pro_proof; +}; // Bit flags for features that are not currently able to be determined by the state stored in // Libsession. They are to be passed in by the client into `get_pro_msg_for_features` to return the diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index c3616318..46e56560 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -18,7 +18,7 @@ TEST_CASE("Pro", "[config][pro]") { // Setup the Pro data structure session::config::ProConfig pro_cpp = {}; - pro_config pro = {}; + pro_pro_config pro = {}; { // CPP pro_cpp.rotating_privkey = rotating_sk; From f73e2296d89e4c27f83af6d6df73fa6deda2bbf8 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 22 Oct 2025 12:05:11 +1100 Subject: [PATCH 124/171] Parse the new error_report value from the user pro status endpoint --- include/session/pro_backend.h | 7 +++++++ include/session/pro_backend.hpp | 5 +++++ src/pro_backend.cpp | 11 +++++++++++ tests/test_pro_backend.cpp | 3 +++ 4 files changed, 26 insertions(+) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 1ab1e6cd..062232e2 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -55,6 +55,12 @@ typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT, } SESSION_PRO_BACKEND_USER_PRO_STATUS; +typedef enum SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT { + SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_SUCCESS, + SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_GENERIC_ERROR, + SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_COUNT, +} SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT; + /// Bundle of hard-coded URLs that an application may want to redirect users to in various /// scenarios. typedef struct session_pro_urls session_pro_urls; @@ -277,6 +283,7 @@ struct session_pro_backend_get_pro_status_response { session_pro_backend_pro_payment_item* items; size_t items_count; SESSION_PRO_BACKEND_USER_PRO_STATUS status; + SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT error_report; bool auto_renewing; uint64_t expiry_unix_ts_ms; uint64_t grace_period_duration_ms; diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 29ce1d94..1474c3c5 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -381,6 +381,11 @@ struct GetProStatusResponse : public ResponseHeader { /// Current Session Pro entitlement status for the master public key SESSION_PRO_BACKEND_USER_PRO_STATUS user_status; + /// Error code that indicates that the Session Pro Backend encountered an error book-keeping + /// Session Pro entitlement for the user. If this value is not `SUCCESS` implementing clients + /// can optionally prompt the user that they should contact support for investigation. + SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT error_report; + /// Flag to indicate if the user will automatically renew their subscription. bool auto_renewing; diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index b2d15b17..d5147b5b 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -455,6 +455,16 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { return result; } result.user_status = static_cast(user_status); + + uint32_t error_report = json_require(result_obj, "error_report", result.errors); + if (error_report >= SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_COUNT) { + result.errors.push_back( + fmt::format("Error report value was out-of-bounds: {}", user_status)); + return result; + } + result.error_report = + static_cast(error_report); + result.auto_renewing = json_require(result_obj, "auto_renewing", result.errors); uint64_t expiry_unix_ts_ms = @@ -954,6 +964,7 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ // Copy to C struct, this is guaranteed not to fail because we pre-allocated memory upfront. result.header.status = cpp.status; result.status = cpp.user_status; + result.error_report = cpp.error_report; result.items_count = cpp.items.size(); result.items = (session_pro_backend_pro_payment_item*)arena_alloc( &arena, result.items_count * sizeof(*result.items)); diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 8d424662..28ebd5f5 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -548,6 +548,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { {"status", SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED}, + {"error_report", SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_GENERIC_ERROR}, {"auto_renewing", true}, {"expiry_unix_ts_ms", unix_ts_ms + 2}, {"grace_period_duration_ms", 1000}, @@ -582,6 +583,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.header.errors_count == 0); REQUIRE(result.header.errors == nullptr); REQUIRE(result.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED); + REQUIRE(result.error_report == + SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_GENERIC_ERROR); REQUIRE(result.items_count == 1); REQUIRE(result.auto_renewing == true); REQUIRE(result.grace_period_duration_ms == 1000); From 725721807b93037cc82b9c318e56608ff8414d5b Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 23 Oct 2025 11:04:40 +1100 Subject: [PATCH 125/171] s/terms_and_conditions/terms_of_service --- include/session/pro_backend.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 062232e2..ae624866 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -67,7 +67,7 @@ typedef struct session_pro_urls session_pro_urls; struct session_pro_urls { string8 roadmap; string8 privacy_policy; - string8 terms_of_conditions; + string8 terms_of_service; string8 pro_access_not_found; string8 support_url; }; @@ -76,7 +76,7 @@ struct session_pro_urls { const session_pro_urls SESSION_PRO_URLS = { .roadmap = string8_literal("https://getsession.org/pro-roadmap"), .privacy_policy = string8_literal("https://getsession.org/pro/privacy"), - .terms_of_conditions = string8_literal("https://getsession.org/pro/terms"), + .terms_of_service = string8_literal("https://getsession.org/pro/terms"), .pro_access_not_found = string8_literal("https://sessionapp.zendesk.com/hc/sections/4416517450649-Support"), .support_url = string8_literal("https://getsession.org/pro-form"), }; From d5bc1ea08ee61dbaf04839575ced7e6cc426a7a8 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 23 Oct 2025 13:58:32 +1100 Subject: [PATCH 126/171] Add missing initialisings for the nil payment platform URLs --- include/session/pro_backend.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index ae624866..a898aa6b 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -116,6 +116,8 @@ const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_ .platform = string8_literal(""), .platform_account = string8_literal(""), .refund_url = string8_literal(""), + .refund_after_platform_deadline_url = string8_literal(""), + .refund_support_url = string8_literal(""), .update_subscription_url = string8_literal(""), .cancel_subscription_url = string8_literal(""), }, From 2efa5de1abd6b888da25be55efe2cdd47e659328 Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 23 Oct 2025 16:40:46 +1100 Subject: [PATCH 127/171] Fix ProConfig proofs not deserialising version correctly --- src/config/pro.cpp | 2 +- tests/test_config_pro.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/pro.cpp b/src/config/pro.cpp index a1fb19be..030ec26d 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -64,7 +64,7 @@ bool ProConfig::load(const dict& root) { if (!maybe_expiry_unix_ts_ms) return false; - version = *version; + proof.version = *version; std::memcpy( proof.gen_index_hash.data(), maybe_gen_index_hash->data(), diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp index 46e56560..b1ead131 100644 --- a/tests/test_config_pro.cpp +++ b/tests/test_config_pro.cpp @@ -22,7 +22,7 @@ TEST_CASE("Pro", "[config][pro]") { { // CPP pro_cpp.rotating_privkey = rotating_sk; - pro_cpp.proof.version = 0; + pro_cpp.proof.version = 2; pro_cpp.proof.rotating_pubkey = rotating_pk; pro_cpp.proof.expiry_unix_ts = std::chrono::sys_time(1s); constexpr auto gen_index_hash = @@ -115,7 +115,7 @@ TEST_CASE("Pro", "[config][pro]") { good_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ - /*version*/ {"@", 0}, + /*version*/ {"@", proof.version}, /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, @@ -146,7 +146,7 @@ TEST_CASE("Pro", "[config][pro]") { bad_dict = { {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, {"p", session::config::dict{ - /*version*/ {"@", 0}, + /*version*/ {"@", proof.version}, /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, From 3b45f22eafffbef0b3602929a356301ff763a9f6 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 24 Oct 2025 11:44:23 +1100 Subject: [PATCH 128/171] Fix inconsistent utf8/16 pro_features_for arguments --- include/session/session_protocol.h | 12 ++++++------ include/session/session_protocol.hpp | 12 ++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index e8b743d5..d098c559 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -277,9 +277,9 @@ typedef struct session_protocol_pro_features_for_msg { /// Determine the Pro features that are used in a given UTF8 message. /// /// Inputs: -/// - `utf8` -- the utf8 string to count the number of codepoints in to determine if it needs the +/// - `utf` -- the UTF8 string to count the number of codepoints in to determine if it needs the /// higher character limit available in Session Pro -/// - `utf8_size` -- the number of code units (aka. bytes) the string has +/// - `utf_size` -- the number of code units (aka. bytes) the string has /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// @@ -293,7 +293,7 @@ typedef struct session_protocol_pro_features_for_msg { /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( - char const* utf8, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) + char const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); /// API: session_protocol/session_protocol_get_pro_features_for_utf16 @@ -301,9 +301,9 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// Determine the Pro features that are used in a given UTF16 message. /// /// Inputs: -/// - `utf8` -- the utf16 string to count the number of codepoints in to determine if it needs the +/// - `utf` -- the UTF16 string to count the number of codepoints in to determine if it needs the /// higher character limit available in Session Pro -/// - `utf16_size` -- the number of code units (aka. bytes) the string has +/// - `utf_size` -- the number of code units (aka. bytes) the string has /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message /// @@ -317,7 +317,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( - uint16_t const* utf16, size_t utf16_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) + uint16_t const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) NON_NULL_ARG(1); /// API: session_protocol_encode_for_1o1 diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 1ef4de29..9285cae4 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -314,7 +314,9 @@ struct DecodeEnvelopeKey { /// Determine the Pro features that are used in a given conversation message. /// /// Inputs: -/// - `msg_size` -- the size of the message in UTF8 code units to determine if the message requires +/// - `utf` -- the UTF8 string to count the number of codepoints in to determine if it needs the +/// higher character limit available in Session Pro +/// - `utf_size` -- the size of the message in UTF8 code units to determine if the message requires /// access to the higher character limit available in Session Pro /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message @@ -328,14 +330,16 @@ struct DecodeEnvelopeKey { /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf8( - char const* utf8, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); + char const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); /// API: session_protocol/pro_features_for_utf16 /// /// Determine the Pro features that are used in a given conversation message. /// /// Inputs: -/// - `msg_size` -- the size of the message in UTF16 code units to determine if the message requires +/// - `utf` -- the UTF16 string to count the number of codepoints in to determine if it needs the +/// higher character limit available in Session Pro +/// - `utf_size` -- the size of the message in UTF16 code units to determine if the message requires /// access to the higher character limit available in Session Pro /// - `flags` -- extra pro features that are known by clients that they wish to be activated on /// this message @@ -349,7 +353,7 @@ ProFeaturesForMsg pro_features_for_utf8( /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf16( - char16_t const* utf16, size_t utf8_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); + char16_t const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); /// API: session_protocol/pad_message /// From 251df165c2214cef6304e8ca3b5784c7a424d846 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 24 Oct 2025 14:06:33 +1100 Subject: [PATCH 129/171] Use west-const and fix mismatched utf16 parameter for pro_features_for_utf16 --- include/session/session_protocol.hpp | 4 ++-- src/session_protocol.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 9285cae4..e35adff7 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -330,7 +330,7 @@ struct DecodeEnvelopeKey { /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf8( - char const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); + const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); /// API: session_protocol/pro_features_for_utf16 /// @@ -353,7 +353,7 @@ ProFeaturesForMsg pro_features_for_utf8( /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf16( - char16_t const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); + const char16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); /// API: session_protocol/pad_message /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index b139699a..974f19f0 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -221,7 +221,7 @@ ProFeaturesForMsg pro_features_for_utf8( } ProFeaturesForMsg pro_features_for_utf16( - const uint16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { + const char16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); return result; } From 5fd78825b79dbc9dbabd06cd64ae37e845d95904 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 28 Oct 2025 11:28:09 +1100 Subject: [PATCH 130/171] Add one-shot functions to directly generate JSON from request params for the pro backend --- include/session/pro_backend.h | 86 +++++++--- include/session/pro_backend.hpp | 74 ++++++++- src/pro_backend.cpp | 268 +++++++++++++++++++++++++++++++- tests/test_pro_backend.cpp | 91 +++++++++-- 4 files changed, 478 insertions(+), 41 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index a898aa6b..5d333e2c 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -157,6 +157,8 @@ struct session_pro_backend_response_header { typedef struct session_pro_backend_to_json session_pro_backend_to_json; struct session_pro_backend_to_json { + char error[256]; + size_t error_count; bool success; /// True if conversion to JSON was successful, false if out-of-memory string8 json; }; @@ -293,7 +295,7 @@ struct session_pro_backend_get_pro_status_response { /// API: session_pro_backend/add_pro_payment_request_build_sigs /// -/// Builds master and rotating signatures for an AddProPaymentRequest. +/// Builds master and rotating signatures for an `add_pro_payment_request`. /// Returns false if the keys (32-byte or 64-byte libsodium format) or payment token hash are /// incorrectly sized. Using 64-byte libsodium keys is more efficient. /// @@ -310,8 +312,8 @@ struct session_pro_backend_get_pro_status_response { /// - `success` - True if signatures are built successfully, false otherwise. /// - `error` - Backing error buffer for the signatures if `success` is false /// - `errors_count` - length of the error if `success` is false -/// - `master_sig` - Master signature -/// - `rotating_sig` - Rotating signature +/// - `master_sig` - Generated master signature +/// - `rotating_sig` - Generated rotating signature LIBSESSION_EXPORT session_pro_backend_master_rotating_signatures session_pro_backend_add_pro_payment_request_build_sigs( @@ -324,9 +326,27 @@ session_pro_backend_add_pro_payment_request_build_sigs( const uint8_t* payment_tx_payment_id, size_t payment_tx_payment_id_len) NON_NULL_ARG(2, 4, 7); +/// API: session_pro_backend/add_pro_payment_request_build_to_json +/// +/// Builds the JSON for a `add_pro_payment_request`. This function is the same as filling in the +/// struct and calling the corresponding `to_json` function. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +/// +/// See: session_pro_backend_add_pro_payment_request_build_sigs +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_add_pro_payment_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len) NON_NULL_ARG(2, 4, 7); + /// API: session_pro_backend/get_pro_proof_request_build_sigs /// -/// Builds master and rotating signatures for a GetProProofRequest. +/// Builds master and rotating signatures for a `get_pro_proof_request`. /// Returns false if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. /// Using 64-byte libsodium keys is more efficient. /// @@ -353,35 +373,65 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof size_t rotating_privkey_len, uint64_t unix_ts_ms) NON_NULL_ARG(2, 4); +/// API: session_pro_backend/get_pro_proof_request_build_to_json +/// +/// Builds the JSON for a `get_pro_proof_request`. This function is the same as filling in the +/// struct and calling the corresponding `to_json` function. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +/// +/// See: `session_pro_backend_get_pro_proof_request_build_sigs` +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + uint64_t unix_ts_ms) NON_NULL_ARG(2, 4); + /// API: session_pro_backend/get_pro_status_request_build_sig /// -/// Builds the signature for GetProPaymentsRequest -/// Returns false if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. -/// Using 64-byte libsodium keys is more efficient. +/// Builds the JSON for a `get_pro_status_request`. Returns false if the keys (32-byte or +/// 64-byte libsodium format) are incorrectly sized. Using 64-byte libsodium keys is more efficient. /// /// Inputs: /// - `request_version` -- Version of the request. /// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). /// - `master_privkey_len` -- Length of master_privkey. /// - `unix_ts_ms` -- Unix timestamp for the request. -/// - `page` -- The page in the paginated list of historical payments to request +/// - `history` -- Flag to request payment history from the backend /// /// Outputs: -/// - `bool` - True if signature was built successfully, false otherwise. -/// - `error` - Backing error buffer for the signatures if `success` is false -/// - `errors_count` - length of the error if `success` is false -/// - `sig` - 64 byte signature +/// - `bool` -- True if signatures are built successfully, false otherwise. +/// - `error` -- Backing error buffer for the signatures if `success` is false +/// - `errors_count` -- length of the error if `success` is false +/// - `sig` -- The generated signature LIBSESSION_EXPORT session_pro_backend_signature session_pro_backend_get_pro_status_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, - uint32_t page) NON_NULL_ARG(2); + bool history) NON_NULL_ARG(2); + +/// API: session_pro_backend/get_pro_status_request_build_to_json +/// +/// Builds the JSON for a `get_pro_status_request`. This function is the same as filling in the +/// struct and calling the corresponding `to_json` function. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +/// +/// See: `session_pro_backend_get_pro_status_request_build_sig` +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_get_pro_status_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_ms, + bool history) NON_NULL_ARG(2); /// API: session_pro_backend/add_pro_payment_request_to_json /// -/// Serializes an `AddProPaymentRequest` to a JSON string. +/// Serializes an `add_pro_payment_request` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. /// /// Inputs: @@ -392,7 +442,7 @@ session_pro_backend_to_json session_pro_backend_add_pro_payment_request_to_json( /// API: session_pro_backend/get_pro_proof_request_to_json /// -/// Serializes a `GetProProofRequest` to a JSON string. +/// Serializes a `get_pro_proof_request` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. /// /// Inputs: @@ -403,7 +453,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_to_json( /// API: session_pro_backend/get_pro_revocations_request_to_json /// -/// Serializes a `GetProRevocationsRequest` to a JSON string. +/// Serializes a `get_pro_revocations_request` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. LIBSESSION_EXPORT session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_json( @@ -411,7 +461,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_j /// API: session_pro_backend/get_pro_status_request_to_json /// -/// Serializes a `GetProPaymentsRequest` to a JSON string. +/// Serializes a `get_pro_status_request` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. LIBSESSION_EXPORT session_pro_backend_to_json session_pro_backend_get_pro_status_request_to_json( @@ -419,7 +469,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_status_request_to_json( /// API: session_pro_backend/add_pro_payment_or_get_pro_proof_response_parse /// -/// Parses a JSON string into an `AddProPaymentOrGetProProofResponse` struct. +/// Parses a JSON string into an `add_pro_payment_or_get_pro_proof_response` struct. /// The caller must free the response using /// `session_pro_backend_add_pro_payment_or_get_pro_proof_response_free`. /// diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 1474c3c5..5ff8068b 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -15,8 +15,8 @@ /// /// The high level summary of the functionality in this file. Clients can: /// -/// 1. Build a request with `AddProPaymentRequest::to_json` from a Session Pro payment and submit it -/// to the backend to register the specified Ed25519 keys for Session Pro. +/// 1. Build a request with `AddProPaymentRequest::build_to_json` from a Session Pro payment and +/// submit it to the backend to register the specified Ed25519 keys for Session Pro. /// /// Server responds JSON to be parsed with `AddProPaymentOrGetProProofResponse::parse`. Clients /// should validate the response and update their `UserProfile` by constructing a `ProConfig` @@ -47,7 +47,7 @@ /// revoked proofs will not be entitled to Pro features. /// /// 4. Query the status (and optionally payment history) of a user's Session Pro Master Ed25519 key -/// has registered by building a `GetProStatusRequest::to_json` query and submitting it. +/// has registered by building a `GetProStatusRequest::build_to_json` query and submitting it. /// /// Server responds JSON to be parsed with `GetProStatusResponse::parse` which they can use to /// populate their client's payment history. @@ -131,7 +131,10 @@ struct AddProPaymentRequest { /// - `request_version` -- Version of the request to build a hash for /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key - /// - `payment_token_hash` -- 32-byte hash of the payment token. + /// - `payment_tx_provider` -- Provider that the payment to register is coming from + /// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment + /// provider (e.g. for Google this is the transaction order ID in string format, for Apple + /// this is the transaction ID in string format). /// /// Outputs: /// - `MasterRotatingSignatures` - Struct containing the 64-byte master and rotating signatures. @@ -141,6 +144,29 @@ struct AddProPaymentRequest { std::span rotating_privkey, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, std::span payment_tx_payment_id); + + /// API: pro/AddProPaymentRequest::build_to_json + /// + /// Builds a AddProPaymentRequest and serialize it to JSON. This function is the same as filling + /// the struct fields and calling `to_json`. + /// + /// Inputs: + /// - `request_version` -- Version of the request to build a hash for + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key + /// - `payment_tx_provider` -- Provider that the payment to register is coming from + /// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment + /// provider (e.g. for Google this is the transaction order ID in string format, for Apple + /// this is the transaction ID in string format). + /// + /// Outputs: + /// - `std::string` -- Request serialised to JSON + static std::string build_to_json( + std::uint8_t request_version, + std::span master_privkey, + std::span rotating_privkey, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id); }; /// The generated proof from the Session Pro backend that has been parsed from JSON. This structure @@ -186,7 +212,7 @@ struct GetProProofRequest { /// 64-byte signature proving knowledge of the rotating key's secret component array_uc64 rotating_sig; - /// API: pro/MasterRotatingSignatures::build_sigs + /// API: pro/GetProProofRequest::build_sigs /// /// Builds master and rotating signatures using the provided private keys and timestamp. /// Throws if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. @@ -206,6 +232,25 @@ struct GetProProofRequest { std::span rotating_privkey, std::chrono::sys_time unix_ts); + /// API: pro/GetProProofRequest::build_to_json + /// + /// Builds a GetProProofRequest and serialize it to JSON. This function is the same as filling + /// the struct fields and calling `to_json`. + /// + /// Inputs: + /// - `request_version` -- Version of the request to build a request for + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key + /// - `unix_ts` -- Unix timestamp for the request. + /// + /// Outputs: + /// - `std::string` -- Request serialised to JSON + static std::string build_to_json( + std::uint8_t request_version, + std::span master_privkey, + std::span rotating_privkey, + std::chrono::sys_time unix_ts); + /// API: pro/GetProProofRequest::to_json /// /// Serializes the request to a JSON string. @@ -300,6 +345,25 @@ struct GetProStatusRequest { std::chrono::sys_time unix_ts, bool history); + /// API: pro/GetProStatusRequest::build_to_json + /// + /// Builds a GetProStatusRequest and serialize it to JSON. This function is the same as filling + /// the struct fields and calling `to_json`. + /// + /// Inputs: + /// - `version` -- Version of the request to build a request from + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `unix_ts` -- Unix timestamp for the request. + /// - `history` -- Flag to request payment history from the backend + /// + /// Outputs: + /// - `std::string` -- Request serialised to JSON + static std::string build_to_json( + std::uint8_t version, + std::span master_privkey, + std::chrono::sys_time unix_ts, + bool history); + /// API: pro/GetProProofRequest::to_json /// /// Serializes the request to a JSON string. diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index d5147b5b..37c40ad2 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -207,6 +207,56 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( return result; } +std::string AddProPaymentRequest::build_to_json( + std::uint8_t version, + std::span master_privkey, + std::span rotating_privkey, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id) { + cleared_uc64 master_from_seed; + if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + cleared_uc64 rotating_from_seed; + if (rotating_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { + array_uc32 rotating_pubkey; + crypto_sign_ed25519_seed_keypair( + rotating_pubkey.data(), rotating_from_seed.data(), rotating_privkey.data()); + rotating_privkey = rotating_from_seed; + } else if (rotating_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { + throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; + } + + MasterRotatingSignatures sigs = AddProPaymentRequest::build_sigs( + version, master_privkey, rotating_privkey, payment_tx_provider, payment_tx_payment_id); + + AddProPaymentRequest request = {}; + request.version = version; + std::memcpy( + request.master_pkey.data(), + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + std::memcpy( + request.rotating_pkey.data(), + rotating_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + request.payment_tx.provider = payment_tx_provider; + request.payment_tx.payment_id = std::string( + reinterpret_cast(payment_tx_payment_id.data()), + payment_tx_payment_id.size()); + request.master_sig = sigs.master_sig; + request.rotating_sig = sigs.rotating_sig; + + std::string result = request.to_json(); + return result; +} + AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse( std::string_view json) { // Parse basics @@ -312,6 +362,53 @@ MasterRotatingSignatures GetProProofRequest::build_sigs( return result; } +std::string GetProProofRequest::build_to_json( + std::uint8_t request_version, + std::span master_privkey, + std::span rotating_privkey, + std::chrono::sys_time unix_ts) { + // Rederive keys from 32 byte seed if given + cleared_uc64 master_from_seed; + if (master_privkey.size() == 32) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != 64) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + cleared_uc64 rotating_from_seed; + if (rotating_privkey.size() == 32) { + array_uc32 rotating_pubkey; + crypto_sign_ed25519_seed_keypair( + rotating_pubkey.data(), rotating_from_seed.data(), rotating_privkey.data()); + rotating_privkey = rotating_from_seed; + } else if (rotating_privkey.size() != 64) { + throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; + } + + MasterRotatingSignatures sigs = GetProProofRequest::build_sigs( + request_version, master_privkey, rotating_privkey, unix_ts); + + GetProProofRequest request = {}; + request.version = request_version; + std::memcpy( + request.master_pkey.data(), + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + std::memcpy( + request.rotating_pkey.data(), + rotating_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + request.unix_ts = unix_ts; + request.master_sig = sigs.master_sig; + request.rotating_sig = sigs.rotating_sig; + + std::string result = request.to_json(); + return result; +} + std::string GetProRevocationsRequest::to_json() const { nlohmann::json j; j["version"] = version; @@ -427,6 +524,34 @@ array_uc64 GetProStatusRequest::build_sig( return result; } +std::string GetProStatusRequest::build_to_json( + uint8_t version, + std::span master_privkey, + std::chrono::sys_time unix_ts, + bool history) { + cleared_uc64 master_from_seed; + if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + GetProStatusRequest request = {}; + request.version = version; + memcpy(request.master_pkey.data(), + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + request.master_sig = GetProStatusRequest::build_sig(version, master_privkey, unix_ts, history); + request.unix_ts = unix_ts; + request.history = history; + + std::string result = request.to_json(); + return result; +} + GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { // Parse basics GetProStatusResponse result = {}; @@ -633,6 +758,46 @@ session_pro_backend_add_pro_payment_request_build_sigs( return result; } +LIBSESSION_C_API session_pro_backend_to_json +session_pro_backend_add_pro_payment_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len) { + session_pro_backend_to_json result = {}; + + // Convert C inputs to C++ types + std::span master_span(master_privkey, master_privkey_len); + std::span rotating_span(rotating_privkey, rotating_privkey_len); + std::span payment_tx_payment_id_span( + payment_tx_payment_id, payment_tx_payment_id_len); + + try { + std::string json = AddProPaymentRequest::build_to_json( + request_version, + master_span, + rotating_span, + payment_tx_provider, + payment_tx_payment_id_span); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + + return result; +} + LIBSESSION_C_API session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof_request_build_sigs( uint8_t request_version, @@ -669,19 +834,53 @@ session_pro_backend_get_pro_proof_request_build_sigs( return result; } +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + const uint8_t* rotating_privkey, + size_t rotating_privkey_len, + uint64_t unix_ts_ms) { + // Convert C inputs to C++ types + std::span master_span(master_privkey, master_privkey_len); + std::span rotating_span(rotating_privkey, rotating_privkey_len); + std::chrono::milliseconds ts{unix_ts_ms}; + + session_pro_backend_to_json result = {}; + try { + auto json = GetProProofRequest::build_to_json( + request_version, + master_span, + rotating_span, + std::chrono::sys_time(ts)); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_status_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, - uint32_t page) { + bool history) { // Convert C inputs to C++ types std::span master_span{master_privkey, master_privkey_len}; std::chrono::sys_time ts{std::chrono::milliseconds(unix_ts_ms)}; session_pro_backend_signature result = {}; try { - auto sig = GetProStatusRequest::build_sig(request_version, master_span, ts, page); + auto sig = GetProStatusRequest::build_sig(request_version, master_span, ts, history); std::memcpy(result.sig.data, sig.data(), sig.size()); result.success = true; } catch (const std::exception& e) { @@ -696,6 +895,34 @@ LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_statu return result; } +LIBSESSION_C_API session_pro_backend_to_json +session_pro_backend_get_pro_status_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_ms, + bool history) { + // Convert C inputs to C++ types + std::span master_span{master_privkey, master_privkey_len}; + std::chrono::sys_time ts{std::chrono::milliseconds(unix_ts_ms)}; + + session_pro_backend_to_json result = {}; + try { + auto json = GetProStatusRequest::build_to_json(request_version, master_span, ts, history); + result.json = string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment_request_to_json( const session_pro_backend_add_pro_payment_request* request) { session_pro_backend_to_json result = {}; @@ -717,7 +944,14 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment std::string json = cpp.to_json(); result.json = string8_copy_or_throw(json.data(), json.size()); result.success = true; - } catch (...) { + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); } return result; @@ -743,7 +977,14 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_r std::string json = cpp.to_json(); result.json = string8_copy_or_throw(json.data(), json.size()); result.success = true; - } catch (...) { + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); } return result; @@ -765,7 +1006,14 @@ session_pro_backend_get_pro_revocations_request_to_json( std::string json = cpp.to_json(); result.json = string8_copy_or_throw(json.data(), json.size()); result.success = true; - } catch (...) { + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); } return result; @@ -791,8 +1039,16 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_ std::string json = cpp.to_json(); result.json = string8_copy_or_throw(json.data(), json.size()); result.success = true; - } catch (...) { + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); } + return result; } diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 28ebd5f5..fb769ed0 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -223,9 +223,19 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.rotating_pkey = rotating_pubkey; request.payment_tx = payment_tx; - // Note just write some junk to the request - request.master_sig = master_privkey; - request.rotating_sig = rotating_privkey; + session_pro_backend_master_rotating_signatures sigs = + session_pro_backend_add_pro_payment_request_build_sigs( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + rotating_privkey.data, + sizeof(rotating_privkey.data), + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count); + + request.master_sig = sigs.master_sig; + request.rotating_sig = sigs.rotating_sig; // Valid request auto result = session_pro_backend_add_pro_payment_request_to_json(&request); @@ -244,11 +254,26 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { cpp.payment_tx.provider = payment_tx.provider; cpp.payment_tx.payment_id = std::string(payment_tx.payment_id, payment_tx.payment_id_count); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.master_sig.data(), sigs.master_sig.data, sizeof(sigs.master_sig)); std::memcpy( - cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + cpp.rotating_sig.data(), sigs.rotating_sig.data, sizeof(sigs.rotating_sig)); std::string cpp_json = cpp.to_json(); REQUIRE(string8_equals(result.json, cpp_json)); + + // Verify that the helper one-shot-to-json function generates the same payload + auto one_shot = session_pro_backend_add_pro_payment_request_build_to_json( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + rotating_privkey.data, + sizeof(rotating_privkey.data), + request.payment_tx.provider, + reinterpret_cast(request.payment_tx.payment_id), + request.payment_tx.payment_id_count); + REQUIRE(one_shot.success); + REQUIRE(one_shot.json.size == result.json.size); + INFO("One shot: " << one_shot.json.data << "\n\nJSON: " << result.json.data); + REQUIRE(memcmp(one_shot.json.data, result.json.data, result.json.size) == 0); } // After freeing @@ -269,9 +294,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.rotating_pkey = rotating_pubkey; request.unix_ts_ms = unix_ts_ms; - // Note just write some junk to the request - request.master_sig = master_privkey; - request.rotating_sig = rotating_privkey; + session_pro_backend_master_rotating_signatures sigs = + session_pro_backend_get_pro_proof_request_build_sigs( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + rotating_privkey.data, + sizeof(rotating_privkey.data), + request.unix_ts_ms); + + request.master_sig = sigs.master_sig; + request.rotating_sig = sigs.rotating_sig; // Valid request auto result = session_pro_backend_get_pro_proof_request_to_json(&request); @@ -289,11 +322,24 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { cpp.rotating_pkey.data(), rotating_pubkey.data, sizeof(rotating_pubkey)); cpp.unix_ts = std::chrono::sys_time( std::chrono::milliseconds{unix_ts_ms}); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.master_sig.data(), sigs.master_sig.data, sizeof(sigs.master_sig)); std::memcpy( - cpp.rotating_sig.data(), rotating_privkey.data, sizeof(rotating_privkey)); + cpp.rotating_sig.data(), sigs.rotating_sig.data, sizeof(sigs.rotating_sig)); std::string cpp_json = cpp.to_json(); REQUIRE(string8_equals(result.json, cpp_json)); + + // Verify that the helper one-shot-to-json function generates the same payload + auto one_shot = session_pro_backend_get_pro_proof_request_build_to_json( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + rotating_privkey.data, + sizeof(rotating_privkey.data), + request.unix_ts_ms); + REQUIRE(one_shot.success); + REQUIRE(one_shot.json.size == result.json.size); + INFO("One shot: " << one_shot.json.data << "\n\nJSON: " << result.json.data); + REQUIRE(memcmp(one_shot.json.data, result.json.data, result.json.size) == 0); } // After freeing @@ -343,10 +389,19 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_status_request request = {}; request.version = 0; request.master_pkey = master_pubkey; - request.master_sig = master_privkey; // Write some junk request.unix_ts_ms = unix_ts_ms; request.history = true; + session_pro_backend_signature sig = + session_pro_backend_get_pro_status_request_build_sig( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + request.unix_ts_ms, + request.history); + + request.master_sig = sig.sig; + // Valid request auto result = session_pro_backend_get_pro_status_request_to_json(&request); { @@ -359,12 +414,24 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { GetProStatusRequest cpp = {}; cpp.version = 0; std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); - std::memcpy(cpp.master_sig.data(), master_privkey.data, sizeof(master_privkey)); + std::memcpy(cpp.master_sig.data(), sig.sig.data, sizeof(sig.sig)); cpp.unix_ts = std::chrono::sys_time{ std::chrono::milliseconds{unix_ts_ms}}; cpp.history = request.history; std::string cpp_json = cpp.to_json(); REQUIRE(string8_equals(result.json, cpp_json)); + + // Verify that the helper one-shot-to-json function generates the same payload + auto one_shot = session_pro_backend_get_pro_status_request_build_to_json( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + request.unix_ts_ms, + request.history); + REQUIRE(one_shot.success); + REQUIRE(one_shot.json.size == result.json.size); + INFO("One shot: " << one_shot.json.data << "\n\nJSON: " << result.json.data); + REQUIRE(memcmp(one_shot.json.data, result.json.data, result.json.size) == 0); } // After freeing From 17026faf020d18f4429bc049a9c5146a65c930e3 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 28 Oct 2025 16:36:51 +1100 Subject: [PATCH 131/171] Update ed25519 session pro key naming convention to privkey This is more accurate as we are returning just the 64 byte libsodium style private key, not the public and private key std::pair (32, 64b) respectively which is what other functions use the `keypair` nomenclamenture to denote. --- include/session/ed25519.h | 4 ++-- include/session/ed25519.hpp | 4 ++-- src/ed25519.cpp | 10 +++++----- tests/test_ed25519.cpp | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/session/ed25519.h b/include/session/ed25519.h index 9418154d..573a66fe 100644 --- a/include/session/ed25519.h +++ b/include/session/ed25519.h @@ -95,7 +95,7 @@ LIBSESSION_EXPORT bool session_ed25519_verify( const unsigned char* msg, size_t msg_len); -/// API: crypto/session_ed25519_pro_key_pair_for_ed25519_seed +/// API: crypto/session_ed25519_pro_privkey_for_ed25519_seed /// /// Generate the deterministic Master Session Pro key for signing requests to interact with the /// Session Pro features of the protocol. @@ -108,7 +108,7 @@ LIBSESSION_EXPORT bool session_ed25519_verify( /// /// Outputs: /// - `bool` -- True if the key pair was successfully derived, false if failed. -LIBSESSION_EXPORT bool session_ed25519_pro_key_pair_for_ed25519_seed( +LIBSESSION_EXPORT bool session_ed25519_pro_privkey_for_ed25519_seed( const unsigned char* ed25519_seed, /* 32 bytes */ unsigned char* ed25519_sk_out /*64 byte output buffer*/); diff --git a/include/session/ed25519.hpp b/include/session/ed25519.hpp index d4a7b892..8a6de921 100644 --- a/include/session/ed25519.hpp +++ b/include/session/ed25519.hpp @@ -56,7 +56,7 @@ bool verify( std::span pubkey, std::span msg); -/// API: ed25519/ed25519_pro_key_pair_for_ed25519_seed +/// API: ed25519/ed25519_pro_privkey_for_ed25519_seed /// /// Generate the deterministic Master Session Pro key for signing requests to interact with the /// Session Pro features of the protocol. @@ -67,7 +67,7 @@ bool verify( /// /// Outputs: /// - The libsodium-style Master Session Pro Ed25519 secret key, 64 bytes. -std::array ed25519_pro_key_pair_for_ed25519_seed( +std::array ed25519_pro_privkey_for_ed25519_seed( std::span ed25519_seed); } // namespace session::ed25519 diff --git a/src/ed25519.cpp b/src/ed25519.cpp index 3cc5dc17..bce3d269 100644 --- a/src/ed25519.cpp +++ b/src/ed25519.cpp @@ -14,7 +14,7 @@ using uc32 = std::array; using uc64 = std::array; namespace { -uc64 derived_ed25519_keypair(std::span ed25519_seed, std::string_view key) { +uc64 derived_ed25519_privkey(std::span ed25519_seed, std::string_view key) { if (ed25519_seed.size() != 32 && ed25519_seed.size() != 64) throw std::invalid_argument{ "Invalid ed25519_seed: expected 32 bytes or libsodium style 64 bytes seed"}; @@ -109,9 +109,9 @@ bool verify( crypto_sign_ed25519_verify_detached(sig.data(), msg.data(), msg.size(), pubkey.data())); } -std::array ed25519_pro_key_pair_for_ed25519_seed( +std::array ed25519_pro_privkey_for_ed25519_seed( std::span ed25519_seed) { - auto result = derived_ed25519_keypair(ed25519_seed, "SessionProRandom"); + auto result = derived_ed25519_privkey(ed25519_seed, "SessionProRandom"); return result; } } // namespace session::ed25519 @@ -186,11 +186,11 @@ LIBSESSION_C_API bool session_ed25519_verify( std::span{msg, msg_len}); } -LIBSESSION_C_API bool session_ed25519_pro_key_pair_for_ed25519_seed( +LIBSESSION_C_API bool session_ed25519_pro_privkey_for_ed25519_seed( const unsigned char* ed25519_seed, unsigned char* ed25519_sk_out) { try { auto seed = std::span(ed25519_seed, 32); - uc64 sk = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed); + uc64 sk = session::ed25519::ed25519_pro_privkey_for_ed25519_seed(seed); std::memcpy(ed25519_sk_out, sk.data(), sk.size()); return true; } catch (...) { diff --git a/tests/test_ed25519.cpp b/tests/test_ed25519.cpp index c04bf2cb..e82092af 100644 --- a/tests/test_ed25519.cpp +++ b/tests/test_ed25519.cpp @@ -99,9 +99,9 @@ TEST_CASE("Ed25519 pro key pair generation seed", "[ed25519][keypair]") { constexpr auto seed2 = "743d646706b6b04b97b752036dd6cf5f2adc4b339fcfdfb4b496f0764bb93a84"_hex_u; constexpr auto seed_invalid = "010203040506070809"_hex_u; - auto sk1 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed1); - auto sk2 = session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed2); - CHECK_THROWS(session::ed25519::ed25519_pro_key_pair_for_ed25519_seed(seed_invalid)); + auto sk1 = session::ed25519::ed25519_pro_privkey_for_ed25519_seed(seed1); + auto sk2 = session::ed25519::ed25519_pro_privkey_for_ed25519_seed(seed2); + CHECK_THROWS(session::ed25519::ed25519_pro_privkey_for_ed25519_seed(seed_invalid)); CHECK(sk1.size() == 64); CHECK(sk1 != sk2); From 48eacaf83bd4cf71dcc1ad483651af58c6a654d8 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 29 Oct 2025 16:30:26 +1100 Subject: [PATCH 132/171] Add missing string_view from config/encrypt.hpp --- include/session/config/encrypt.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/session/config/encrypt.hpp b/include/session/config/encrypt.hpp index df0911a1..b4b46ef4 100644 --- a/include/session/config/encrypt.hpp +++ b/include/session/config/encrypt.hpp @@ -2,10 +2,9 @@ #include #include +#include #include -#include "../types.hpp" - namespace session::config { /// API: encrypt/encrypt From 38c26a7671302f32905d5d6e0a33e66ba6e879bd Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 30 Oct 2025 09:53:01 +1100 Subject: [PATCH 133/171] Add missing dllexport via LIBSESSION_EXPORT to protocol API; fix incorrect EXPORT in impl --- include/session/session_encrypt.h | 2 +- include/session/session_protocol.h | 2 +- src/session_protocol.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/session/session_encrypt.h b/include/session/session_encrypt.h index a08c4612..fa220ca8 100644 --- a/include/session/session_encrypt.h +++ b/include/session/session_encrypt.h @@ -281,7 +281,7 @@ typedef struct session_decrypt_group_message_result { /// required to write the error. Both counts include the null-terminator. The user must allocate /// at minimum the requested length, including the null-terminator in order for the error message /// to be preserved in full. -session_decrypt_group_message_result session_decrypt_group_message( +LIBSESSION_EXPORT session_decrypt_group_message_result session_decrypt_group_message( const span_u8* decrypt_ed25519_privkey_list, size_t decrypt_ed25519_privkey_len, const unsigned char* group_ed25519_pubkey, diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index d098c559..cc593104 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -732,7 +732,7 @@ LIBSESSION_EXPORT void session_protocol_decode_envelope_free( /// /// If the `status` is set to valid the the caller can proceed with entitling the envelope with /// access to pro features if it's using any. -session_protocol_decoded_community_message session_protocol_decode_for_community( +LIBSESSION_EXPORT session_protocol_decoded_community_message session_protocol_decode_for_community( const void* content_or_envelope_payload, size_t content_or_envelope_payload_len, uint64_t unix_ts_ms, diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 974f19f0..ec2e264b 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1485,7 +1485,7 @@ session_protocol_decoded_community_message session_protocol_decode_for_community return result; } -LIBSESSION_EXPORT void session_protocol_decode_for_community_free( +LIBSESSION_C_API void session_protocol_decode_for_community_free( session_protocol_decoded_community_message* community_msg) { if (community_msg) { free(community_msg->content_plaintext.data); From 51cc7fad3b08ebc4b7d42c989ffe3145f576c74e Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 31 Oct 2025 14:29:18 +1100 Subject: [PATCH 134/171] Identify when message exceeds max limits in pro_features_for_utf8/16 --- include/session/session_protocol.h | 8 +++++- include/session/session_protocol.hpp | 12 +++++++- src/session_protocol.cpp | 18 ++++++++---- tests/test_session_protocol.cpp | 41 ++++++++++++++++++++++++---- 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index cc593104..b0ede726 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -72,6 +72,12 @@ enum SESSION_PROTOCOL_PRO_FEATURES_ { SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR }; +typedef enum SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS { // See session::ProFeaturesForMsgStatus + SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS, + SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_UTF_DECODING_ERROR, + SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_EXCEEDS_CHARACTER_LIMIT, +} SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS; + typedef enum SESSION_PROTOCOL_DESTINATION_TYPE { // See session::DestinationType SESSION_PROTOCOL_DESTINATION_TYPE_SYNC_OR_1O1, SESSION_PROTOCOL_DESTINATION_TYPE_GROUP, @@ -266,7 +272,7 @@ LIBSESSION_EXPORT SESSION_PROTOCOL_PRO_STATUS session_protocol_pro_proof_status( /// API: session_protocol/session_protocol_get_pro_features_for_msg typedef struct session_protocol_pro_features_for_msg { - bool success; + SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS status; string8 error; SESSION_PROTOCOL_PRO_FEATURES features; size_t codepoint_count; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index e35adff7..ecac36ed 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -168,8 +168,18 @@ class ProProof { array_uc32 hash() const; }; +enum class ProFeaturesForMsgStatus { + Success = SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS, + + /// Message byte stream to classify could not be decoded into a valid UTF8/16 string + UTFDecodingError = SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_UTF_DECODING_ERROR, + + /// Decoded UTF8/16 string exceeded the maximum character limit allowed for Session Pro + ExceedsCharacterLimit = SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_EXCEEDS_CHARACTER_LIMIT, +}; + struct ProFeaturesForMsg { - bool success; + ProFeaturesForMsgStatus status; std::string_view error; SESSION_PROTOCOL_PRO_FEATURES features; size_t codepoint_count; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index ec2e264b..e2d305c4 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -191,12 +191,19 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( : simdutf::validate_utf16_with_errors( reinterpret_cast(utf), utf_size); if (validate.is_ok()) { - result.success = true; + result.status = session::ProFeaturesForMsgStatus::Success; result.codepoint_count = is_utf8 ? simdutf::count_utf8(reinterpret_cast(utf), utf_size) : simdutf::count_utf16(reinterpret_cast(utf), utf_size); - if (result.codepoint_count > SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT) - result.features |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + if (result.codepoint_count > SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT) { + if (result.codepoint_count <= SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT) { + result.features |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + } else { + result.error = "Message exceeds the maximum character limit allowed"; + result.status = session::ProFeaturesForMsgStatus::ExceedsCharacterLimit; + } + } if (extra & SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR) result.features |= SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR; @@ -206,6 +213,7 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( assert((result.features & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) == 0); } else { + result.status = session::ProFeaturesForMsgStatus::UTFDecodingError; result.error = simdutf::error_to_string(validate.error); } return result; @@ -1119,7 +1127,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( ProFeaturesForMsg result_cpp = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); session_protocol_pro_features_for_msg result = { - .success = result_cpp.success, + .status = static_cast(result_cpp.status), .error = {const_cast(result_cpp.error.data()), result_cpp.error.size()}, .features = result_cpp.features, .codepoint_count = result_cpp.codepoint_count, @@ -1133,7 +1141,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( ProFeaturesForMsg result_cpp = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); session_protocol_pro_features_for_msg result = { - .success = result_cpp.success, + .status = static_cast(result_cpp.status), .error = {const_cast(result_cpp.error.data()), result_cpp.error.size()}, .features = result_cpp.features, .codepoint_count = result_cpp.codepoint_count, diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index d6357f05..5fd605c7 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -111,7 +111,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { msg.size(), SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(pro_msg.success); + REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); REQUIRE(pro_msg.codepoint_count == msg.size()); @@ -122,11 +122,12 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { std::string_view msg = "\xFF"; session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), SESSION_PROTOCOL_PRO_FEATURES_NIL); - REQUIRE(!pro_msg.success); + REQUIRE(pro_msg.status == + SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_UTF_DECODING_ERROR); REQUIRE(pro_msg.error.size); } - // Try a message exceeding the size threshold + // Try a message exceeding the standard size threshold { auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT + 1, 'a'); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( @@ -134,19 +135,49 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { msg.size(), SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); - REQUIRE(pro_msg.success); + REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); REQUIRE(pro_msg.codepoint_count == msg.size()); } + // Try a message at the max size threshold + { + auto msg = std::string(SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT, 'a'); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), + msg.size(), + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); + REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); + REQUIRE(pro_msg.codepoint_count == msg.size()); + } + + // Try a message at the (max size + 1) threshold + { + auto msg = std::string(SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT + 1, 'a'); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), + msg.size(), + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + REQUIRE(pro_msg.status == + SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_EXCEEDS_CHARACTER_LIMIT); + REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); + REQUIRE(pro_msg.codepoint_count == msg.size()); + } + // Try asking for just one extra feature { auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT, 'a'); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE); - REQUIRE(pro_msg.success); + REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); REQUIRE(pro_msg.codepoint_count == msg.size()); } From 010a2e424316dfb9c23725ec546ca25329556b1f Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 31 Oct 2025 15:43:34 +1100 Subject: [PATCH 135/171] Add constant for the max number of pinned convos for non-pro users --- include/session/session_protocol.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index b0ede726..d66c98a7 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -23,6 +23,11 @@ enum { /// definitions for users of the library to consume. SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT = 10000, + /// Amount of conversations that a user without Session Pro can pin + SESSION_PROTOCOL_PRO_STANDARD_PINNED_CONVERSATION_LIMIT = 5, + + /// Amount of bytes that a community or 1o1 message `Content` must be padded by before wrapping + /// in an envelope. SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING = 160, }; From 0d6f9ec06cd1678059897d07b9d7f151a8c6171a Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 31 Oct 2025 16:25:02 +1100 Subject: [PATCH 136/171] Move C helper functions that throw into C++ land C functions that throw cannot be extern "C"-ed because they throw and C doesn't support C++ exceptions so move them into the .hpp file which is only used in C++ files. --- include/session/types.h | 16 ---------------- include/session/types.hpp | 19 +++++++++++++++++++ src/pro_backend.cpp | 14 +++++++------- src/session_encrypt.cpp | 7 ++++--- src/session_protocol.cpp | 7 ++++--- src/types.cpp | 27 +++++++++++++++------------ 6 files changed, 49 insertions(+), 41 deletions(-) diff --git a/include/session/types.h b/include/session/types.h index 4db935e6..5029cab3 100644 --- a/include/session/types.h +++ b/include/session/types.h @@ -52,16 +52,6 @@ struct arena_t { size_t max; }; -/// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this -/// function throws a runtime exception. The `data` pointer is span must be freed once the span -/// is no longer needed. -span_u8 span_u8_alloc_or_throw(size_t size); - -/// Create a span of bytes that copies the payload at `data` for `size` bytes. If allocation fails -/// this function throws a runtime exception. The `data` pointer is span must be freed once the span -/// is no longer needed. -span_u8 span_u8_copy_or_throw(const void* data, size_t size); - /// A wrapper around snprintf that fixes a common bug in the value the printing function returns /// when a buffer is passed in. Irrespective of whether a buffer is passed in, snprintf is defined /// to return: @@ -80,12 +70,6 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size); /// entire string (as per normal snprintf behaviour). int snprintf_clamped(char* buffer, size_t size, char const* fmt, ...); -/// Allocate the string with the specific size. Throws on allocation failure. -string8 string8_alloc_or_throw(size_t size); - -/// Create a string by copying the given pointer and size. Throws on allocation failure -string8 string8_copy_or_throw(const void* data, size_t size); - /// Allocate memory from the basic bump allocating arena. Returns a null pointer on failure. void* arena_alloc(arena_t* arena, size_t bytes); diff --git a/include/session/types.hpp b/include/session/types.hpp index b66f39ba..d28dbc14 100644 --- a/include/session/types.hpp +++ b/include/session/types.hpp @@ -1,8 +1,11 @@ #pragma once #include +#include #include +#include "types.h" + namespace session { template @@ -24,4 +27,20 @@ enum class SessionIDPrefix { namespace config { using seqno_t = std::int64_t; } + +/// Create a span of bytes that owns the `size` bytes of memory requested. If allocation fails, this +/// function throws a runtime exception. The `data` pointer is span must be freed once the span +/// is no longer needed. +span_u8 span_u8_alloc_or_throw(size_t size); + +/// Create a span of bytes that copies the payload at `data` for `size` bytes. If allocation fails +/// this function throws a runtime exception. The `data` pointer is span must be freed once the span +/// is no longer needed. +span_u8 span_u8_copy_or_throw(const void* data, size_t size); + +/// Allocate the string with the specific size. Throws on allocation failure. +string8 string8_alloc_or_throw(size_t size); + +/// Create a string by copying the given pointer and size. Throws on allocation failure +string8 string8_copy_or_throw(const void* data, size_t size); } // namespace session diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 37c40ad2..835a2290 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -783,7 +783,7 @@ session_pro_backend_add_pro_payment_request_build_to_json( rotating_span, payment_tx_provider, payment_tx_payment_id_span); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); @@ -854,7 +854,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_j master_span, rotating_span, std::chrono::sys_time(ts)); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); @@ -909,7 +909,7 @@ session_pro_backend_get_pro_status_request_build_to_json( session_pro_backend_to_json result = {}; try { auto json = GetProStatusRequest::build_to_json(request_version, master_span, ts, history); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); @@ -942,7 +942,7 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment try { std::string json = cpp.to_json(); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); @@ -975,7 +975,7 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_r try { std::string json = cpp.to_json(); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); @@ -1004,7 +1004,7 @@ session_pro_backend_get_pro_revocations_request_to_json( try { std::string json = cpp.to_json(); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); @@ -1037,7 +1037,7 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_ try { std::string json = cpp.to_json(); - result.json = string8_copy_or_throw(json.data(), json.size()); + result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { const std::string& error = e.what(); diff --git a/src/session_encrypt.cpp b/src/session_encrypt.cpp index 3246f8b8..ec4ffe23 100644 --- a/src/session_encrypt.cpp +++ b/src/session_encrypt.cpp @@ -27,6 +27,7 @@ #include "session/blinding.hpp" #include "session/sodium_array.hpp" +#include "session/types.hpp" using namespace std::literals; @@ -1138,7 +1139,7 @@ LIBSESSION_C_API session_encrypt_group_message session_encrypt_for_group( padding); result = { .success = true, - .ciphertext = span_u8_copy_or_throw(result_cpp.data(), result_cpp.size()), + .ciphertext = session::span_u8_copy_or_throw(result_cpp.data(), result_cpp.size()), }; } catch (const std::exception& e) { std::string error_cpp = e.what(); @@ -1250,8 +1251,8 @@ LIBSESSION_C_API session_decrypt_group_message_result session_decrypt_group_mess result = { .success = true, .index = index, - .plaintext = - span_u8_copy_or_throw(result.plaintext.data, result.plaintext.size), + .plaintext = session::span_u8_copy_or_throw( + result.plaintext.data, result.plaintext.size), }; assert(result_cpp.session_id.size() == sizeof(result.session_id)); std::memcpy(result.session_id, result_cpp.session_id.data(), sizeof(result.session_id)); diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index e2d305c4..ce546fc9 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "SessionProtos.pb.h" #include "WebSocketResources.pb.h" @@ -464,7 +465,7 @@ static EncryptedForDestinationInternal encode_for_destination_internal( if (use_malloc == UseMalloc::Yes) { result.ciphertext_c = - span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); + session::span_u8_copy_or_throw(ciphertext.data(), ciphertext.size()); } else { result.ciphertext_cpp = std::move(ciphertext); } @@ -1389,7 +1390,7 @@ session_protocol_decoded_envelope session_protocol_decode_envelope( // Marshall into c type try { - result.content_plaintext = span_u8_copy_or_throw( + result.content_plaintext = session::span_u8_copy_or_throw( result_cpp.content_plaintext.data(), result_cpp.content_plaintext.size()); } catch (const std::exception& e) { std::string error_cpp = e.what(); @@ -1469,7 +1470,7 @@ session_protocol_decoded_community_message session_protocol_decode_for_community if (result.has_envelope) result.envelope = envelope_from_cpp(*decoded.envelope); - result.content_plaintext = span_u8_copy_or_throw( + result.content_plaintext = session::span_u8_copy_or_throw( decoded.content_plaintext.data(), decoded.content_plaintext.size()); result.content_plaintext_unpadded_size = decoded.content_plaintext_unpadded_size; result.has_pro = decoded.pro.has_value(); diff --git a/src/types.cpp b/src/types.cpp index 6032a74f..5efa976d 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -2,7 +2,9 @@ #include #include +#include +namespace session { span_u8 span_u8_alloc_or_throw(size_t size) { span_u8 result = {}; result.size = size; @@ -19,18 +21,6 @@ span_u8 span_u8_copy_or_throw(const void* data, size_t size) { return result; } -int snprintf_clamped(char* buffer, size_t size, char const* fmt, ...) { - va_list args; - va_start(args, fmt); - int bytes_required_not_incl_null = vsnprintf(buffer, size, fmt, args); - va_end(args); - - int result = bytes_required_not_incl_null; - if (buffer && size && bytes_required_not_incl_null >= (size - 1)) - result = size - 1; - return result; -} - string8 string8_alloc_or_throw(size_t size) { string8 result = {}; result.size = size; @@ -48,6 +38,19 @@ string8 string8_copy_or_throw(const void* data, size_t size) { result.data[result.size] = 0; return result; } +}; // namespace session + +int snprintf_clamped(char* buffer, size_t size, char const* fmt, ...) { + va_list args; + va_start(args, fmt); + int bytes_required_not_incl_null = vsnprintf(buffer, size, fmt, args); + va_end(args); + + int result = bytes_required_not_incl_null; + if (buffer && size && bytes_required_not_incl_null >= (size - 1)) + result = size - 1; + return result; +} void* arena_alloc(arena_t* arena, size_t bytes) { void* result = nullptr; From 32bda61d0a108841c773a02271ad8dd377eba3c7 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 3 Nov 2025 14:20:05 +1100 Subject: [PATCH 137/171] Change get_pro_status history to accept a count --- include/session/pro_backend.h | 9 +++++---- include/session/pro_backend.hpp | 16 ++++++++++------ src/pro_backend.cpp | 26 ++++++++++++++------------ src/session_protocol.cpp | 2 +- tests/test_pro_backend.cpp | 16 +++++++++------- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 5d333e2c..0f8ec636 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -247,7 +247,7 @@ struct session_pro_backend_get_pro_status_request { bytes32 master_pkey; bytes64 master_sig; uint64_t unix_ts_ms; - bool history; + uint32_t count; }; typedef struct session_pro_backend_pro_payment_item session_pro_backend_pro_payment_item; @@ -291,6 +291,7 @@ struct session_pro_backend_get_pro_status_response { bool auto_renewing; uint64_t expiry_unix_ts_ms; uint64_t grace_period_duration_ms; + uint32_t payments_total; }; /// API: session_pro_backend/add_pro_payment_request_build_sigs @@ -399,7 +400,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_j /// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). /// - `master_privkey_len` -- Length of master_privkey. /// - `unix_ts_ms` -- Unix timestamp for the request. -/// - `history` -- Flag to request payment history from the backend +/// - `count` -- Amount of historical payments to request /// /// Outputs: /// - `bool` -- True if signatures are built successfully, false otherwise. @@ -412,7 +413,7 @@ session_pro_backend_signature session_pro_backend_get_pro_status_request_build_s const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, - bool history) NON_NULL_ARG(2); + uint32_t count) NON_NULL_ARG(2); /// API: session_pro_backend/get_pro_status_request_build_to_json /// @@ -427,7 +428,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_status_request_build_to_ const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, - bool history) NON_NULL_ARG(2); + uint32_t count) NON_NULL_ARG(2); /// API: session_pro_backend/add_pro_payment_request_to_json /// diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 5ff8068b..94fb4387 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -322,8 +322,8 @@ struct GetProStatusRequest { /// Unix timestamp of the request std::chrono::sys_time unix_ts; - /// Flag to request payment history from the backend - bool history; + /// Max amount of historical payments to request from the backend + uint32_t count; /// API: pro/AddProPaymentRequest::build_sigs /// @@ -335,7 +335,7 @@ struct GetProStatusRequest { /// - `request_version` -- Version of the request to build a hash for /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key /// - `unix_ts` -- Unix timestamp for the request. - /// - `history` -- Flag to request payment history from the backend + /// - `count` -- Amount of historical payments to request /// /// Outputs: /// - `array_uc64` - the 64-byte signature @@ -343,7 +343,7 @@ struct GetProStatusRequest { uint8_t version, std::span master_privkey, std::chrono::sys_time unix_ts, - bool history); + uint32_t count); /// API: pro/GetProStatusRequest::build_to_json /// @@ -354,7 +354,7 @@ struct GetProStatusRequest { /// - `version` -- Version of the request to build a request from /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key /// - `unix_ts` -- Unix timestamp for the request. - /// - `history` -- Flag to request payment history from the backend + /// - `count` -- Amount of historical payments to request /// /// Outputs: /// - `std::string` -- Request serialised to JSON @@ -362,7 +362,7 @@ struct GetProStatusRequest { std::uint8_t version, std::span master_privkey, std::chrono::sys_time unix_ts, - bool history); + uint32_t count); /// API: pro/GetProProofRequest::to_json /// @@ -485,6 +485,10 @@ struct GetProStatusResponse : public ResponseHeader { /// subtracting `expiry_unix_ts_ms` from this value. std::chrono::milliseconds grace_period_duration_ms; + /// Total number of payments known by the backend for the user. This may be greater than the + /// length of items if the request, requested less than the number of payments the user has. + uint32_t payments_total; + /// API: pro/GetProStatusResponse::parse /// /// Parses a JSON string into the response struct. diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 835a2290..819cee6f 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -475,7 +475,7 @@ std::string GetProStatusRequest::to_json() const { j["master_pkey"] = oxenc::to_hex(master_pkey); j["master_sig"] = oxenc::to_hex(master_sig); j["unix_ts_ms"] = unix_ts.time_since_epoch().count(); - j["history"] = history; + j["count"] = count; std::string result = j.dump(); return result; } @@ -484,7 +484,7 @@ array_uc64 GetProStatusRequest::build_sig( uint8_t version, std::span master_privkey, std::chrono::sys_time unix_ts, - bool history) { + uint32_t count) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; @@ -508,9 +508,8 @@ array_uc64 GetProStatusRequest::build_sig( crypto_sign_ed25519_PUBLICKEYBYTES); crypto_generichash_blake2b_update( &state, reinterpret_cast(&unix_ts_ms), sizeof(unix_ts_ms)); - uint8_t history_u8 = history; crypto_generichash_blake2b_update( - &state, reinterpret_cast(&history_u8), sizeof(history_u8)); + &state, reinterpret_cast(&count), sizeof(count)); crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash @@ -528,7 +527,7 @@ std::string GetProStatusRequest::build_to_json( uint8_t version, std::span master_privkey, std::chrono::sys_time unix_ts, - bool history) { + uint32_t count) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; @@ -544,9 +543,9 @@ std::string GetProStatusRequest::build_to_json( memcpy(request.master_pkey.data(), master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); - request.master_sig = GetProStatusRequest::build_sig(version, master_privkey, unix_ts, history); + request.master_sig = GetProStatusRequest::build_sig(version, master_privkey, unix_ts, count); request.unix_ts = unix_ts; - request.history = history; + request.count = count; std::string result = request.to_json(); return result; @@ -592,6 +591,8 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { result.auto_renewing = json_require(result_obj, "auto_renewing", result.errors); + result.payments_total = json_require(result_obj, "payments_total", result.errors); + uint64_t expiry_unix_ts_ms = json_require(result_obj, "expiry_unix_ts_ms", result.errors); uint64_t grace_period_duration_ms = @@ -873,14 +874,14 @@ LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_statu const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, - bool history) { + uint32_t count) { // Convert C inputs to C++ types std::span master_span{master_privkey, master_privkey_len}; std::chrono::sys_time ts{std::chrono::milliseconds(unix_ts_ms)}; session_pro_backend_signature result = {}; try { - auto sig = GetProStatusRequest::build_sig(request_version, master_span, ts, history); + auto sig = GetProStatusRequest::build_sig(request_version, master_span, ts, count); std::memcpy(result.sig.data, sig.data(), sig.size()); result.success = true; } catch (const std::exception& e) { @@ -901,14 +902,14 @@ session_pro_backend_get_pro_status_request_build_to_json( const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, - bool history) { + uint32_t count) { // Convert C inputs to C++ types std::span master_span{master_privkey, master_privkey_len}; std::chrono::sys_time ts{std::chrono::milliseconds(unix_ts_ms)}; session_pro_backend_to_json result = {}; try { - auto json = GetProStatusRequest::build_to_json(request_version, master_span, ts, history); + auto json = GetProStatusRequest::build_to_json(request_version, master_span, ts, count); result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { @@ -1033,7 +1034,7 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_ std::memcpy(cpp.master_sig.data(), request->master_sig.data, sizeof(request->master_sig.data)); cpp.unix_ts = std::chrono::sys_time{ std::chrono::milliseconds{request->unix_ts_ms}}; - cpp.history = request->history; + cpp.count = request->count; try { std::string json = cpp.to_json(); @@ -1227,6 +1228,7 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ result.auto_renewing = cpp.auto_renewing; result.expiry_unix_ts_ms = cpp.expiry_unix_ts_ms.time_since_epoch().count(); result.grace_period_duration_ms = cpp.grace_period_duration_ms.count(); + result.payments_total = cpp.payments_total; for (size_t index = 0; index < result.items_count; ++index) { const ProPaymentItem& src = cpp.items[index]; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index ce546fc9..5dbfb38d 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include "SessionProtos.pb.h" #include "WebSocketResources.pb.h" diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index fb769ed0..75afa723 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -390,7 +390,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.version = 0; request.master_pkey = master_pubkey; request.unix_ts_ms = unix_ts_ms; - request.history = true; + request.count = 10'000; session_pro_backend_signature sig = session_pro_backend_get_pro_status_request_build_sig( @@ -398,7 +398,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { master_privkey.data, sizeof(master_privkey.data), request.unix_ts_ms, - request.history); + request.count); request.master_sig = sig.sig; @@ -417,7 +417,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::memcpy(cpp.master_sig.data(), sig.sig.data, sizeof(sig.sig)); cpp.unix_ts = std::chrono::sys_time{ std::chrono::milliseconds{unix_ts_ms}}; - cpp.history = request.history; + cpp.count = request.count; std::string cpp_json = cpp.to_json(); REQUIRE(string8_equals(result.json, cpp_json)); @@ -427,7 +427,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { master_privkey.data, sizeof(master_privkey.data), request.unix_ts_ms, - request.history); + request.count); REQUIRE(one_shot.success); REQUIRE(one_shot.json.size == result.json.size); INFO("One shot: " << one_shot.json.data << "\n\nJSON: " << result.json.data); @@ -619,6 +619,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"auto_renewing", true}, {"expiry_unix_ts_ms", unix_ts_ms + 2}, {"grace_period_duration_ms", 1000}, + {"payments_total", 3}, {"items", nlohmann::json::array( {{{"status", SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED}, @@ -656,6 +657,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.auto_renewing == true); REQUIRE(result.grace_period_duration_ms == 1000); REQUIRE(result.expiry_unix_ts_ms == unix_ts_ms + 2); + REQUIRE(result.payments_total == 3); REQUIRE(result.items != nullptr); REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED); REQUIRE(result.items[0].plan == SESSION_PRO_BACKEND_PLAN_ONE_MONTH); @@ -885,7 +887,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.version = 0; request.master_pkey = master_pubkey; request.unix_ts_ms = time(nullptr) * 1000; - request.history = true; + request.count = 10'000; session_pro_backend_signature sig = session_pro_backend_get_pro_status_request_build_sig( @@ -893,7 +895,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { master_privkey.data, sizeof(master_privkey.data), request.unix_ts_ms, - request.history); + request.count); REQUIRE(sig.success); request.master_sig = sig.sig; @@ -943,7 +945,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { master_privkey.data, sizeof(master_privkey.data), request.unix_ts_ms, - request.history); + request.count); REQUIRE(sig.success); request.master_sig = sig.sig; From 8cfa064d0a1edcf1d7ce467dcc4c3da81efd5cb3 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 7 Nov 2025 12:13:45 +1100 Subject: [PATCH 138/171] Add missing order ID to the payment tx for the pro backend --- include/session/pro_backend.h | 19 ++++-- include/session/pro_backend.hpp | 34 ++++++++--- src/pro_backend.cpp | 62 ++++++++++++++++--- tests/test_pro_backend.cpp | 102 ++++++++++++++++++++++---------- 4 files changed, 168 insertions(+), 49 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 0f8ec636..7f8b642d 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -187,6 +187,8 @@ struct session_pro_backend_add_pro_payment_user_transaction { SESSION_PRO_BACKEND_PAYMENT_PROVIDER provider; char payment_id[128]; size_t payment_id_count; + char order_id[128]; + size_t order_id_count; }; typedef struct session_pro_backend_add_pro_payment_request @@ -306,8 +308,13 @@ struct session_pro_backend_get_pro_status_response { /// - `master_privkey_len` -- Length of master_privkey. /// - `rotating_privkey` -- Ed25519 rotating private key (32-byte or 64-byte libsodium format). /// - `rotating_privkey_len` -- Length of rotating_privkey. -/// - `payment_token_hash` -- 32-byte hash of the payment token. -/// - `payment_token_hash_len` -- Length of payment_token_hash. +/// - `payment_tx_provider` -- Provider that the payment to register is coming from +/// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment provider. +/// See `AddProPaymentUserTransaction` +/// - `payment_tx_payment_id_len` -- Length of the `payment_tx_payment_id` payload +/// - `payment_tx_order_id` -- Order ID that is associated with the payment see +/// `AddProPaymentUserTransaction` +/// - `payment_tx_order_id_len` -- Length of the `payment_tx_order_id` payload /// /// Outputs: /// - `success` - True if signatures are built successfully, false otherwise. @@ -325,7 +332,9 @@ session_pro_backend_add_pro_payment_request_build_sigs( size_t rotating_privkey_len, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, const uint8_t* payment_tx_payment_id, - size_t payment_tx_payment_id_len) NON_NULL_ARG(2, 4, 7); + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) NON_NULL_ARG(2, 4, 7, 9); /// API: session_pro_backend/add_pro_payment_request_build_to_json /// @@ -343,7 +352,9 @@ session_pro_backend_to_json session_pro_backend_add_pro_payment_request_build_to size_t rotating_privkey_len, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, const uint8_t* payment_tx_payment_id, - size_t payment_tx_payment_id_len) NON_NULL_ARG(2, 4, 7); + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) NON_NULL_ARG(2, 4, 7, 9); /// API: session_pro_backend/get_pro_proof_request_build_sigs /// diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 94fb4387..dcf7e7bb 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -82,7 +82,16 @@ struct MasterRotatingSignatures { struct AddProPaymentUserTransaction { SESSION_PRO_BACKEND_PAYMENT_PROVIDER provider; + + /// The payment ID to claim which is different per platform. + /// + /// Google Play Store => purchase token + /// iOS App Store => transaction ID (note, not the original transaction id) std::string payment_id; + + /// Only for Google Play Store, set this to the purchase's order ID. Ignored for other payment + /// providers + std::string order_id; }; /// Register a new Session Pro proof to the backend. The payment is registered under the @@ -125,7 +134,8 @@ struct AddProPaymentRequest { /// /// Builds the master and rotating signatures using the provided private keys and payment token /// hash. Throws if the keys (32-byte or 64-byte libsodium format) or 32-byte payment token hash - /// are passed with an incorrect size. Using 64-byte libsodium keys is more efficient. + /// are passed with an incorrect size or the payment IDs are invalid. Using 64-byte libsodium + /// keys is more efficient. /// /// Inputs: /// - `request_version` -- Version of the request to build a hash for @@ -133,8 +143,10 @@ struct AddProPaymentRequest { /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key /// - `payment_tx_provider` -- Provider that the payment to register is coming from /// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment - /// provider (e.g. for Google this is the transaction order ID in string format, for Apple - /// this is the transaction ID in string format). + /// provider. See `AddProPaymentUserTransaction` + /// this is the transaction ID). + /// - `payment_tx_order_id` -- Order ID that is associated with the payment see + /// `AddProPaymentUserTransaction` /// /// Outputs: /// - `MasterRotatingSignatures` - Struct containing the 64-byte master and rotating signatures. @@ -143,7 +155,8 @@ struct AddProPaymentRequest { std::span master_privkey, std::span rotating_privkey, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, - std::span payment_tx_payment_id); + std::span payment_tx_payment_id, + std::span payment_tx_order_id); /// API: pro/AddProPaymentRequest::build_to_json /// @@ -156,8 +169,10 @@ struct AddProPaymentRequest { /// - `rotating_privkey` -- 64-byte libsodium style or 32 byte Ed25519 rotating private key /// - `payment_tx_provider` -- Provider that the payment to register is coming from /// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment - /// provider (e.g. for Google this is the transaction order ID in string format, for Apple - /// this is the transaction ID in string format). + /// provider. See `AddProPaymentUserTransaction` + /// this is the transaction ID). + /// - `payment_tx_order_id` -- Order ID that is associated with the payment see + /// `AddProPaymentUserTransaction` /// /// Outputs: /// - `std::string` -- Request serialised to JSON @@ -166,7 +181,8 @@ struct AddProPaymentRequest { std::span master_privkey, std::span rotating_privkey, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, - std::span payment_tx_payment_id); + std::span payment_tx_payment_id, + std::span payment_tx_order_id); }; /// The generated proof from the Session Pro backend that has been parsed from JSON. This structure @@ -424,6 +440,10 @@ struct ProPaymentItem { /// token. This information should be considered as confidential and stored appropriately. std::string google_payment_token; + /// When payment provider is set to Google Play Store, this is the platform-specific order + /// id. This information should be considered as confidential and stored appropriately. + std::string google_order_id; + /// When payment provider is set to iOS App Store, this is the platform-specific original /// transaction ID. This information should be considered as confidential and stored /// appropriately. diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 819cee6f..1492b072 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -130,6 +130,7 @@ std::string AddProPaymentRequest::to_json() const { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE: { j["payment_tx"]["google_payment_token"] = payment_tx.payment_id; + j["payment_tx"]["google_order_id"] = payment_tx.order_id; } break; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { j["payment_tx"]["apple_tx_id"] = payment_tx.payment_id; @@ -146,7 +147,8 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( std::span master_privkey, std::span rotating_privkey, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, - std::span payment_tx_payment_id) { + std::span payment_tx_payment_id, + std::span payment_tx_order_id) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; @@ -167,6 +169,18 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; } + if (payment_tx_provider == SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE) { + if (payment_tx_order_id.empty()) + throw std::invalid_argument{ + "Invalid payment_tx_order_id: order ID must be set for a Google Play store " + "payment"}; + } else { + if (payment_tx_order_id.size()) + throw std::invalid_argument{ + "Invalid payment_tx_order_id: order ID must not be set for an iOS App store " + "payment"}; + } + // Hash components to 32 bytes, must match: // https://github.com/Doy-lee/session-pro-backend/blob/5b66b1a4a64dc8da0225507019cbe21d7642fa78/backend.py#L171 array_uc32 hash_to_sign = {}; @@ -188,6 +202,12 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( &state, reinterpret_cast(payment_tx_payment_id.data()), payment_tx_payment_id.size()); + if (payment_tx_order_id.size()) { + crypto_generichash_blake2b_update( + &state, + reinterpret_cast(payment_tx_order_id.data()), + payment_tx_order_id.size()); + } crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); // Sign the hash with both keys @@ -212,7 +232,8 @@ std::string AddProPaymentRequest::build_to_json( std::span master_privkey, std::span rotating_privkey, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, - std::span payment_tx_payment_id) { + std::span payment_tx_payment_id, + std::span payment_tx_order_id) { cleared_uc64 master_from_seed; if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { array_uc32 master_pubkey; @@ -234,7 +255,12 @@ std::string AddProPaymentRequest::build_to_json( } MasterRotatingSignatures sigs = AddProPaymentRequest::build_sigs( - version, master_privkey, rotating_privkey, payment_tx_provider, payment_tx_payment_id); + version, + master_privkey, + rotating_privkey, + payment_tx_provider, + payment_tx_payment_id, + payment_tx_order_id); AddProPaymentRequest request = {}; request.version = version; @@ -250,6 +276,8 @@ std::string AddProPaymentRequest::build_to_json( request.payment_tx.payment_id = std::string( reinterpret_cast(payment_tx_payment_id.data()), payment_tx_payment_id.size()); + request.payment_tx.order_id = std::string( + reinterpret_cast(payment_tx_order_id.data()), payment_tx_order_id.size()); request.master_sig = sigs.master_sig; request.rotating_sig = sigs.rotating_sig; @@ -673,6 +701,10 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { json_require(obj, "google_payment_token", result.errors); assert(item.google_payment_token.size() < sizeof(((session_pro_backend_pro_payment_item*)0)->google_payment_token)); + item.google_order_id = + json_require(obj, "google_order_id", result.errors); + assert(item.google_order_id.size() < + sizeof(((session_pro_backend_pro_payment_item*)0)->google_order_id)); } break; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { @@ -728,13 +760,17 @@ session_pro_backend_add_pro_payment_request_build_sigs( size_t rotating_privkey_len, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, const uint8_t* payment_tx_payment_id, - size_t payment_tx_payment_id_len) { + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) { // Convert C inputs to C++ types std::span master_span(master_privkey, master_privkey_len); std::span rotating_span(rotating_privkey, rotating_privkey_len); std::span payment_tx_payment_id_span( payment_tx_payment_id, payment_tx_payment_id_len); + std::span payment_tx_order_id_span( + payment_tx_order_id, payment_tx_order_id_len); session_pro_backend_master_rotating_signatures result = {}; try { @@ -743,7 +779,8 @@ session_pro_backend_add_pro_payment_request_build_sigs( master_span, rotating_span, payment_tx_provider, - payment_tx_payment_id_span); + payment_tx_payment_id_span, + payment_tx_order_id_span); std::memcpy(result.master_sig.data, sigs.master_sig.data(), sigs.master_sig.size()); std::memcpy(result.rotating_sig.data, sigs.rotating_sig.data(), sigs.rotating_sig.size()); result.success = true; @@ -768,7 +805,9 @@ session_pro_backend_add_pro_payment_request_build_to_json( size_t rotating_privkey_len, SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, const uint8_t* payment_tx_payment_id, - size_t payment_tx_payment_id_len) { + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) { session_pro_backend_to_json result = {}; // Convert C inputs to C++ types @@ -776,6 +815,8 @@ session_pro_backend_add_pro_payment_request_build_to_json( std::span rotating_span(rotating_privkey, rotating_privkey_len); std::span payment_tx_payment_id_span( payment_tx_payment_id, payment_tx_payment_id_len); + std::span payment_tx_order_id_span( + payment_tx_order_id, payment_tx_order_id_len); try { std::string json = AddProPaymentRequest::build_to_json( @@ -783,7 +824,8 @@ session_pro_backend_add_pro_payment_request_build_to_json( master_span, rotating_span, payment_tx_provider, - payment_tx_payment_id_span); + payment_tx_payment_id_span, + payment_tx_order_id_span); result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { @@ -938,6 +980,8 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment cpp.payment_tx.provider = request->payment_tx.provider; cpp.payment_tx.payment_id = std::string(request->payment_tx.payment_id, request->payment_tx.payment_id_count); + cpp.payment_tx.order_id = + std::string(request->payment_tx.order_id, request->payment_tx.order_id_count); std::memcpy(cpp.master_sig.data(), request->master_sig.data, cpp.master_sig.size()); std::memcpy(cpp.rotating_sig.data(), request->rotating_sig.data, cpp.rotating_sig.size()); @@ -1265,6 +1309,10 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ dest.google_payment_token, sizeof(dest.google_payment_token), src.google_payment_token.data()); + dest.google_order_id_count = snprintf_clamped( + dest.google_order_id, + sizeof(dest.google_order_id), + src.google_order_id.data()); } break; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 75afa723..bba2c2eb 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -112,17 +112,24 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { crypto_sign_ed25519_keypair(rotating_pubkey.data, rotating_privkey.data); { - bytes32 fake_google_payment_token; - randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); - std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token.data); + char fake_google_payment_token[16]; + randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); + std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token); + + char fake_google_order_id[16]; + randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); + std::string fake_google_order_id_hex = oxenc::to_hex(fake_google_order_id); session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + payment_tx.order_id_count = fake_google_order_id_hex.size(); std::memcpy( payment_tx.payment_id, fake_google_payment_token_hex.data(), payment_tx.payment_id_count); + std::memcpy( + payment_tx.order_id, fake_google_order_id_hex.data(), payment_tx.order_id_count); uint64_t unix_ts_ms = 1698765432ULL * 1000; // Arbitrary timestamp @@ -137,7 +144,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey), payment_tx.provider, reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count); + payment_tx.payment_id_count, + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count); + INFO(result.error); REQUIRE(result.success); REQUIRE(result.error_count == 0); @@ -149,7 +159,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { payment_tx.provider, std::span( reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count)); + payment_tx.payment_id_count), + std::span( + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count)); REQUIRE(std::memcmp( result.master_sig.data, @@ -169,7 +182,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey), payment_tx.provider, reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count); + payment_tx.payment_id_count, + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count); REQUIRE(!result.success); REQUIRE(result.error_count > 0); } @@ -232,7 +247,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey.data), payment_tx.provider, reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count); + payment_tx.payment_id_count, + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count); request.master_sig = sigs.master_sig; request.rotating_sig = sigs.rotating_sig; @@ -254,6 +271,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { cpp.payment_tx.provider = payment_tx.provider; cpp.payment_tx.payment_id = std::string(payment_tx.payment_id, payment_tx.payment_id_count); + cpp.payment_tx.order_id = + std::string(payment_tx.order_id, payment_tx.order_id_count); std::memcpy(cpp.master_sig.data(), sigs.master_sig.data, sizeof(sigs.master_sig)); std::memcpy( cpp.rotating_sig.data(), sigs.rotating_sig.data, sizeof(sigs.rotating_sig)); @@ -269,7 +288,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey.data), request.payment_tx.provider, reinterpret_cast(request.payment_tx.payment_id), - request.payment_tx.payment_id_count); + request.payment_tx.payment_id_count, + reinterpret_cast(request.payment_tx.order_id), + request.payment_tx.order_id_count); REQUIRE(one_shot.success); REQUIRE(one_shot.json.size == result.json.size); INFO("One shot: " << one_shot.json.data << "\n\nJSON: " << result.json.data); @@ -635,7 +656,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"revoked_unix_ts_ms", unix_ts_ms + 3600}, {"google_payment_token", std::string( - payment_tx.payment_id, payment_tx.payment_id_count)}}})}}; + payment_tx.payment_id, payment_tx.payment_id_count)}, + {"google_order_id", + std::string( + payment_tx.order_id, payment_tx.order_id_count)}}})}}; std::string json = j.dump(); // Valid JSON @@ -674,6 +698,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { result.items[0].google_payment_token, payment_tx.payment_id, payment_tx.payment_id_count) == 0); + REQUIRE(result.items[0].google_order_id_count == payment_tx.order_id_count); + REQUIRE(std::memcmp( + result.items[0].google_order_id, + payment_tx.order_id, + payment_tx.order_id_count) == 0); } // After freeing @@ -746,18 +775,26 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Add pro payment session_protocol_pro_proof first_pro_proof = {}; { - bytes32 fake_google_payment_token; - randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); - std::string fake_google_payment_token_hex = - oxenc::to_hex(fake_google_payment_token.data); + char fake_google_payment_token[16]; + randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); + std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token); + + char fake_google_order_id[16]; + randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); + std::string fake_google_order_id_hex = oxenc::to_hex(fake_google_order_id); session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + payment_tx.order_id_count = fake_google_order_id_hex.size(); std::memcpy( payment_tx.payment_id, fake_google_payment_token_hex.data(), payment_tx.payment_id_count); + std::memcpy( + payment_tx.order_id, + fake_google_order_id_hex.data(), + payment_tx.order_id_count); // Build request session_pro_backend_master_rotating_signatures add_pro_sigs = @@ -769,7 +806,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey), payment_tx.provider, reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count); + payment_tx.payment_id_count, + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count); session_pro_backend_add_pro_payment_request request = {}; request.version = 0; @@ -982,22 +1021,28 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.items_count == 0); } - // Add _another_ payment, same details. This creates a revocation for - // the old proof and the subscription duration will stack, all old - // proofs invalidated and new ones issued with the combined duration. + // Add _another_ payment, same details { - bytes32 fake_google_payment_token; - randombytes_buf(fake_google_payment_token.data, sizeof(fake_google_payment_token.data)); - std::string fake_google_payment_token_hex = - oxenc::to_hex(fake_google_payment_token.data); + char fake_google_payment_token[16]; + randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); + std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token); + + char fake_google_order_id[16]; + randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); + std::string fake_google_order_id_hex = oxenc::to_hex(fake_google_order_id); session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + payment_tx.order_id_count = fake_google_order_id_hex.size(); std::memcpy( payment_tx.payment_id, fake_google_payment_token_hex.data(), payment_tx.payment_id_count); + std::memcpy( + payment_tx.order_id, + fake_google_order_id_hex.data(), + payment_tx.order_id_count); // Build request session_pro_backend_master_rotating_signatures add_pro_sigs = @@ -1009,7 +1054,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey), payment_tx.provider, reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count); + payment_tx.payment_id_count, + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count); session_pro_backend_add_pro_payment_request request = {}; request.version = 0; @@ -1084,15 +1131,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Verify the response REQUIRE(response.header.errors_count == 0); REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); - REQUIRE(response.ticket > 0); - REQUIRE(response.items_count > 0); - - // The last revocation added should be the first pro proof we generated from a "payment" - // in the test-suite - REQUIRE(std::memcmp( - response.items[response.items_count - 1].gen_index_hash.data, - first_pro_proof.gen_index_hash.data, - sizeof(first_pro_proof.gen_index_hash)) == 0); + REQUIRE(response.ticket == 0); + REQUIRE(response.items_count == 0); } } #endif From 19f460106cabc016c44321f7e451f72dd78192fe Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 7 Nov 2025 13:20:09 +1100 Subject: [PATCH 139/171] Unpad the decoded community message on behalf of the caller --- include/session/session_protocol.h | 1 - include/session/session_protocol.hpp | 8 ++------ src/session_protocol.cpp | 20 ++++++++++++-------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index d66c98a7..f0d1c68c 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -166,7 +166,6 @@ struct session_protocol_decoded_community_message { bool has_envelope; session_protocol_envelope envelope; span_u8 content_plaintext; - size_t content_plaintext_unpadded_size; bool has_pro; bytes64 pro_sig; session_protocol_decoded_pro pro; diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index ecac36ed..dcf51f12 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -250,7 +250,7 @@ struct DecodedEnvelope { // The envelope parsed from the plaintext Envelope envelope; - // Decoded envelope content into plaintext + // Decoded envelope content into plaintext with padding stripped std::vector content_plaintext; // Sender public key extracted from the encrypted content payload. This is not set if the @@ -274,13 +274,9 @@ struct DecodedCommunityMessage { // kind of blob on the wire during that period. std::optional envelope; - // The protobuf encoded `Content` including padding. + // The protobuf encoded `Content` with padding stripped std::vector content_plaintext; - // The size of the payload from [content_plaintext.data(), content_plaintext_unpadded_size) that - // contains the protobuf encoded `Content` without padding. - size_t content_plaintext_unpadded_size; - // The signature if it was present in the payload. If the envelope is set and the envelope has // the pro signature flag set, then this signature was extracted from the envelope. When the // signature is sourced from the envelope, the envelope's `pro_sig` field is also set to the diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 5dbfb38d..a5375c57 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -754,8 +754,8 @@ DecodedEnvelope decode_envelope( // Strip padding from content std::span unpadded_content = unpad_message(content_plaintext); content_plaintext.resize(unpadded_content.size()); - result.content_plaintext = std::move(content_plaintext); + std::memcpy( result.sender_ed25519_pubkey.data(), sender_ed25519_pubkey.data(), @@ -925,15 +925,12 @@ DecodedCommunityMessage decode_for_community( result.content_plaintext = std::vector( content_or_envelope_payload.begin(), content_or_envelope_payload.end()); } - - // Get the unpadded size of the content - result.content_plaintext_unpadded_size = unpad_message(result.content_plaintext).size(); } // Parse the content blob + std::span unpadded_content = unpad_message(result.content_plaintext); SessionProtos::Content content = {}; - if (!content.ParseFromArray( - result.content_plaintext.data(), result.content_plaintext_unpadded_size)) + if (!content.ParseFromArray(unpadded_content.data(), unpadded_content.size())) throw std::runtime_error{ "Decoding community message failed, could not interpret blob as content or " "envelope"}; @@ -1037,6 +1034,15 @@ DecodedCommunityMessage decode_for_community( pro.status = proof.status(pro_backend_pubkey, unix_ts, signed_msg); } } + + // Strip padding from content, we only strip at the very end once we're done using the padded + // content. A Session Pro proof, if provided will contain a signature that signs over the content + // including its padding- that is verified in this function above. + // + // After that verification is complete then we can remove the padding here and return it to the + // caller without padding as we no longer have a need for it. + result.content_plaintext.resize(unpadded_content.size()); + return result; } } // namespace session @@ -1469,10 +1475,8 @@ session_protocol_decoded_community_message session_protocol_decode_for_community result.has_envelope = decoded.envelope.has_value(); if (result.has_envelope) result.envelope = envelope_from_cpp(*decoded.envelope); - result.content_plaintext = session::span_u8_copy_or_throw( decoded.content_plaintext.data(), decoded.content_plaintext.size()); - result.content_plaintext_unpadded_size = decoded.content_plaintext_unpadded_size; result.has_pro = decoded.pro.has_value(); if (decoded.pro_sig) std::memcpy(result.pro_sig.data, decoded.pro_sig->data(), decoded.pro_sig->max_size()); From 75e48ae6eec6dab5dc5a537f881266ad133ed197 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 7 Nov 2025 13:51:57 +1100 Subject: [PATCH 140/171] Add the custom status codes for AddProPayment responses --- include/session/pro_backend.h | 8 ++++++++ include/session/pro_backend.hpp | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 7f8b642d..544ef5fb 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -61,6 +61,14 @@ typedef enum SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT { SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_COUNT, } SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT; +typedef enum SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS { + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_UNKNOWN_PAYMENT, +} SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS; + + /// Bundle of hard-coded URLs that an application may want to redirect users to in various /// scenarios. typedef struct session_pro_urls session_pro_urls; diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index dcf7e7bb..a9231b29 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -66,8 +66,32 @@ constexpr array_uc32 PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static_assert(sizeof(PUBKEY) == array_uc32{}.size()); +/// NOTE: Must match +/// https://github.com/Doy-lee/session-pro-backend/blob/eed715c8ff7bc513486ca6c6ce88a93c988f67dd/server.py#L457 +enum struct AddProPaymentResponseStatus { + /// Payment was claimed and the pro proof was successfully generated + Success = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS, + + /// Backend encountered an error when attempting to claim the payment + Error = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR, + + /// Payment is already claimed + AlreadyRedeemed = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED, + + /// Payment transaction attempted to claim a payment that the backend does not have. Either the + /// payment doesn't exist or the backend has not witnessed the payment from the provider yet. + UnknownPayment = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_UNKNOWN_PAYMENT, +}; + struct ResponseHeader { - /// Status code: RESPONSE_STATUS_SUCCESS for success, other values indicate errors + /// Status code for the response, maps to a specific enum for some requests otherwise it uses 0 + /// for success, other values indicate errors. For the following responses, the status code maps + /// to + /// + /// | Request | Enum + /// | AddProPayment | AddProPaymentResponseStatus + /// | Everything else ...| SESSION_PRO_BACKEND_STATUS_SUCCESS or + /// SESSION_PRO_BACKEND_STATUS_ERROR std::uint32_t status; /// List of parsing or processing errors. Empty if there are no parsing errors, if there are From 3808050a4be373b6c22f21c87dce9a6dd83aedf7 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 7 Nov 2025 14:10:31 +1100 Subject: [PATCH 141/171] Formatting --- include/session/pro_backend.h | 9 ++++----- src/pro_backend.cpp | 6 ++---- src/session_protocol.cpp | 4 ++-- tests/test_pro_backend.cpp | 6 ++---- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 544ef5fb..60432620 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -62,13 +62,12 @@ typedef enum SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT { } SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT; typedef enum SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS { - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS, - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR, - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED, - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_UNKNOWN_PAYMENT, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_UNKNOWN_PAYMENT, } SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS; - /// Bundle of hard-coded URLs that an application may want to redirect users to in various /// scenarios. typedef struct session_pro_urls session_pro_urls; diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 1492b072..24a11391 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -769,8 +769,7 @@ session_pro_backend_add_pro_payment_request_build_sigs( std::span rotating_span(rotating_privkey, rotating_privkey_len); std::span payment_tx_payment_id_span( payment_tx_payment_id, payment_tx_payment_id_len); - std::span payment_tx_order_id_span( - payment_tx_order_id, payment_tx_order_id_len); + std::span payment_tx_order_id_span(payment_tx_order_id, payment_tx_order_id_len); session_pro_backend_master_rotating_signatures result = {}; try { @@ -815,8 +814,7 @@ session_pro_backend_add_pro_payment_request_build_to_json( std::span rotating_span(rotating_privkey, rotating_privkey_len); std::span payment_tx_payment_id_span( payment_tx_payment_id, payment_tx_payment_id_len); - std::span payment_tx_order_id_span( - payment_tx_order_id, payment_tx_order_id_len); + std::span payment_tx_order_id_span(payment_tx_order_id, payment_tx_order_id_len); try { std::string json = AddProPaymentRequest::build_to_json( diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index a5375c57..76514dcb 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -1036,8 +1036,8 @@ DecodedCommunityMessage decode_for_community( } // Strip padding from content, we only strip at the very end once we're done using the padded - // content. A Session Pro proof, if provided will contain a signature that signs over the content - // including its padding- that is verified in this function above. + // content. A Session Pro proof, if provided will contain a signature that signs over the + // content including its padding- that is verified in this function above. // // After that verification is complete then we can remove the padding here and return it to the // caller without padding as we no longer have a need for it. diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index bba2c2eb..77b47841 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -655,11 +655,9 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"platform_refund_expiry_unix_ts_ms", unix_ts_ms + 1}, {"revoked_unix_ts_ms", unix_ts_ms + 3600}, {"google_payment_token", - std::string( - payment_tx.payment_id, payment_tx.payment_id_count)}, + std::string(payment_tx.payment_id, payment_tx.payment_id_count)}, {"google_order_id", - std::string( - payment_tx.order_id, payment_tx.order_id_count)}}})}}; + std::string(payment_tx.order_id, payment_tx.order_id_count)}}})}}; std::string json = j.dump(); // Valid JSON From 6134c4718ae094be53deeb2b4285bed475b20b88 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 7 Nov 2025 14:27:16 +1100 Subject: [PATCH 142/171] Remove Session Pro from the user config This is not needed anymore as each device can independently manage their own rotating keypair and get individualised proofs that they keep to themselves for use on the network. These proofs are identified and revoked by the generation index hash which is shared across all proofs that are generated from a payment so it's totally fine for a client to have their own individual proof as the generation index hash is what's shared between all of them. [Gen Index Hash] | +----Proof A {rotating pkey1} | +----Proof B {rotating pkey2} | +----... --- include/session/config/pro.h | 38 ------ include/session/config/pro.hpp | 48 ------- include/session/config/user_profile.h | 43 ------- include/session/config/user_profile.hpp | 21 --- src/CMakeLists.txt | 1 - src/config/pro.cpp | 116 ----------------- src/config/user_profile.cpp | 64 ---------- tests/CMakeLists.txt | 1 - tests/test_config_pro.cpp | 162 ------------------------ tests/test_pro_backend.cpp | 2 - 10 files changed, 496 deletions(-) delete mode 100644 include/session/config/pro.h delete mode 100644 include/session/config/pro.hpp delete mode 100644 src/config/pro.cpp delete mode 100644 tests/test_config_pro.cpp diff --git a/include/session/config/pro.h b/include/session/config/pro.h deleted file mode 100644 index dcf2a264..00000000 --- a/include/session/config/pro.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#include "../export.h" -#include "session/session_protocol.h" - -typedef struct pro_pro_config pro_pro_config; -struct pro_pro_config { - bytes64 rotating_privkey; - session_protocol_pro_proof proof; -}; - -/// 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 diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp deleted file mode 100644 index 9d195941..00000000 --- a/include/session/config/pro.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace session::config { - -/// keys used currently or in the past (so that we don't reuse): -/// -/// s + session pro data -/// | -/// +-- p + proof -/// | | -/// | +-- @ - version -/// | +-- e - expiry unix timestamp (in milliseconds) -/// | +-- g - gen_index_hash -/// | +-- r - rotating ed25519 privkey -/// | +-- s - proof signature, signed by the Session Pro Backend's ed25519 key -/// | -/// +-- r - rotating ed25519 pubkey -class ProConfig { - public: - /// Private key for the public key key specified in the proof. This is synced between clients - /// to allow multiple clients to synchronise the Session Pro Proof and also the keys necessary - /// to use the proof. - cleared_uc64 rotating_privkey; - - /// A cryptographic proof for entitling an Ed25519 key to Session Pro - ProProof proof; - - /// API: pro/Pro::verify - /// - /// Verify the proof and that the proof's rotating public key matches the public key of the - /// `rotating_privkey` - /// - /// Inputs: - /// - `verify_pubkey` -- Ed25519 public key of the corresponding secret key to check if they are - /// the original signatory of the proof. - /// - /// Outputs: - /// - `bool` - True if the proof was verified and the proof's rotating public key corresponds to - /// the public component of the `rotating_privkey`. - bool verify_signature(const array_uc32& verify_pubkey) const; - - bool load(const dict& root); -}; -}; // namespace session::config diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index ee7c842e..94d3531c 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -5,7 +5,6 @@ extern "C" { #endif #include "base.h" -#include "pro.h" #include "profile_pic.h" /// API: user_profile/user_profile_init @@ -280,48 +279,6 @@ LIBSESSION_EXPORT void user_profile_set_blinded_msgreqs(config_object* conf, int /// information. Will be `0` if it's never been updated. LIBSESSION_EXPORT int64_t user_profile_get_profile_updated(config_object* conf); -/// API: user_profile/user_profile_get_pro_config -/// -/// Get the Pro data for the user profile if it exists which includes the users rotating private key -/// and their last authorised proof. -/// -/// Declaration: -/// ```cpp -/// BOOL user_profile_get_pro_config( -/// [in] const config_object* conf -/// [out] pro_pro* pro -/// ); -/// ``` -/// -/// Inputs: -/// - `conf` -- [in] Pointer to the config object -/// - `pro` -- [out] Pointer to the pro object where the retrieved details are written -/// -/// Outputs: -/// - `bool` -- True if the user profile had Pro data associated with it. Otherwise false and the -/// pro structure will remain untouched. -LIBSESSION_EXPORT bool user_profile_get_pro_config(const config_object* conf, pro_pro_config* pro); - -/// API: user_profile/user_profile_set_pro_config -/// -/// Update the pro data associated with the user profile. -/// -/// Declaration: -/// ```cpp -/// VOID user_profile_set_pro_config( -/// [in] config_object* conf, -/// [in] pro_pro* pro -/// ); -/// ``` -/// -/// Inputs: -/// - `conf` -- [in] Pointer to the config object -/// - `pro` -- [in] Pointer to the Pro data to write to the user profile -/// -/// Outputs: -/// - `void` -- Returns nothing -LIBSESSION_EXPORT void user_profile_set_pro_config(config_object* conf, const pro_pro_config* pro); - #ifdef __cplusplus } // extern "C" #endif diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index f987671f..3fa48bb1 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -6,7 +6,6 @@ #include "base.hpp" #include "namespaces.hpp" -#include "pro.hpp" #include "profile_pic.hpp" namespace session::config { @@ -24,7 +23,6 @@ using namespace std::literals; /// M - set to 1 if blinded message request retrieval is enabled, 0 if retrieval is *disabled*, and /// omitted if the setting has not been explicitly set (or has been explicitly cleared for some /// reason). -/// s - session pro config /// t - The unix timestamp (seconds) that the user last explicitly updated their profile information /// (automatically updates when changing `name`, `profile_pic` or `set_blinded_msgreqs`). /// P - user profile url after re-uploading (should take precedence over `p` when `T > t`). @@ -242,25 +240,6 @@ class UserProfile : public ConfigBase { std::chrono::sys_seconds get_profile_updated() const; bool accepts_protobuf() const override { return true; } - - /// API: user_profile/UserProfile::get_pro_config - /// - /// Get the Session Pro data if any, for the current user profile. This may be missing if the - /// user does not have any entitlement to Session Pro config. - /// - /// Inputs: None - std::optional get_pro_config() const; - - /// API: user_profile/UserProfile::set_pro_config - /// - /// Attach the Session Pro components to the user profile including the proof entitling the user - /// to use Session Pro features as well as the Ed25519 key pair known as the Rotating Session - /// Pro key authorised to use the proof. - /// - /// Inputs: - /// - `pro` -- The Session Pro components to assign to the current user profile. This will - /// overwrite any existing Session Pro config if it exists. No verification of `pro` is done. - void set_pro_config(const ProConfig& pro); }; } // namespace session::config diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af9bd4bf..16563923 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,7 +73,6 @@ add_libsession_util_library(config config/internal.cpp config/local.cpp config/protos.cpp - config/pro.cpp config/user_groups.cpp config/user_profile.cpp fields.cpp diff --git a/src/config/pro.cpp b/src/config/pro.cpp deleted file mode 100644 index 030ec26d..00000000 --- a/src/config/pro.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include "internal.hpp" - -namespace session::config { -static_assert(sizeof(((ProConfig*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); -bool ProConfig::verify_signature(const array_uc32& verify_pubkey) const { - uint64_t expiry_unix_ts = proof.expiry_unix_ts.time_since_epoch().count(); - if (!proof.verify_signature(verify_pubkey)) - return false; - - session::array_uc32 rederived_pk; - [[maybe_unused]] session::cleared_uc64 rederived_sk; - crypto_sign_ed25519_seed_keypair( - rederived_pk.data(), rederived_sk.data(), rotating_privkey.data()); - - bool result = false; - if (rederived_pk.size() == proof.rotating_pubkey.size()) - result = std::memcmp( - rederived_pk.data(), proof.rotating_pubkey.data(), rederived_pk.size()) == - 0; - return result; -} - -bool ProConfig::load(const dict& root) { - // Get proof fields from session pro data sitting in the 'p' (proof) dictionary - auto p_it = root.find("p"); - if (p_it == root.end()) - return false; - - // Lookup and get 'p' - const config::dict* p = std::get_if(&p_it->second); - if (!p) - return false; - - std::optional> maybe_rotating_privkey = maybe_vector(root, "r"); - if (!maybe_rotating_privkey || maybe_rotating_privkey->size() != rotating_privkey.max_size()) - return false; - - // NOTE: Load into the proof object - { - std::optional version = maybe_int(*p, "@"); - std::optional> maybe_gen_index_hash = maybe_vector(*p, "g"); - std::optional> maybe_rotating_pubkey = maybe_vector(*p, "r"); - std::optional> maybe_expiry_unix_ts_ms = - maybe_ts_ms(*p, "e"); - std::optional> maybe_sig = maybe_vector(*p, "s"); - - if (!version) - return false; - if (!maybe_gen_index_hash || maybe_gen_index_hash->size() != proof.gen_index_hash.size()) - return false; - if (!maybe_rotating_pubkey || - maybe_rotating_pubkey->size() != proof.rotating_pubkey.max_size()) - return false; - if (!maybe_sig || maybe_sig->size() != proof.sig.max_size()) - return false; - if (!maybe_expiry_unix_ts_ms) - return false; - - proof.version = *version; - std::memcpy( - proof.gen_index_hash.data(), - maybe_gen_index_hash->data(), - proof.gen_index_hash.size()); - std::memcpy( - proof.rotating_pubkey.data(), - maybe_rotating_pubkey->data(), - proof.rotating_pubkey.size()); - proof.expiry_unix_ts = *maybe_expiry_unix_ts_ms; - std::memcpy(proof.sig.data(), maybe_sig->data(), proof.sig.size()); - } - - std::memcpy(rotating_privkey.data(), maybe_rotating_privkey->data(), rotating_privkey.size()); - return true; -} - -}; // namespace session::config - -// Ensure these are byte buffers and we can just use sizeof to build std::spans to interop with C++ -static_assert((sizeof((pro_pro_config*)0)->rotating_privkey) == crypto_sign_ed25519_SECRETKEYBYTES); - -LIBSESSION_C_API bool pro_config_verify_signature( - pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len) { - if (verify_pubkey_len != crypto_sign_ed25519_PUBLICKEYBYTES) - return false; - - session::config::ProConfig config = {}; - std::memcpy( - config.rotating_privkey.data(), - pro->rotating_privkey.data, - sizeof pro->rotating_privkey.data); - config.proof.version = pro->proof.version; - std::memcpy( - config.proof.gen_index_hash.data(), - pro->proof.gen_index_hash.data, - sizeof pro->proof.gen_index_hash.data); - std::memcpy( - config.proof.rotating_pubkey.data(), - pro->proof.rotating_pubkey.data, - sizeof pro->proof.rotating_pubkey.data); - config.proof.expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(pro->proof.expiry_unix_ts_ms)); - std::memcpy(config.proof.sig.data(), pro->proof.sig.data, sizeof pro->proof.sig.data); - - session::array_uc32 verify_pubkey_cpp; - std::memcpy(verify_pubkey_cpp.data(), verify_pubkey, verify_pubkey_len); - bool result = config.verify_signature(verify_pubkey_cpp); - return result; -} diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 28e31182..8153e02f 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -5,11 +5,8 @@ #include "internal.hpp" #include "session/config/contacts.hpp" #include "session/config/error.h" -#include "session/config/pro.h" -#include "session/config/pro.hpp" #include "session/config/user_profile.hpp" #include "session/export.h" -#include "session/types.hpp" using namespace session::config; @@ -149,29 +146,6 @@ std::chrono::sys_seconds UserProfile::get_profile_updated() const { return std::chrono::sys_seconds{}; } -std::optional UserProfile::get_pro_config() const { - std::optional result = {}; - if (const config::dict* s = data["s"].dict(); s) { - ProConfig pro = {}; - if (pro.load(*s)) - result = std::move(pro); - } - return result; -} - -void UserProfile::set_pro_config(ProConfig const& pro) { - auto root = data["s"]; - root["r"] = pro.rotating_privkey; - - const ProProof& pro_proof = pro.proof; - auto proof_dict = root["p"]; - proof_dict["@"] = pro_proof.version; - proof_dict["g"] = pro_proof.gen_index_hash; - proof_dict["r"] = pro_proof.rotating_pubkey; - proof_dict["e"] = pro_proof.expiry_unix_ts.time_since_epoch().count(); - proof_dict["s"] = pro_proof.sig; -} - extern "C" { using namespace session; @@ -277,42 +251,4 @@ LIBSESSION_C_API void user_profile_set_blinded_msgreqs(config_object* conf, int LIBSESSION_C_API int64_t user_profile_get_profile_updated(config_object* conf) { return unbox(conf)->get_profile_updated().time_since_epoch().count(); } - -LIBSESSION_C_API bool user_profile_get_pro_config(const config_object* conf, pro_pro_config* pro) { - if (auto val = unbox(conf)->get_pro_config(); val) { - static_assert(sizeof pro->proof.gen_index_hash == sizeof(val->proof.gen_index_hash)); - static_assert(sizeof pro->proof.rotating_pubkey == sizeof(val->proof.rotating_pubkey)); - static_assert(sizeof pro->proof.sig == sizeof(val->proof.sig)); - pro->proof.version = val->proof.version; - std::memcpy( - pro->proof.gen_index_hash.data, - val->proof.gen_index_hash.data(), - val->proof.gen_index_hash.size()); - std::memcpy( - pro->proof.rotating_pubkey.data, - val->proof.rotating_pubkey.data(), - val->proof.rotating_pubkey.size()); - pro->proof.expiry_unix_ts_ms = val->proof.expiry_unix_ts.time_since_epoch().count(); - std::memcpy(pro->proof.sig.data, val->proof.sig.data(), val->proof.sig.size()); - return true; - } - return false; -} - -LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro_pro_config* pro) { - ProConfig val = {}; - val.proof.version = pro->proof.version; - std::memcpy( - val.proof.gen_index_hash.data(), - pro->proof.gen_index_hash.data, - val.proof.gen_index_hash.size()); - std::memcpy( - val.proof.rotating_pubkey.data(), - pro->proof.rotating_pubkey.data, - val.proof.rotating_pubkey.size()); - val.proof.expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(pro->proof.expiry_unix_ts_ms)); - std::memcpy(val.proof.sig.data(), pro->proof.sig.data, val.proof.sig.size()); - unbox(conf)->set_pro_config(val); -} } // extern "C" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 16983201..09e93084 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,7 +16,6 @@ set(LIB_SESSION_UTESTS_SOURCES test_config_contacts.cpp test_config_convo_info_volatile.cpp test_config_local.cpp - test_config_pro.cpp test_curve25519.cpp test_ed25519.cpp test_encrypt.cpp diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp deleted file mode 100644 index b1ead131..00000000 --- a/tests/test_config_pro.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include - -#include -#include - -using namespace oxenc::literals; - -TEST_CASE("Pro", "[config][pro]") { - // Setup keys - std::array rotating_pk, signing_pk; - session::cleared_uc64 rotating_sk, signing_sk; - { - crypto_sign_ed25519_keypair(rotating_pk.data(), rotating_sk.data()); - crypto_sign_ed25519_keypair(signing_pk.data(), signing_sk.data()); - } - - // Setup the Pro data structure - session::config::ProConfig pro_cpp = {}; - pro_pro_config pro = {}; - { - // CPP - pro_cpp.rotating_privkey = rotating_sk; - pro_cpp.proof.version = 2; - pro_cpp.proof.rotating_pubkey = rotating_pk; - pro_cpp.proof.expiry_unix_ts = std::chrono::sys_time(1s); - constexpr auto gen_index_hash = - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hex_u; - static_assert(pro_cpp.proof.gen_index_hash.max_size() == gen_index_hash.size()); - std::memcpy( - pro_cpp.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); - - // C - std::memcpy(pro.rotating_privkey.data, rotating_sk.data(), rotating_sk.size()); - pro.proof.version = pro_cpp.proof.version; - std::memcpy(pro.proof.rotating_pubkey.data, rotating_pk.data(), rotating_pk.size()); - pro.proof.expiry_unix_ts_ms = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); - std::memcpy(pro.proof.gen_index_hash.data, gen_index_hash.data(), gen_index_hash.size()); - } - - // Generate and write the hashes that are signed by the faux pro backend into the proof - { - // Generate the hashes - static_assert(crypto_sign_ed25519_BYTES == pro_cpp.proof.sig.max_size()); - std::array hash_to_sign_cpp = pro_cpp.proof.hash(); - bytes32 hash_to_sign = session_protocol_pro_proof_hash(&pro.proof); - - static_assert(hash_to_sign_cpp.size() == sizeof(hash_to_sign)); - CHECK(std::memcmp(hash_to_sign_cpp.data(), hash_to_sign.data, hash_to_sign_cpp.size()) == - 0); - - // Write the signature into the proof - int sig_result = crypto_sign_ed25519_detached( - pro_cpp.proof.sig.data(), - nullptr, - hash_to_sign_cpp.data(), - hash_to_sign_cpp.size(), - signing_sk.data()); - CHECK(sig_result == 0); - - sig_result = crypto_sign_ed25519_detached( - pro.proof.sig.data, - nullptr, - hash_to_sign.data, - sizeof(hash_to_sign.data), - signing_sk.data()); - CHECK(sig_result == 0); - } - - // Verify the signature in the proof was signed by the faux pro backend key "signing_sk" - { - CHECK_FALSE(pro_cpp.verify_signature(rotating_pk)); - CHECK(pro_cpp.verify_signature(signing_pk)); - - CHECK_FALSE(pro_config_verify_signature(&pro, rotating_pk.data(), rotating_pk.size())); - CHECK(pro_config_verify_signature(&pro, signing_pk.data(), signing_pk.size())); - } - - // Verify expiry - { - CHECK(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts)); - CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1ms)); - - CHECK(session_protocol_pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms)); - CHECK_FALSE( - session_protocol_pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms + 1)); - } - - // Verify it can verify messages signed with the rotating public key - { - std::string_view body = "hello world"; - std::array sig = {}; - int sign_result = crypto_sign_ed25519_detached( - sig.data(), - nullptr, - reinterpret_cast(body.data()), - body.size(), - rotating_sk.data()); - CHECK(sign_result == 0); - CHECK(pro_cpp.proof.verify_message(sig, session::to_span(body))); - CHECK(session_protocol_pro_proof_verify_message( - &pro.proof, - sig.data(), - sig.size(), - reinterpret_cast(body.data()), - body.size())); - } - - // Try loading the proof from dict - session::config::dict good_dict; - { - // clang-format off - const session::ProProof& proof = pro_cpp.proof; - good_dict = { - {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, - {"p", session::config::dict{ - /*version*/ {"@", proof.version}, - /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, - /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, - /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, - /*signature*/ {"s", std::string{reinterpret_cast(proof.sig.data()), proof.sig.size()}}, - }} - }; - // clang-format on - - session::config::ProConfig loaded_pro = {}; - CHECK(loaded_pro.load(good_dict)); - CHECK(loaded_pro.rotating_privkey == pro_cpp.rotating_privkey); - CHECK(loaded_pro.proof.version == pro_cpp.proof.version); - CHECK(loaded_pro.proof.gen_index_hash == pro_cpp.proof.gen_index_hash); - CHECK(loaded_pro.proof.rotating_pubkey == pro_cpp.proof.rotating_pubkey); - CHECK(loaded_pro.proof.expiry_unix_ts == pro_cpp.proof.expiry_unix_ts); - CHECK(loaded_pro.proof.sig == pro_cpp.proof.sig); - CHECK(loaded_pro.verify_signature(signing_pk)); - } - - // Try loading a proof with a bad signature in it from dict - { - session::config::dict bad_dict = good_dict; - std::array broken_sig = pro_cpp.proof.sig; - broken_sig[0] = ~broken_sig[0]; // Break the sig - - // clang-format off - const session::ProProof& proof = pro_cpp.proof; - bad_dict = { - {"r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())}, - {"p", session::config::dict{ - /*version*/ {"@", proof.version}, - /*gen_index_hash*/ {"g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())}, - /*rotating pubkey*/ {"r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())}, - /*expiry unix ts*/ {"e", proof.expiry_unix_ts.time_since_epoch().count()}, - /*signature*/ {"s", std::string{reinterpret_cast(broken_sig.data()), broken_sig.size()}}, - }} - }; - // clang-format on - - session::config::ProConfig loaded_pro = {}; - CHECK(loaded_pro.load(bad_dict)); - CHECK_FALSE(loaded_pro.verify_signature(signing_pk)); - } -} diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 77b47841..bd52a51c 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -1,12 +1,10 @@ #include -#include #include #include #include #include #include -#include #include #include From 66ecf924b5c26ba79b39211d6f68de109e7bef97 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 7 Nov 2025 15:33:19 +1100 Subject: [PATCH 143/171] Add new parse-error status code to pro backend responses --- include/session/pro_backend.h | 18 ++++++++++++++---- include/session/pro_backend.hpp | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 60432620..0b7c2175 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -11,9 +11,12 @@ extern "C" { #endif +/// Must match: +/// https://github.com/Doy-lee/session-pro-backend/blob/41a794e2998b528566d0c27d34c4faeed5602e26/server.py#L457 enum { SESSION_PRO_BACKEND_STATUS_SUCCESS = 0, SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR = 1, + SESSION_PRO_BACKEND_STATUS_PARSE_ERROR = 2, }; /// Store front that a Session Pro payment came from. Must match: @@ -61,11 +64,18 @@ typedef enum SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT { SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_COUNT, } SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT; +/// Must match: +/// https://github.com/Doy-lee/session-pro-backend/blob/41a794e2998b528566d0c27d34c4faeed5602e26/server.py#L461 typedef enum SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS { - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS, - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR, - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED, - SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_UNKNOWN_PAYMENT, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS = + SESSION_PRO_BACKEND_STATUS_SUCCESS, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_PARSE_ERROR = + SESSION_PRO_BACKEND_STATUS_PARSE_ERROR, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR = + SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR, + + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED = 100, + SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_UNKNOWN_PAYMENT = 101, } SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS; /// Bundle of hard-coded URLs that an application may want to redirect users to in various diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index a9231b29..f447edcf 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -66,8 +66,6 @@ constexpr array_uc32 PUBKEY = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static_assert(sizeof(PUBKEY) == array_uc32{}.size()); -/// NOTE: Must match -/// https://github.com/Doy-lee/session-pro-backend/blob/eed715c8ff7bc513486ca6c6ce88a93c988f67dd/server.py#L457 enum struct AddProPaymentResponseStatus { /// Payment was claimed and the pro proof was successfully generated Success = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_SUCCESS, @@ -75,6 +73,9 @@ enum struct AddProPaymentResponseStatus { /// Backend encountered an error when attempting to claim the payment Error = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ERROR, + /// Request JSON failed to be parsed correctly, payload was malformed or missing values + ParseError = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_PARSE_ERROR, + /// Payment is already claimed AlreadyRedeemed = SESSION_PRO_BACKEND_ADD_PRO_PAYMENT_RESPONSE_STATUS_ALREADY_REDEEMED, From 6c38f2c8eb019fb978bca2fbc1276fe02bb70939 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 10 Nov 2025 11:52:09 +1100 Subject: [PATCH 144/171] Merge EXTRA_PRO_FEATURES into PRO_FEATURES to simplify interface --- include/session/session_protocol.h | 29 ++++++++------------ include/session/session_protocol.hpp | 18 ++++++++---- src/session_protocol.cpp | 41 +++++++++++++++++----------- tests/test_session_protocol.cpp | 20 +++++++------- 4 files changed, 59 insertions(+), 49 deletions(-) diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index f0d1c68c..5d00e0f1 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -54,16 +54,6 @@ struct session_protocol_pro_proof { bytes64 sig; }; -// Bit flags for features that are not currently able to be determined by the state stored in -// Libsession. They are to be passed in by the client into `get_pro_msg_for_features` to return the -// bitset of `PRO_FEATURES` that a message will use. -typedef uint64_t SESSION_PROTOCOL_PRO_EXTRA_FEATURES; -enum SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ { - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_NIL = 0, - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE = 1 << 0, - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR = 1 << 1, -}; - // Bitset of Session Pro features that a message uses. This bitset is stored in the protobuf // `Content.proMessage` when a message is sent for other clients to consume. typedef uint64_t SESSION_PROTOCOL_PRO_FEATURES; @@ -290,8 +280,11 @@ typedef struct session_protocol_pro_features_for_msg { /// - `utf` -- the UTF8 string to count the number of codepoints in to determine if it needs the /// higher character limit available in Session Pro /// - `utf_size` -- the number of code units (aka. bytes) the string has -/// - `flags` -- extra pro features that are known by clients that they wish to be activated on -/// this message +/// - `features` -- Pro features to augment the message with, some feature flags may be ignored in +/// this function if they overlap with the feature flags that will derive itself. This function +/// hence ignores if it is specified: +/// 1. 10K_CHARACTER_LIMIT (because this function counts the UTF message to determine if this +/// feature should be applied). /// /// Outputs: /// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. @@ -303,8 +296,7 @@ typedef struct session_protocol_pro_features_for_msg { /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( - char const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) - NON_NULL_ARG(1); + char const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features) NON_NULL_ARG(1); /// API: session_protocol/session_protocol_get_pro_features_for_utf16 /// @@ -314,8 +306,11 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// - `utf` -- the UTF16 string to count the number of codepoints in to determine if it needs the /// higher character limit available in Session Pro /// - `utf_size` -- the number of code units (aka. bytes) the string has -/// - `flags` -- extra pro features that are known by clients that they wish to be activated on -/// this message +/// - `features` -- Pro features to augment the message with, some feature flags may be ignored in +/// this function if they overlap with the feature flags that will derive itself. This function +/// hence ignores if it is specified: +/// 1. 10K_CHARACTER_LIMIT (because this function counts the UTF message to determine if this +/// feature should be applied). /// /// Outputs: /// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. @@ -327,7 +322,7 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. LIBSESSION_EXPORT session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( - uint16_t const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) + uint16_t const* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features) NON_NULL_ARG(1); /// API: session_protocol_encode_for_1o1 diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index dcf51f12..883993a0 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -324,8 +324,11 @@ struct DecodeEnvelopeKey { /// higher character limit available in Session Pro /// - `utf_size` -- the size of the message in UTF8 code units to determine if the message requires /// access to the higher character limit available in Session Pro -/// - `flags` -- extra pro features that are known by clients that they wish to be activated on -/// this message +/// - `features` -- Pro features to augment the message with, some feature flags may be ignored in +/// this function if they overlap with the feature flags that will derive itself. This function +/// hence ignores if it is specified: +/// 1. 10K_CHARACTER_LIMIT (because this function counts the UTF message to determine if this +/// feature should be applied). /// /// Outputs: /// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. @@ -336,7 +339,7 @@ struct DecodeEnvelopeKey { /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf8( - const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); + const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features); /// API: session_protocol/pro_features_for_utf16 /// @@ -347,8 +350,11 @@ ProFeaturesForMsg pro_features_for_utf8( /// higher character limit available in Session Pro /// - `utf_size` -- the size of the message in UTF16 code units to determine if the message requires /// access to the higher character limit available in Session Pro -/// - `flags` -- extra pro features that are known by clients that they wish to be activated on -/// this message +/// - `features` -- Pro features to augment the message with, some feature flags may be ignored in +/// this function if they overlap with the feature flags that will derive itself. This function +/// hence ignores if it is specified: +/// 1. 10K_CHARACTER_LIMIT (because this function counts the UTF message to determine if this +/// feature should be applied). /// /// Outputs: /// - `success` -- True if the message was evaluated successfully for PRO features false otherwise. @@ -359,7 +365,7 @@ ProFeaturesForMsg pro_features_for_utf8( /// `ProMessage` in `Content` /// - `codepoint_count` -- Counts the number of unicode codepoints that were in the message. ProFeaturesForMsg pro_features_for_utf16( - const char16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags); + const char16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features); /// API: session_protocol/pad_message /// diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 76514dcb..bb903090 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -185,7 +186,18 @@ array_uc32 ProProof::hash() const { } session::ProFeaturesForMsg pro_features_for_utf8_or_16( - const void* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra, bool is_utf8) { + const void* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES flags, bool is_utf8) { + assert((flags & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) == 0 && + "A bit is set in 'flags' which does not correspond to a feature flag known by " + "libsession"); + + if (flags & SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT) { + oxen::log::warning( + oxen::log::Cat("protocol"), + "10k character limit flag was specified but will be ignored"); + flags &= ~SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT; + } + session::ProFeaturesForMsg result = {}; simdutf::result validate = is_utf8 ? simdutf::validate_utf8_with_errors( reinterpret_cast(utf), utf_size) @@ -199,19 +211,14 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( if (result.codepoint_count > SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT) { if (result.codepoint_count <= SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT) { - result.features |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + flags |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; } else { result.error = "Message exceeds the maximum character limit allowed"; result.status = session::ProFeaturesForMsgStatus::ExceedsCharacterLimit; } } - if (extra & SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR) - result.features |= SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR; - - if (extra & SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE) - result.features |= SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE; - + result.features = flags; assert((result.features & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) == 0); } else { result.status = session::ProFeaturesForMsgStatus::UTFDecodingError; @@ -224,14 +231,16 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( namespace session { ProFeaturesForMsg pro_features_for_utf8( - const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { - ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); + const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features) { + ProFeaturesForMsg result = + pro_features_for_utf8_or_16(utf, utf_size, features, /*is_utf8*/ true); return result; } ProFeaturesForMsg pro_features_for_utf16( - const char16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { - ProFeaturesForMsg result = pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); + const char16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features) { + ProFeaturesForMsg result = + pro_features_for_utf8_or_16(utf, utf_size, features, /*is_utf8*/ false); return result; } @@ -1130,9 +1139,9 @@ LIBSESSION_C_API SESSION_PROTOCOL_PRO_STATUS session_protocol_pro_proof_status( LIBSESSION_C_API session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( - const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { + const char* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features) { ProFeaturesForMsg result_cpp = - pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ true); + pro_features_for_utf8_or_16(utf, utf_size, features, /*is_utf8*/ true); session_protocol_pro_features_for_msg result = { .status = static_cast(result_cpp.status), .error = {const_cast(result_cpp.error.data()), result_cpp.error.size()}, @@ -1144,9 +1153,9 @@ session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf8( LIBSESSION_C_API session_protocol_pro_features_for_msg session_protocol_pro_features_for_utf16( - const uint16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_EXTRA_FEATURES extra) { + const uint16_t* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES features) { ProFeaturesForMsg result_cpp = - pro_features_for_utf8_or_16(utf, utf_size, extra, /*is_utf8*/ false); + pro_features_for_utf8_or_16(utf, utf_size, features, /*is_utf8*/ false); session_protocol_pro_features_for_msg result = { .status = static_cast(result_cpp.status), .error = {const_cast(result_cpp.error.data()), result_cpp.error.size()}, diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 5fd605c7..0663d5c5 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -109,8 +109,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); @@ -133,8 +133,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | @@ -148,8 +148,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | @@ -163,8 +163,8 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( msg.data(), msg.size(), - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE | - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR); + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | + SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_EXCEEDS_CHARACTER_LIMIT); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE | @@ -176,7 +176,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { { auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT, 'a'); session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( - msg.data(), msg.size(), SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE); + msg.data(), msg.size(), SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); REQUIRE(pro_msg.features == SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); REQUIRE(pro_msg.codepoint_count == msg.size()); @@ -445,7 +445,7 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( large_message.data(), large_message.size(), - SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE); + SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); REQUIRE(pro_msg.features == (SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); From de29ec0a49cbdd76126ea5f88ae6857e11b64638 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 11 Nov 2025 12:08:43 +1100 Subject: [PATCH 145/171] Document protobufs sigTimestamp and pro proof fields --- proto/SessionProtos.proto | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 743ed91b..06165b07 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -72,6 +72,10 @@ message Content { optional SharedConfigMessage sharedConfigMessage = 11; optional ExpirationType expirationType = 12; optional uint32 expirationTimer = 13; + + // NOTE: This timestamp was added to address the issue with 1o1 message envelope timestamps were + // unauthenticated because 1o1 messages encrypt the Content not the envelope. In Groups, the + // entire envelope is encrypted and hence can be trusted. optional uint64 sigTimestamp = 15; optional ProMessage proMessage = 16; @@ -385,10 +389,10 @@ message GroupUpdateDeleteMemberContentMessage { message ProProof { optional uint32 version = 1; - optional bytes genIndexHash = 2; - optional bytes rotatingPublicKey = 3; - optional uint64 expiryUnixTs = 4; // Epoch timestamp in milliseconds - optional bytes sig = 5; + optional bytes genIndexHash = 2; // Opaque identifier of this proof produced by the Session Pro backend + optional bytes rotatingPublicKey = 3; // Public key whose signatures is authorised to entitle messages with Session Pro + optional uint64 expiryUnixTs = 4; // Epoch timestamps in milliseconds + optional bytes sig = 5; // Signature produced by the Session Pro Backend signing over the hash of the proof } message ProMessage { From 0fd3d5cc07704b375f0185c5fb49ad9b5cfb8756 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 12 Nov 2025 13:49:09 +1100 Subject: [PATCH 146/171] Fix 10k character flag check in pro_features_for_utf For forwards compatibility, we can't assert as an existing client might observer messages from new clients that have different features. We previously asserted on this but this will cause some pain in development when switching between builds. --- src/session_protocol.cpp | 14 ++++++++------ tests/test_session_protocol.cpp | 10 ++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index bb903090..603d622f 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -187,15 +187,18 @@ array_uc32 ProProof::hash() const { session::ProFeaturesForMsg pro_features_for_utf8_or_16( const void* utf, size_t utf_size, SESSION_PROTOCOL_PRO_FEATURES flags, bool is_utf8) { - assert((flags & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) == 0 && - "A bit is set in 'flags' which does not correspond to a feature flag known by " - "libsession"); + if (flags & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) { + oxen::log::warning( + oxen::log::Cat("protocol"), + "A bit is set in 'flags' which does not correspond to a feature flag known by " + "libsession"); + } - if (flags & SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT) { + if (flags & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) { oxen::log::warning( oxen::log::Cat("protocol"), "10k character limit flag was specified but will be ignored"); - flags &= ~SESSION_PROTOCOL_PRO_HIGHER_CHARACTER_LIMIT; + flags &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; } session::ProFeaturesForMsg result = {}; @@ -219,7 +222,6 @@ session::ProFeaturesForMsg pro_features_for_utf8_or_16( } result.features = flags; - assert((result.features & ~SESSION_PROTOCOL_PRO_FEATURES_ALL) == 0); } else { result.status = session::ProFeaturesForMsgStatus::UTFDecodingError; result.error = simdutf::error_to_string(validate.error); diff --git a/tests/test_session_protocol.cpp b/tests/test_session_protocol.cpp index 0663d5c5..19f89ea7 100644 --- a/tests/test_session_protocol.cpp +++ b/tests/test_session_protocol.cpp @@ -172,6 +172,16 @@ TEST_CASE("Session protocol helpers C API", "[session-protocol][helpers]") { REQUIRE(pro_msg.codepoint_count == msg.size()); } + // Try asking for the 10k limit but passing a smaller message + { + auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT, 'a'); + session_protocol_pro_features_for_msg pro_msg = session_protocol_pro_features_for_utf8( + msg.data(), msg.size(), SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); + REQUIRE(pro_msg.status == SESSION_PROTOCOL_PRO_FEATURES_FOR_MSG_STATUS_SUCCESS); + REQUIRE(pro_msg.features == SESSION_PROTOCOL_PRO_FEATURES_NIL); + REQUIRE(pro_msg.codepoint_count == msg.size()); + } + // Try asking for just one extra feature { auto msg = std::string(SESSION_PROTOCOL_PRO_STANDARD_CHARACTER_LIMIT, 'a'); From 4945c20c6d809b194eef2059d82ea1bedab00ced Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 14 Nov 2025 15:10:46 +1100 Subject: [PATCH 147/171] Update Session Pro naming scheme for some apis get_pro_proof -> generate_pro_proof GetProProof -> GenerateProProof get_pro_status -> get_pro_details GetProStatus -> GetProDetails --- include/session/pro_backend.h | 108 ++++++++++++------------ include/session/pro_backend.hpp | 48 +++++------ src/pro_backend.cpp | 85 +++++++++---------- tests/test_pro_backend.cpp | 142 ++++++++++++++++---------------- 4 files changed, 195 insertions(+), 188 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 0b7c2175..2290f50f 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -58,11 +58,11 @@ typedef enum SESSION_PRO_BACKEND_USER_PRO_STATUS { SESSION_PRO_BACKEND_USER_PRO_STATUS_COUNT, } SESSION_PRO_BACKEND_USER_PRO_STATUS; -typedef enum SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT { - SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_SUCCESS, - SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_GENERIC_ERROR, - SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_COUNT, -} SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT; +typedef enum SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT { + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT_SUCCESS, + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT_GENERIC_ERROR, + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT_COUNT, +} SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT; /// Must match: /// https://github.com/Doy-lee/session-pro-backend/blob/41a794e2998b528566d0c27d34c4faeed5602e26/server.py#L461 @@ -219,8 +219,9 @@ struct session_pro_backend_add_pro_payment_request { bytes64 rotating_sig; }; -typedef struct session_pro_backend_get_pro_proof_request session_pro_backend_get_pro_proof_request; -struct session_pro_backend_get_pro_proof_request { +typedef struct session_pro_backend_generate_pro_proof_request + session_pro_backend_generate_pro_proof_request; +struct session_pro_backend_generate_pro_proof_request { uint8_t version; bytes32 master_pkey; bytes32 rotating_pkey; @@ -229,9 +230,9 @@ struct session_pro_backend_get_pro_proof_request { bytes64 rotating_sig; }; -typedef struct session_pro_backend_add_pro_payment_or_get_pro_proof_response - session_pro_backend_add_pro_payment_or_get_pro_proof_response; -struct session_pro_backend_add_pro_payment_or_get_pro_proof_response { +typedef struct session_pro_backend_add_pro_payment_or_generate_pro_proof_response + session_pro_backend_add_pro_payment_or_generate_pro_proof_response; +struct session_pro_backend_add_pro_payment_or_generate_pro_proof_response { session_pro_backend_response_header header; session_protocol_pro_proof proof; }; @@ -259,9 +260,9 @@ struct session_pro_backend_get_pro_revocations_response { size_t items_count; }; -typedef struct session_pro_backend_get_pro_status_request - session_pro_backend_get_pro_status_request; -struct session_pro_backend_get_pro_status_request { +typedef struct session_pro_backend_get_pro_details_request + session_pro_backend_get_pro_details_request; +struct session_pro_backend_get_pro_details_request { uint8_t version; bytes32 master_pkey; bytes64 master_sig; @@ -298,15 +299,15 @@ struct session_pro_backend_pro_payment_item { size_t apple_web_line_order_id_count; }; -typedef struct session_pro_backend_get_pro_status_response - session_pro_backend_get_pro_status_response; -struct session_pro_backend_get_pro_status_response { +typedef struct session_pro_backend_get_pro_details_response + session_pro_backend_get_pro_details_response; +struct session_pro_backend_get_pro_details_response { session_pro_backend_response_header header; /// Array of payment items, with items_count elements session_pro_backend_pro_payment_item* items; size_t items_count; SESSION_PRO_BACKEND_USER_PRO_STATUS status; - SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT error_report; + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT error_report; bool auto_renewing; uint64_t expiry_unix_ts_ms; uint64_t grace_period_duration_ms; @@ -373,9 +374,9 @@ session_pro_backend_to_json session_pro_backend_add_pro_payment_request_build_to const uint8_t* payment_tx_order_id, size_t payment_tx_order_id_len) NON_NULL_ARG(2, 4, 7, 9); -/// API: session_pro_backend/get_pro_proof_request_build_sigs +/// API: session_pro_backend/generate_pro_proof_request_build_sigs /// -/// Builds master and rotating signatures for a `get_pro_proof_request`. +/// Builds master and rotating signatures for a `generate_pro_proof_request`. /// Returns false if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. /// Using 64-byte libsodium keys is more efficient. /// @@ -394,7 +395,8 @@ session_pro_backend_to_json session_pro_backend_add_pro_payment_request_build_to /// - `master_sig` - Master signature /// - `rotating_sig` - Rotating signature LIBSESSION_EXPORT -session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof_request_build_sigs( +session_pro_backend_master_rotating_signatures +session_pro_backend_generate_pro_proof_request_build_sigs( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -402,15 +404,15 @@ session_pro_backend_master_rotating_signatures session_pro_backend_get_pro_proof size_t rotating_privkey_len, uint64_t unix_ts_ms) NON_NULL_ARG(2, 4); -/// API: session_pro_backend/get_pro_proof_request_build_to_json +/// API: session_pro_backend/generate_pro_proof_request_build_to_json /// -/// Builds the JSON for a `get_pro_proof_request`. This function is the same as filling in the +/// Builds the JSON for a `generate_pro_proof_request`. This function is the same as filling in the /// struct and calling the corresponding `to_json` function. /// The caller must free the returned string using `session_pro_backend_to_json_free`. /// -/// See: `session_pro_backend_get_pro_proof_request_build_sigs` +/// See: `session_pro_backend_generate_pro_proof_request_build_sigs` LIBSESSION_EXPORT -session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_json( +session_pro_backend_to_json session_pro_backend_generate_pro_proof_request_build_to_json( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -418,9 +420,9 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_j size_t rotating_privkey_len, uint64_t unix_ts_ms) NON_NULL_ARG(2, 4); -/// API: session_pro_backend/get_pro_status_request_build_sig +/// API: session_pro_backend/get_pro_details_request_build_sig /// -/// Builds the JSON for a `get_pro_status_request`. Returns false if the keys (32-byte or +/// Builds the JSON for a `get_pro_details_request`. Returns false if the keys (32-byte or /// 64-byte libsodium format) are incorrectly sized. Using 64-byte libsodium keys is more efficient. /// /// Inputs: @@ -436,22 +438,22 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_j /// - `errors_count` -- length of the error if `success` is false /// - `sig` -- The generated signature LIBSESSION_EXPORT -session_pro_backend_signature session_pro_backend_get_pro_status_request_build_sig( +session_pro_backend_signature session_pro_backend_get_pro_details_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, uint64_t unix_ts_ms, uint32_t count) NON_NULL_ARG(2); -/// API: session_pro_backend/get_pro_status_request_build_to_json +/// API: session_pro_backend/get_pro_details_request_build_to_json /// -/// Builds the JSON for a `get_pro_status_request`. This function is the same as filling in the +/// Builds the JSON for a `get_pro_details_request`. This function is the same as filling in the /// struct and calling the corresponding `to_json` function. /// The caller must free the returned string using `session_pro_backend_to_json_free`. /// -/// See: `session_pro_backend_get_pro_status_request_build_sig` +/// See: `session_pro_backend_get_pro_details_request_build_sig` LIBSESSION_EXPORT -session_pro_backend_to_json session_pro_backend_get_pro_status_request_build_to_json( +session_pro_backend_to_json session_pro_backend_get_pro_details_request_build_to_json( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -469,16 +471,16 @@ LIBSESSION_EXPORT session_pro_backend_to_json session_pro_backend_add_pro_payment_request_to_json( const session_pro_backend_add_pro_payment_request* request); -/// API: session_pro_backend/get_pro_proof_request_to_json +/// API: session_pro_backend/generate_pro_proof_request_to_json /// -/// Serializes a `get_pro_proof_request` to a JSON string. +/// Serializes a `generate_pro_proof_request` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. /// /// Inputs: /// - `request` -- Pointer to the request struct. LIBSESSION_EXPORT -session_pro_backend_to_json session_pro_backend_get_pro_proof_request_to_json( - const session_pro_backend_get_pro_proof_request* request); +session_pro_backend_to_json session_pro_backend_generate_pro_proof_request_to_json( + const session_pro_backend_generate_pro_proof_request* request); /// API: session_pro_backend/get_pro_revocations_request_to_json /// @@ -488,26 +490,26 @@ LIBSESSION_EXPORT session_pro_backend_to_json session_pro_backend_get_pro_revocations_request_to_json( const session_pro_backend_get_pro_revocations_request* request); -/// API: session_pro_backend/get_pro_status_request_to_json +/// API: session_pro_backend/get_pro_details_request_to_json /// -/// Serializes a `get_pro_status_request` to a JSON string. +/// Serializes a `get_pro_details_request` to a JSON string. /// The caller must free the returned string using `session_pro_backend_to_json_free`. LIBSESSION_EXPORT -session_pro_backend_to_json session_pro_backend_get_pro_status_request_to_json( - const session_pro_backend_get_pro_status_request* request); +session_pro_backend_to_json session_pro_backend_get_pro_details_request_to_json( + const session_pro_backend_get_pro_details_request* request); -/// API: session_pro_backend/add_pro_payment_or_get_pro_proof_response_parse +/// API: session_pro_backend/add_pro_payment_or_generate_pro_proof_response_parse /// -/// Parses a JSON string into an `add_pro_payment_or_get_pro_proof_response` struct. +/// Parses a JSON string into an `add_pro_payment_or_generate_pro_proof_response` struct. /// The caller must free the response using -/// `session_pro_backend_add_pro_payment_or_get_pro_proof_response_free`. +/// `session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free`. /// /// Inputs: /// - `json` -- JSON string to parse. /// - `json_len` -- Length of the JSON string. LIBSESSION_EXPORT -session_pro_backend_add_pro_payment_or_get_pro_proof_response -session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( +session_pro_backend_add_pro_payment_or_generate_pro_proof_response +session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( const char* json, size_t json_len); /// API: session_pro_backend/get_pro_revocations_response_parse @@ -522,16 +524,16 @@ LIBSESSION_EXPORT session_pro_backend_get_pro_revocations_response session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t json_len); -/// API: session_pro_backend/get_pro_status_response_parse +/// API: session_pro_backend/get_pro_details_response_parse /// /// Parses a JSON string into a GetProPaymentsResponse struct. -/// The caller must free the response using session_pro_backend_get_pro_status_response_free. +/// The caller must free the response using session_pro_backend_get_pro_details_response_free. /// /// Inputs: /// - `json` -- JSON string to parse. /// - `json_len` -- Length of the JSON string. LIBSESSION_EXPORT -session_pro_backend_get_pro_status_response session_pro_backend_get_pro_status_response_parse( +session_pro_backend_get_pro_details_response session_pro_backend_get_pro_details_response_parse( const char* json, size_t json_len); /// API: session_pro_backend/to_json_free @@ -540,12 +542,12 @@ session_pro_backend_get_pro_status_response session_pro_backend_get_pro_status_r LIBSESSION_EXPORT void session_pro_backend_to_json_free(session_pro_backend_to_json* to_json); -/// API: session_pro_backend/add_pro_payment_or_get_pro_proof_response_free +/// API: session_pro_backend/add_pro_payment_or_generate_pro_proof_response_free /// /// Frees the response LIBSESSION_EXPORT -void session_pro_backend_add_pro_payment_or_get_pro_proof_response_free( - session_pro_backend_add_pro_payment_or_get_pro_proof_response* response); +void session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free( + session_pro_backend_add_pro_payment_or_generate_pro_proof_response* response); /// API: session_pro_backend/get_pro_revocations_response_free /// @@ -554,12 +556,12 @@ LIBSESSION_EXPORT void session_pro_backend_get_pro_revocations_response_free( session_pro_backend_get_pro_revocations_response* response); -/// API: session_pro_backend/get_pro_status_response_free +/// API: session_pro_backend/get_pro_details_response_free /// /// Frees the respone LIBSESSION_EXPORT -void session_pro_backend_get_pro_status_response_free( - session_pro_backend_get_pro_status_response* response); +void session_pro_backend_get_pro_details_response_free( + session_pro_backend_get_pro_details_response* response); #ifdef __cplusplus } // extern "C" diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index f447edcf..0eaa9ea8 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -18,10 +18,10 @@ /// 1. Build a request with `AddProPaymentRequest::build_to_json` from a Session Pro payment and /// submit it to the backend to register the specified Ed25519 keys for Session Pro. /// -/// Server responds JSON to be parsed with `AddProPaymentOrGetProProofResponse::parse`. Clients -/// should validate the response and update their `UserProfile` by constructing a `ProConfig` -/// with the `proof` from the response and filling in the relevant rotating private key that the -/// proof was authorised for. +/// Server responds JSON to be parsed with `AddProPaymentOrGenerateProProofResponse::parse`. +/// Clients should validate the response and update their `UserProfile` by constructing a +/// `ProConfig` with the `proof` from the response and filling in the relevant rotating private +/// key that the proof was authorised for. /// /// The server will only respond successfully if it can also independently verify the purchase /// otherwise an error is returned and can be read from the `ResponseHeader` after parsing the @@ -47,9 +47,9 @@ /// revoked proofs will not be entitled to Pro features. /// /// 4. Query the status (and optionally payment history) of a user's Session Pro Master Ed25519 key -/// has registered by building a `GetProStatusRequest::build_to_json` query and submitting it. +/// has registered by building a `GetProDetailsRequest::build_to_json` query and submitting it. /// -/// Server responds JSON to be parsed with `GetProStatusResponse::parse` which they can use to +/// Server responds JSON to be parsed with `GetProDetailsResponse::parse` which they can use to /// populate their client's payment history. /// /// 5. Get a list of per-payment provider URLs, such as links to the support page for refunds and @@ -213,10 +213,10 @@ struct AddProPaymentRequest { /// The generated proof from the Session Pro backend that has been parsed from JSON. This structure /// is the raw parse result that can then be converted into the config::ProProof or equivalent /// structure. -struct AddProPaymentOrGetProProofResponse : public ResponseHeader { +struct AddProPaymentOrGenerateProProofResponse : public ResponseHeader { ProProof proof; - /// API: pro/AddProPaymentOrGetProProofResponse::parse + /// API: pro/AddProPaymentOrGenerateProProofResponse::parse /// /// Parses a JSON string into the response struct. /// @@ -225,14 +225,14 @@ struct AddProPaymentOrGetProProofResponse : public ResponseHeader { /// /// Outputs: /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. - static AddProPaymentOrGetProProofResponse parse(std::string_view json); + static AddProPaymentOrGenerateProProofResponse parse(std::string_view json); }; /// Request a new Session Pro proof from the backend. The specified `master_pkey` must have /// previously already registered a payment to the backend that is still active and hence entitled /// to Session Pro features. This endpoint can then be used to pair a new Ed25519 key to be /// authorised to use a the Session Pro proof. -struct GetProProofRequest { +struct GenerateProProofRequest { /// Request version. The latest accepted version is 0 std::uint8_t version; @@ -253,7 +253,7 @@ struct GetProProofRequest { /// 64-byte signature proving knowledge of the rotating key's secret component array_uc64 rotating_sig; - /// API: pro/GetProProofRequest::build_sigs + /// API: pro/GenerateProProofRequest::build_sigs /// /// Builds master and rotating signatures using the provided private keys and timestamp. /// Throws if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. @@ -273,10 +273,10 @@ struct GetProProofRequest { std::span rotating_privkey, std::chrono::sys_time unix_ts); - /// API: pro/GetProProofRequest::build_to_json + /// API: pro/GenerateProProofRequest::build_to_json /// - /// Builds a GetProProofRequest and serialize it to JSON. This function is the same as filling - /// the struct fields and calling `to_json`. + /// Builds a GenerateProProofRequest and serialize it to JSON. This function is the same as + /// filling the struct fields and calling `to_json`. /// /// Inputs: /// - `request_version` -- Version of the request to build a request for @@ -292,7 +292,7 @@ struct GetProProofRequest { std::span rotating_privkey, std::chrono::sys_time unix_ts); - /// API: pro/GetProProofRequest::to_json + /// API: pro/GenerateProProofRequest::to_json /// /// Serializes the request to a JSON string. /// @@ -313,7 +313,7 @@ struct GetProRevocationsRequest { /// the Session Pro Backend to omit the revocation list if it has not changed. std::uint32_t ticket; - /// API: pro/GetProProofRequest::to_json + /// API: pro/GenerateProProofRequest::to_json /// /// Serializes the request to a JSON string. /// @@ -350,7 +350,7 @@ struct GetProRevocationsResponse : public ResponseHeader { static GetProRevocationsResponse parse(std::string_view json); }; -struct GetProStatusRequest { +struct GetProDetailsRequest { /// Request version for the API std::uint8_t version; @@ -386,9 +386,9 @@ struct GetProStatusRequest { std::chrono::sys_time unix_ts, uint32_t count); - /// API: pro/GetProStatusRequest::build_to_json + /// API: pro/GetProDetailsRequest::build_to_json /// - /// Builds a GetProStatusRequest and serialize it to JSON. This function is the same as filling + /// Builds a GetProDetailsRequest and serialize it to JSON. This function is the same as filling /// the struct fields and calling `to_json`. /// /// Inputs: @@ -405,7 +405,7 @@ struct GetProStatusRequest { std::chrono::sys_time unix_ts, uint32_t count); - /// API: pro/GetProProofRequest::to_json + /// API: pro/GenerateProProofRequest::to_json /// /// Serializes the request to a JSON string. /// @@ -483,7 +483,7 @@ struct ProPaymentItem { std::string apple_web_line_order_id; }; -struct GetProStatusResponse : public ResponseHeader { +struct GetProDetailsResponse : public ResponseHeader { /// List of payment items for the master public key std::vector items; @@ -493,7 +493,7 @@ struct GetProStatusResponse : public ResponseHeader { /// Error code that indicates that the Session Pro Backend encountered an error book-keeping /// Session Pro entitlement for the user. If this value is not `SUCCESS` implementing clients /// can optionally prompt the user that they should contact support for investigation. - SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT error_report; + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT error_report; /// Flag to indicate if the user will automatically renew their subscription. bool auto_renewing; @@ -534,7 +534,7 @@ struct GetProStatusResponse : public ResponseHeader { /// length of items if the request, requested less than the number of payments the user has. uint32_t payments_total; - /// API: pro/GetProStatusResponse::parse + /// API: pro/GetProDetailsResponse::parse /// /// Parses a JSON string into the response struct. /// @@ -543,7 +543,7 @@ struct GetProStatusResponse : public ResponseHeader { /// /// Outputs: /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. - static GetProStatusResponse parse(std::string_view json); + static GetProDetailsResponse parse(std::string_view json); }; void make_blake2b32_hasher(struct crypto_generichash_blake2b_state* hasher); diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 24a11391..ad6fc03b 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -285,10 +285,10 @@ std::string AddProPaymentRequest::build_to_json( return result; } -AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse( +AddProPaymentOrGenerateProProofResponse AddProPaymentOrGenerateProProofResponse::parse( std::string_view json) { // Parse basics - AddProPaymentOrGetProProofResponse result = {}; + AddProPaymentOrGenerateProProofResponse result = {}; nlohmann::json j = json_parse(json, result.errors); result.status = json_require(j, "status", result.errors); if (result.errors.size()) { @@ -319,7 +319,7 @@ AddProPaymentOrGetProProofResponse AddProPaymentOrGetProProofResponse::parse( return result; } -std::string GetProProofRequest::to_json() const { +std::string GenerateProProofRequest::to_json() const { nlohmann::json j; j["version"] = version; j["master_pkey"] = oxenc::to_hex(master_pkey); @@ -331,7 +331,7 @@ std::string GetProProofRequest::to_json() const { return result; } -MasterRotatingSignatures GetProProofRequest::build_sigs( +MasterRotatingSignatures GenerateProProofRequest::build_sigs( std::uint8_t request_version, std::span master_privkey, std::span rotating_privkey, @@ -390,7 +390,7 @@ MasterRotatingSignatures GetProProofRequest::build_sigs( return result; } -std::string GetProProofRequest::build_to_json( +std::string GenerateProProofRequest::build_to_json( std::uint8_t request_version, std::span master_privkey, std::span rotating_privkey, @@ -416,10 +416,10 @@ std::string GetProProofRequest::build_to_json( throw std::invalid_argument{"Invalid rotating_privkey: expected 32 or 64 bytes"}; } - MasterRotatingSignatures sigs = GetProProofRequest::build_sigs( + MasterRotatingSignatures sigs = GenerateProProofRequest::build_sigs( request_version, master_privkey, rotating_privkey, unix_ts); - GetProProofRequest request = {}; + GenerateProProofRequest request = {}; request.version = request_version; std::memcpy( request.master_pkey.data(), @@ -497,7 +497,7 @@ GetProRevocationsResponse GetProRevocationsResponse::parse(std::string_view json return result; } -std::string GetProStatusRequest::to_json() const { +std::string GetProDetailsRequest::to_json() const { nlohmann::json j; j["version"] = version; j["master_pkey"] = oxenc::to_hex(master_pkey); @@ -508,7 +508,7 @@ std::string GetProStatusRequest::to_json() const { return result; } -array_uc64 GetProStatusRequest::build_sig( +array_uc64 GetProDetailsRequest::build_sig( uint8_t version, std::span master_privkey, std::chrono::sys_time unix_ts, @@ -551,7 +551,7 @@ array_uc64 GetProStatusRequest::build_sig( return result; } -std::string GetProStatusRequest::build_to_json( +std::string GetProDetailsRequest::build_to_json( uint8_t version, std::span master_privkey, std::chrono::sys_time unix_ts, @@ -566,12 +566,12 @@ std::string GetProStatusRequest::build_to_json( throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; } - GetProStatusRequest request = {}; + GetProDetailsRequest request = {}; request.version = version; memcpy(request.master_pkey.data(), master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, crypto_sign_ed25519_PUBLICKEYBYTES); - request.master_sig = GetProStatusRequest::build_sig(version, master_privkey, unix_ts, count); + request.master_sig = GetProDetailsRequest::build_sig(version, master_privkey, unix_ts, count); request.unix_ts = unix_ts; request.count = count; @@ -579,9 +579,9 @@ std::string GetProStatusRequest::build_to_json( return result; } -GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { +GetProDetailsResponse GetProDetailsResponse::parse(std::string_view json) { // Parse basics - GetProStatusResponse result = {}; + GetProDetailsResponse result = {}; nlohmann::json j = json_parse(json, result.errors); result.status = json_require(j, "status", result.errors); if (result.errors.size()) { @@ -609,13 +609,13 @@ GetProStatusResponse GetProStatusResponse::parse(std::string_view json) { result.user_status = static_cast(user_status); uint32_t error_report = json_require(result_obj, "error_report", result.errors); - if (error_report >= SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_COUNT) { + if (error_report >= SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT_COUNT) { result.errors.push_back( fmt::format("Error report value was out-of-bounds: {}", user_status)); return result; } result.error_report = - static_cast(error_report); + static_cast(error_report); result.auto_renewing = json_require(result_obj, "auto_renewing", result.errors); @@ -840,7 +840,7 @@ session_pro_backend_add_pro_payment_request_build_to_json( } LIBSESSION_C_API session_pro_backend_master_rotating_signatures -session_pro_backend_get_pro_proof_request_build_sigs( +session_pro_backend_generate_pro_proof_request_build_sigs( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -855,7 +855,7 @@ session_pro_backend_get_pro_proof_request_build_sigs( session_pro_backend_master_rotating_signatures result = {}; try { - auto sigs = GetProProofRequest::build_sigs( + auto sigs = GenerateProProofRequest::build_sigs( request_version, master_span, rotating_span, @@ -876,7 +876,7 @@ session_pro_backend_get_pro_proof_request_build_sigs( } LIBSESSION_EXPORT -session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_json( +session_pro_backend_to_json session_pro_backend_generate_pro_proof_request_build_to_json( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -890,7 +890,7 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_j session_pro_backend_to_json result = {}; try { - auto json = GetProProofRequest::build_to_json( + auto json = GenerateProProofRequest::build_to_json( request_version, master_span, rotating_span, @@ -909,7 +909,8 @@ session_pro_backend_to_json session_pro_backend_get_pro_proof_request_build_to_j return result; } -LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_status_request_build_sig( +LIBSESSION_C_API session_pro_backend_signature +session_pro_backend_get_pro_details_request_build_sig( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -921,7 +922,7 @@ LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_statu session_pro_backend_signature result = {}; try { - auto sig = GetProStatusRequest::build_sig(request_version, master_span, ts, count); + auto sig = GetProDetailsRequest::build_sig(request_version, master_span, ts, count); std::memcpy(result.sig.data, sig.data(), sig.size()); result.success = true; } catch (const std::exception& e) { @@ -937,7 +938,7 @@ LIBSESSION_C_API session_pro_backend_signature session_pro_backend_get_pro_statu } LIBSESSION_C_API session_pro_backend_to_json -session_pro_backend_get_pro_status_request_build_to_json( +session_pro_backend_get_pro_details_request_build_to_json( uint8_t request_version, const uint8_t* master_privkey, size_t master_privkey_len, @@ -949,7 +950,7 @@ session_pro_backend_get_pro_status_request_build_to_json( session_pro_backend_to_json result = {}; try { - auto json = GetProStatusRequest::build_to_json(request_version, master_span, ts, count); + auto json = GetProDetailsRequest::build_to_json(request_version, master_span, ts, count); result.json = session::string8_copy_or_throw(json.data(), json.size()); result.success = true; } catch (const std::exception& e) { @@ -1000,14 +1001,14 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_add_pro_payment return result; } -LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_proof_request_to_json( - const session_pro_backend_get_pro_proof_request* request) { +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_generate_pro_proof_request_to_json( + const session_pro_backend_generate_pro_proof_request* request) { session_pro_backend_to_json result = {}; if (!request) return result; // Construct C++ struct - GetProProofRequest cpp; + GenerateProProofRequest cpp; cpp.version = request->version; std::memcpy(cpp.master_pkey.data(), request->master_pkey.data, cpp.master_pkey.size()); std::memcpy(cpp.rotating_pkey.data(), request->rotating_pkey.data, cpp.rotating_pkey.size()); @@ -1062,14 +1063,14 @@ session_pro_backend_get_pro_revocations_request_to_json( return result; } -LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_request_to_json( - const session_pro_backend_get_pro_status_request* request) { +LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_details_request_to_json( + const session_pro_backend_get_pro_details_request* request) { session_pro_backend_to_json result = {}; if (!request) return result; // Construct C++ struct - GetProStatusRequest cpp = {}; + GetProDetailsRequest cpp = {}; cpp.version = request->version; std::memcpy( cpp.master_pkey.data(), request->master_pkey.data, sizeof(request->master_pkey.data)); @@ -1095,11 +1096,11 @@ LIBSESSION_C_API session_pro_backend_to_json session_pro_backend_get_pro_status_ return result; } -LIBSESSION_C_API session_pro_backend_add_pro_payment_or_get_pro_proof_response -session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( +LIBSESSION_C_API session_pro_backend_add_pro_payment_or_generate_pro_proof_response +session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( const char* json, size_t json_len) { - session_pro_backend_add_pro_payment_or_get_pro_proof_response result = {}; + session_pro_backend_add_pro_payment_or_generate_pro_proof_response result = {}; if (!json) { result.header.status = 1; result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; @@ -1108,7 +1109,7 @@ session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( } // Note, parse is written to not throw so we can safely read without try-catch crap - auto cpp = AddProPaymentOrGetProProofResponse::parse({json, json_len}); + auto cpp = AddProPaymentOrGenerateProProofResponse::parse({json, json_len}); // Calculate how much memory we need and create an arena arena_t arena = {}; @@ -1226,9 +1227,9 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t return result; } -LIBSESSION_C_API session_pro_backend_get_pro_status_response -session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_len) { - session_pro_backend_get_pro_status_response result = {}; +LIBSESSION_C_API session_pro_backend_get_pro_details_response +session_pro_backend_get_pro_details_response_parse(const char* json, size_t json_len) { + session_pro_backend_get_pro_details_response result = {}; if (!json) { result.header.status = 1; result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; @@ -1237,7 +1238,7 @@ session_pro_backend_get_pro_status_response_parse(const char* json, size_t json_ } // Note, parse is written to not throw so we can safely read without try-catch crap - auto cpp = GetProStatusResponse::parse({json, json_len}); + auto cpp = GetProDetailsResponse::parse({json, json_len}); // Calculate how much memory we need and create an arena arena_t arena = {}; @@ -1347,8 +1348,8 @@ LIBSESSION_C_API void session_pro_backend_to_json_free(session_pro_backend_to_js } } -LIBSESSION_C_API void session_pro_backend_add_pro_payment_or_get_pro_proof_response_free( - session_pro_backend_add_pro_payment_or_get_pro_proof_response* response) { +LIBSESSION_C_API void session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free( + session_pro_backend_add_pro_payment_or_generate_pro_proof_response* response) { if (response) { free(response->header.internal_arena_buf_); *response = {}; @@ -1363,8 +1364,8 @@ LIBSESSION_C_API void session_pro_backend_get_pro_revocations_response_free( } } -LIBSESSION_C_API void session_pro_backend_get_pro_status_response_free( - session_pro_backend_get_pro_status_response* response) { +LIBSESSION_C_API void session_pro_backend_get_pro_details_response_free( + session_pro_backend_get_pro_details_response* response) { if (response) { free(response->header.internal_arena_buf_); *response = {}; diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index bd52a51c..00c4d7df 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -187,11 +187,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.error_count > 0); } - SECTION("session_pro_backend_get_pro_proof_request_build_sigs") { + SECTION("session_pro_backend_generate_pro_proof_request_build_sigs") { session_pro_backend_master_rotating_signatures result = {}; // Valid inputs - result = session_pro_backend_get_pro_proof_request_build_sigs( + result = session_pro_backend_generate_pro_proof_request_build_sigs( 0, master_privkey.data, sizeof(master_privkey), @@ -202,7 +202,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.error_count == 0); // Verify signatures match C++ implementation - auto cpp_sigs = GetProProofRequest::build_sigs( + auto cpp_sigs = GenerateProProofRequest::build_sigs( 0, master_privkey.data, rotating_privkey.data, @@ -218,7 +218,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(result.rotating_sig)) == 0); // Invalid rotating key size - result = session_pro_backend_get_pro_proof_request_build_sigs( + result = session_pro_backend_generate_pro_proof_request_build_sigs( 0, master_privkey.data, sizeof(master_privkey), @@ -306,15 +306,15 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.json.size == 0); } - SECTION("session_pro_backend_get_pro_proof_request_to_json") { - session_pro_backend_get_pro_proof_request request = {}; + SECTION("session_pro_backend_generate_pro_proof_request_to_json") { + session_pro_backend_generate_pro_proof_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; request.unix_ts_ms = unix_ts_ms; session_pro_backend_master_rotating_signatures sigs = - session_pro_backend_get_pro_proof_request_build_sigs( + session_pro_backend_generate_pro_proof_request_build_sigs( request.version, master_privkey.data, sizeof(master_privkey.data), @@ -326,7 +326,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.rotating_sig = sigs.rotating_sig; // Valid request - auto result = session_pro_backend_get_pro_proof_request_to_json(&request); + auto result = session_pro_backend_generate_pro_proof_request_to_json(&request); { scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; REQUIRE(result.success); @@ -334,7 +334,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.json.size > 0); // Verify JSON matches C++ implementation - GetProProofRequest cpp = {}; + GenerateProProofRequest cpp = {}; cpp.version = request.version; std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); std::memcpy( @@ -348,7 +348,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(string8_equals(result.json, cpp_json)); // Verify that the helper one-shot-to-json function generates the same payload - auto one_shot = session_pro_backend_get_pro_proof_request_build_to_json( + auto one_shot = session_pro_backend_generate_pro_proof_request_build_to_json( request.version, master_privkey.data, sizeof(master_privkey.data), @@ -366,7 +366,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.json.size == 0); // Null request - result = session_pro_backend_get_pro_proof_request_to_json(nullptr); + result = session_pro_backend_generate_pro_proof_request_to_json(nullptr); REQUIRE(!result.success); REQUIRE(result.json.data == nullptr); REQUIRE(result.json.size == 0); @@ -404,15 +404,15 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.json.size == 0); } - SECTION("session_pro_backend_get_pro_status_request_to_json") { - session_pro_backend_get_pro_status_request request = {}; + SECTION("session_pro_backend_get_pro_details_request_to_json") { + session_pro_backend_get_pro_details_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.unix_ts_ms = unix_ts_ms; request.count = 10'000; session_pro_backend_signature sig = - session_pro_backend_get_pro_status_request_build_sig( + session_pro_backend_get_pro_details_request_build_sig( request.version, master_privkey.data, sizeof(master_privkey.data), @@ -422,7 +422,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.master_sig = sig.sig; // Valid request - auto result = session_pro_backend_get_pro_status_request_to_json(&request); + auto result = session_pro_backend_get_pro_details_request_to_json(&request); { scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; REQUIRE(result.success); @@ -430,7 +430,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.json.size > 0); // Verify JSON matches C++ implementation - GetProStatusRequest cpp = {}; + GetProDetailsRequest cpp = {}; cpp.version = 0; std::memcpy(cpp.master_pkey.data(), master_pubkey.data, sizeof(master_pubkey)); std::memcpy(cpp.master_sig.data(), sig.sig.data, sizeof(sig.sig)); @@ -441,7 +441,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(string8_equals(result.json, cpp_json)); // Verify that the helper one-shot-to-json function generates the same payload - auto one_shot = session_pro_backend_get_pro_status_request_build_to_json( + auto one_shot = session_pro_backend_get_pro_details_request_build_to_json( request.version, master_privkey.data, sizeof(master_privkey.data), @@ -458,13 +458,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.json.size == 0); // Null request - result = session_pro_backend_get_pro_status_request_to_json(nullptr); + result = session_pro_backend_get_pro_details_request_to_json(nullptr); REQUIRE(!result.success); REQUIRE(result.json.data == nullptr); REQUIRE(result.json.size == 0); } - SECTION("session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse") { + SECTION("session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse") { char fake_gen_index_hash[32]; randombytes_buf(fake_gen_index_hash, sizeof(fake_gen_index_hash)); @@ -482,12 +482,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string json = j.dump(); // Valid JSON - session_pro_backend_add_pro_payment_or_get_pro_proof_response result = - session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + session_pro_backend_add_pro_payment_or_generate_pro_proof_response result = + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( json.data(), json.size()); { scope_exit result_free{[&]() { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free( + &result); }}; for (size_t index = 0; index < result.header.errors_count; index++) @@ -512,7 +513,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Here we also create the CPP version, we will run the conversion functions into // pro proofs (both C and CPP variants) and then compare the two structures to make // sure the conversion functions are sound. - auto result_cpp = AddProPaymentOrGetProProofResponse::parse(json); + auto result_cpp = AddProPaymentOrGenerateProProofResponse::parse(json); // Validate C and CPP variants REQUIRE(result.proof.version == result_cpp.proof.version); @@ -539,11 +540,12 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Invalid JSON json = "{invalid}"; - result = session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + result = session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( json.data(), json.size()); { scope_exit result_free{[&]() { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free( + &result); }}; REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count > 0); @@ -551,12 +553,12 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { } // After freeing - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&result); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free(&result); REQUIRE(result.header.internal_arena_buf_ == nullptr); // Null JSON - result = - session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse(nullptr, 0); + result = session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( + nullptr, 0); REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count == 1); REQUIRE(result.header.errors != nullptr); @@ -629,12 +631,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.header.errors != nullptr); } - SECTION("session_pro_backend_get_pro_status_response_parse") { + SECTION("session_pro_backend_get_pro_details_response_parse") { nlohmann::json j; j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; j["result"] = { {"status", SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED}, - {"error_report", SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_GENERIC_ERROR}, + {"error_report", + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT_GENERIC_ERROR}, {"auto_renewing", true}, {"expiry_unix_ts_ms", unix_ts_ms + 2}, {"grace_period_duration_ms", 1000}, @@ -660,10 +663,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Valid JSON auto result = - session_pro_backend_get_pro_status_response_parse(json.data(), json.size()); + session_pro_backend_get_pro_details_response_parse(json.data(), json.size()); { scope_exit result_free{ - [&]() { session_pro_backend_get_pro_status_response_free(&result); }}; + [&]() { session_pro_backend_get_pro_details_response_free(&result); }}; for (size_t index = 0; index < result.header.errors_count; index++) INFO(result.header.errors[index].data); @@ -672,7 +675,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.header.errors == nullptr); REQUIRE(result.status == SESSION_PRO_BACKEND_USER_PRO_STATUS_EXPIRED); REQUIRE(result.error_report == - SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT_GENERIC_ERROR); + SESSION_PRO_BACKEND_GET_PRO_DETAILS_ERROR_REPORT_GENERIC_ERROR); REQUIRE(result.items_count == 1); REQUIRE(result.auto_renewing == true); REQUIRE(result.grace_period_duration_ms == 1000); @@ -708,10 +711,10 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Invalid JSON json = "{invalid}"; - result = session_pro_backend_get_pro_status_response_parse(json.data(), json.size()); + result = session_pro_backend_get_pro_details_response_parse(json.data(), json.size()); { std::unique_ptr> esult_free(nullptr, [&](void*) { - session_pro_backend_get_pro_status_response_free(&result); + session_pro_backend_get_pro_details_response_free(&result); }); REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count > 0); @@ -719,11 +722,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { } // After freeing - session_pro_backend_get_pro_status_response_free(&result); + session_pro_backend_get_pro_details_response_free(&result); REQUIRE(result.header.internal_arena_buf_ == nullptr); // Null JSON - result = session_pro_backend_get_pro_status_response_parse(nullptr, 0); + result = session_pro_backend_get_pro_details_response_parse(nullptr, 0); REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); REQUIRE(result.header.errors_count == 1); REQUIRE(result.header.errors != nullptr); @@ -736,16 +739,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(to_json.json.data == nullptr); REQUIRE(to_json.json.size == 0); - session_pro_backend_add_pro_payment_or_get_pro_proof_response proof_response = {}; - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&proof_response); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response proof_response = {}; + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free( + &proof_response); REQUIRE(proof_response.header.internal_arena_buf_ == nullptr); session_pro_backend_get_pro_revocations_response rev_response = {}; session_pro_backend_get_pro_revocations_response_free(&rev_response); REQUIRE(rev_response.header.internal_arena_buf_ == nullptr); - session_pro_backend_get_pro_status_response pay_response = {}; - session_pro_backend_get_pro_status_response_free(&pay_response); + session_pro_backend_get_pro_details_response pay_response = {}; + session_pro_backend_get_pro_details_response_free(&pay_response); REQUIRE(pay_response.header.internal_arena_buf_ == nullptr); } } @@ -827,11 +831,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string_view(request_json.json.data, request_json.json.size)); // Parse response - session_pro_backend_add_pro_payment_or_get_pro_proof_response response = - session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + session_pro_backend_add_pro_payment_or_generate_pro_proof_response response = + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( response_json.data(), response_json.size()); scope_exit response_free{[&]() { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free(&response); }}; for (size_t index = 0; index < response.header.errors_count; index++) { @@ -857,7 +861,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { uint64_t now_unix_ts_ms = time(nullptr) * 1000; // Build request session_pro_backend_master_rotating_signatures pro_sigs = - session_pro_backend_get_pro_proof_request_build_sigs( + session_pro_backend_generate_pro_proof_request_build_sigs( /*version*/ 0, master_privkey.data, sizeof(master_privkey), @@ -865,7 +869,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(rotating_privkey), now_unix_ts_ms); - session_pro_backend_get_pro_proof_request request = {}; + session_pro_backend_generate_pro_proof_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; @@ -874,7 +878,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { request.rotating_sig = pro_sigs.rotating_sig; session_pro_backend_to_json request_json = - session_pro_backend_get_pro_proof_request_to_json(&request); + session_pro_backend_generate_pro_proof_request_to_json(&request); scope_exit request_json_free{ [&]() { session_pro_backend_to_json_free(&request_json); }}; @@ -882,15 +886,15 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - g_test_pro_backend_dev_server_url + "/get_pro_proof", + g_test_pro_backend_dev_server_url + "/generate_pro_proof", std::string_view(request_json.json.data, request_json.json.size)); // Parse response - session_pro_backend_add_pro_payment_or_get_pro_proof_response response = - session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + session_pro_backend_add_pro_payment_or_generate_pro_proof_response response = + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( response_json.data(), response_json.size()); std::unique_ptr> response_free(nullptr, [&](void*) { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free(&response); }); for (size_t index = 0; index < response.header.errors_count; index++) { @@ -912,20 +916,20 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(request.rotating_pkey)) == 0); session_pro_backend_to_json_free(&request_json); - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free(&response); } // Get pro status { // Build request - session_pro_backend_get_pro_status_request request = {}; + session_pro_backend_get_pro_details_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.unix_ts_ms = time(nullptr) * 1000; request.count = 10'000; session_pro_backend_signature sig = - session_pro_backend_get_pro_status_request_build_sig( + session_pro_backend_get_pro_details_request_build_sig( request.version, master_privkey.data, sizeof(master_privkey.data), @@ -936,22 +940,22 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Do CURL request session_pro_backend_to_json request_json = - session_pro_backend_get_pro_status_request_to_json(&request); + session_pro_backend_get_pro_details_request_to_json(&request); scope_exit request_json_free{ [&]() { session_pro_backend_to_json_free(&request_json); }}; std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - g_test_pro_backend_dev_server_url + "/get_pro_status", + g_test_pro_backend_dev_server_url + "/get_pro_details", std::string_view(request_json.json.data, request_json.json.size)); // Parse response - session_pro_backend_get_pro_status_response response = - session_pro_backend_get_pro_status_response_parse( + session_pro_backend_get_pro_details_response response = + session_pro_backend_get_pro_details_response_parse( response_json.data(), response_json.size()); scope_exit response_free{ - [&]() { session_pro_backend_get_pro_status_response_free(&response); }}; + [&]() { session_pro_backend_get_pro_details_response_free(&response); }}; // Verify the response for (size_t index = 0; index < response.header.errors_count; index++) { @@ -969,13 +973,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Get pro status without history { // Build request - session_pro_backend_get_pro_status_request request = {}; + session_pro_backend_get_pro_details_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.unix_ts_ms = time(nullptr) * 1000; session_pro_backend_signature sig = - session_pro_backend_get_pro_status_request_build_sig( + session_pro_backend_get_pro_details_request_build_sig( request.version, master_privkey.data, sizeof(master_privkey.data), @@ -986,22 +990,22 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Do CURL request session_pro_backend_to_json request_json = - session_pro_backend_get_pro_status_request_to_json(&request); + session_pro_backend_get_pro_details_request_to_json(&request); scope_exit request_json_free{ [&]() { session_pro_backend_to_json_free(&request_json); }}; std::string response_json = curl_do_basic_blocking_post_request( curl, curl_headers, - g_test_pro_backend_dev_server_url + "/get_pro_status", + g_test_pro_backend_dev_server_url + "/get_pro_details", std::string_view(request_json.json.data, request_json.json.size)); // Parse response - session_pro_backend_get_pro_status_response response = - session_pro_backend_get_pro_status_response_parse( + session_pro_backend_get_pro_details_response response = + session_pro_backend_get_pro_details_response_parse( response_json.data(), response_json.size()); scope_exit response_free{ - [&]() { session_pro_backend_get_pro_status_response_free(&response); }}; + [&]() { session_pro_backend_get_pro_details_response_free(&response); }}; for (size_t index = 0; index < response.header.errors_count; index++) { if (index == 0) @@ -1075,11 +1079,11 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { std::string_view(request_json.json.data, request_json.json.size)); // Parse response - session_pro_backend_add_pro_payment_or_get_pro_proof_response response = - session_pro_backend_add_pro_payment_or_get_pro_proof_response_parse( + session_pro_backend_add_pro_payment_or_generate_pro_proof_response response = + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( response_json.data(), response_json.size()); scope_exit response_free{[&]() { - session_pro_backend_add_pro_payment_or_get_pro_proof_response_free(&response); + session_pro_backend_add_pro_payment_or_generate_pro_proof_response_free(&response); }}; // Verify response From 456cb16d1d9ae3a53ab2316576461a451bba447e Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 17 Nov 2025 14:53:15 +1100 Subject: [PATCH 148/171] Added syncing for Session Pro profile values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added the ProConfig back • Stored the ProConfig in the extra_data of UserProfile so it isn't synced • Added syncing of the pro features bitset to UserProfile and Contacts configs • Added syncing of the pro genIndexHash and expiryUnixTs to the ConvoInfoVolatile config --- include/session/config/contacts.h | 5 + include/session/config/contacts.hpp | 56 +++++++ include/session/config/convo_info_volatile.h | 11 ++ .../session/config/convo_info_volatile.hpp | 18 ++ include/session/config/pro.h | 22 +++ include/session/config/pro.hpp | 38 +++++ include/session/config/user_profile.h | 96 +++++++++++ include/session/config/user_profile.hpp | 70 ++++++++ include/session/session_protocol.hpp | 6 + src/CMakeLists.txt | 1 + src/config/contacts.cpp | 57 +++++++ src/config/convo_info_volatile.cpp | 99 ++++++++++- src/config/pro.cpp | 74 +++++++++ src/config/user_profile.cpp | 155 +++++++++++++++++ tests/CMakeLists.txt | 1 + tests/test_config_contacts.cpp | 35 ++++ tests/test_config_convo_info_volatile.cpp | 76 +++++++++ tests/test_config_pro.cpp | 157 ++++++++++++++++++ tests/test_config_userprofile.cpp | 79 +++++++++ 19 files changed, 1051 insertions(+), 5 deletions(-) create mode 100644 include/session/config/pro.h create mode 100644 include/session/config/pro.hpp create mode 100644 src/config/pro.cpp create mode 100644 tests/test_config_pro.cpp diff --git a/include/session/config/contacts.h b/include/session/config/contacts.h index 80df2699..f5318a79 100644 --- a/include/session/config/contacts.h +++ b/include/session/config/contacts.h @@ -7,6 +7,7 @@ extern "C" { #include "base.h" #include "expiring.h" #include "notify.h" +#include "pro.h" #include "profile_pic.h" #include "util.h" @@ -35,6 +36,8 @@ typedef struct contacts_contact { int64_t created; // unix timestamp (seconds) + SESSION_PROTOCOL_PRO_FEATURES pro_features; + } contacts_contact; typedef struct contacts_blinded_contact { @@ -52,6 +55,8 @@ typedef struct contacts_blinded_contact { bool legacy_blinding; int64_t created; // unix timestamp (seconds) + SESSION_PROTOCOL_PRO_FEATURES pro_features; + } contacts_blinded_contact; /// Struct containing a list of contacts_blinded_contact structs. Typically where this is returned diff --git a/include/session/config/contacts.hpp b/include/session/config/contacts.hpp index 586488db..4742fee9 100644 --- a/include/session/config/contacts.hpp +++ b/include/session/config/contacts.hpp @@ -11,6 +11,7 @@ #include "expiring.hpp" #include "namespaces.hpp" #include "notify.hpp" +#include "pro.hpp" #include "profile_pic.hpp" extern "C" struct contacts_contact; @@ -47,6 +48,7 @@ namespace session::config { /// j - Unix timestamp (seconds) when the contact was created ("j" to match user_groups /// equivalent "j"oined field). Omitted if 0. /// t - The `profile_updated` unix timestamp (seconds) for this contacts profile information. +/// f - session pro features bitset for this contact /// /// b - dict of blinded contacts. This is a nested dict where the outer keys are the BASE_URL of /// the community the blinded contact originated from and the outer value is a dict containing: @@ -68,6 +70,7 @@ namespace session::config { /// j - Unix timestamp (seconds) when the contact was created ("j" to match user_groups /// equivalent "j"oined field). Omitted if 0. /// y - flag indicating whether the blinded message request is using legac"y" blinding. +/// f - session pro features bitset for this blinded contact struct contact_info { static constexpr size_t MAX_NAME_LENGTH = 100; @@ -93,6 +96,8 @@ struct contact_info { std::chrono::seconds exp_timer{0}; // The expiration timer (in seconds) int64_t created = 0; // Unix timestamp (seconds) when this contact was added + SESSION_PROTOCOL_PRO_FEATURES pro_features = SESSION_PROTOCOL_PRO_FEATURES_NIL; + explicit contact_info(std::string sid); // Internal ctor/method for C API implementations: @@ -117,6 +122,25 @@ struct contact_info { void set_nickname(std::string nickname); void set_nickname_truncated(std::string nickname); + /// API: contacts/contact_info::get_pro_features + /// + /// Retrieves the bitset indicating which pro features the user currently has enabled. + /// + /// Inputs: None + /// + /// Outputs: + /// - `SESSION_PROTOCOL_PRO_FEATURES` - bitset indicating which pro features are enabled. + SESSION_PROTOCOL_PRO_FEATURES get_pro_features() const; + + /// API: contacts/contact_info::set_pro_features + /// + /// Updates the pro features bitset for this contact. Note: If the bitset provided contains the + /// '10K_CHARACTER_LIMIT' feature then it will be removed. + /// + /// Inputs: + /// - `features` -- The updated pro features bitset to use. + void set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features); + private: friend class Contacts; void load(const dict& info_dict); @@ -136,6 +160,8 @@ struct blinded_contact_info { bool legacy_blinding; std::chrono::sys_seconds created{}; // Unix timestamp (seconds) when this contact was added + SESSION_PROTOCOL_PRO_FEATURES pro_features = SESSION_PROTOCOL_PRO_FEATURES_NIL; + blinded_contact_info() = default; explicit blinded_contact_info( std::string_view community_base_url, @@ -193,6 +219,25 @@ struct blinded_contact_info { /// - `std::string` -- Returns the pubkey std::string community_pubkey_hex() const { return comm.pubkey_hex(); } + /// API: contacts/blinded_contact_info::get_pro_features + /// + /// Retrieves the bitset indicating which pro features the user currently has enabled. + /// + /// Inputs: None + /// + /// Outputs: + /// - `SESSION_PROTOCOL_PRO_FEATURES` - bitset indicating which pro features are enabled. + SESSION_PROTOCOL_PRO_FEATURES get_pro_features() const; + + /// API: contacts/blinded_contact_info::set_pro_features + /// + /// Updates the pro features bitset for this contact. Note: If the bitset provided contains the + /// '10K_CHARACTER_LIMIT' feature then it will be removed. + /// + /// Inputs: + /// - `features` -- The updated pro features bitset to use. + void set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features); + private: friend class Contacts; friend struct session::config::comm_iterator_helper; @@ -428,6 +473,17 @@ class Contacts : public ConfigBase { /// - `timestamp` -- standard unix timestamp of the time contact was created void set_created(std::string_view session_id, int64_t timestamp); + /// API: contacts/contacts::set_pro_features + /// + /// Alternative to `set()` for setting a single field. (If setting multiple fields at once you + /// should use `set()` instead). + /// + /// Inputs: + /// - `session_id` -- hex string of the session id + /// - `features` -- The updated pro features bitset to use. Note: If the bitset provided + /// contains the '10K_CHARACTER_LIMIT' feature then it will be removed. + void set_pro_features(std::string_view session_id, SESSION_PROTOCOL_PRO_FEATURES features); + /// API: contacts/contacts::erase /// /// Removes a contact, if present. Returns true if it was found and removed, false otherwise. diff --git a/include/session/config/convo_info_volatile.h b/include/session/config/convo_info_volatile.h index c33bc55b..8d8d667d 100644 --- a/include/session/config/convo_info_volatile.h +++ b/include/session/config/convo_info_volatile.h @@ -6,12 +6,18 @@ extern "C" { #include "base.h" #include "profile_pic.h" +#include "session/types.h" typedef struct convo_info_volatile_1to1 { char session_id[67]; // in hex; 66 hex chars + null terminator. int64_t last_read; // milliseconds since unix epoch bool unread; // true if the conversation is explicitly marked unread + + bool has_pro_gen_index_hash; // Flag indicating if hash is set + bytes32 pro_gen_index_hash; // Hash of the generation index set by the Session Pro Backend + uint64_t pro_expiry_unix_ts_ms; // Unix epoch timestamp to which this contacts entitlement to + // Session Pro features is valid to } convo_info_volatile_1to1; typedef struct convo_info_volatile_community { @@ -44,6 +50,11 @@ typedef struct convo_info_volatile_blinded_1to1 { int64_t last_read; // ms since unix epoch bool unread; // true if the conversation is explicitly marked unread + + bool has_pro_gen_index_hash; // Flag indicating if hash is set + bytes32 pro_gen_index_hash; // Hash of the generation index set by the Session Pro Backend + uint64_t pro_expiry_unix_ts_ms; // Unix epoch timestamp to which this contacts entitlement to + // Session Pro features is valid to } convo_info_volatile_blinded_1to1; /// API: convo_info_volatile/convo_info_volatile_init diff --git a/include/session/config/convo_info_volatile.hpp b/include/session/config/convo_info_volatile.hpp index 3b0f75ee..19c42b85 100644 --- a/include/session/config/convo_info_volatile.hpp +++ b/include/session/config/convo_info_volatile.hpp @@ -31,6 +31,8 @@ class val_loader; /// /// 1 - dict of one-to-one conversations. Each key is the Session ID of the contact (in hex). /// Values are dicts with keys: +/// e - contacts pro expiry unix timestamp (in milliseconds) +/// g - contacts pro gen_index_hash /// 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. @@ -59,6 +61,8 @@ class val_loader; /// /// b - outgoing blinded message request conversations. The key is the blinded Session ID without /// the prefix. Values are dicts with keys: +/// e - contacts pro expiry unix timestamp (in milliseconds) +/// g - contacts pro gen_index_hash /// r - the unix timestamp (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. @@ -79,6 +83,13 @@ namespace convo { struct one_to_one : base { std::string session_id; // in hex + /// Hash of the generation index set by the Session Pro Backend + std::optional pro_gen_index_hash; + + /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid + /// to + std::chrono::sys_time pro_expiry_unix_ts{}; + /// API: convo_info_volatile/one_to_one::one_to_one /// /// Constructs an empty one_to_one from a session_id. Session ID can be either bytes (33) @@ -161,6 +172,13 @@ namespace convo { std::string blinded_session_id; // in hex bool legacy_blinding; + /// Hash of the generation index set by the Session Pro Backend + std::optional pro_gen_index_hash; + + /// Unix epoch timestamp to which this proof's entitlement to Session Pro features is valid + /// to + std::chrono::sys_time pro_expiry_unix_ts{}; + /// API: convo_info_volatile/blinded_one_to_one::blinded_one_to_one /// /// Constructs an empty blinded_one_to_one from a blinded_session_id. Session ID can be diff --git a/include/session/config/pro.h b/include/session/config/pro.h new file mode 100644 index 00000000..05420f57 --- /dev/null +++ b/include/session/config/pro.h @@ -0,0 +1,22 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include "../export.h" +#include "session/session_protocol.h" + +typedef struct pro_pro_config pro_pro_config; +struct pro_pro_config { + bytes64 rotating_privkey; + session_protocol_pro_proof proof; +}; + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp new file mode 100644 index 00000000..204a4d07 --- /dev/null +++ b/include/session/config/pro.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +namespace session::config { + +/// keys used currently or in the past (so that we don't reuse): +/// +/// s + session pro data +/// | +/// +-- p + proof +/// | | +/// | +-- @ - version +/// | +-- e - expiry unix timestamp (in milliseconds) +/// | +-- g - gen_index_hash +/// | +-- r - rotating ed25519 privkey +/// | +-- s - proof signature, signed by the Session Pro Backend's ed25519 key +/// | +/// +-- r - rotating ed25519 pubkey +class ProConfig { + public: + /// Private key for the public key key specified in the proof. This is synced between clients + /// to allow multiple clients to synchronise the Session Pro Proof and also the keys necessary + /// to use the proof. + cleared_uc64 rotating_privkey; + + /// A cryptographic proof for entitling an Ed25519 key to Session Pro + ProProof proof; + + bool load(bt_dict_consumer& root); + + bool operator==(const ProConfig& other) const { + return rotating_privkey == other.rotating_privkey && proof == other.proof; + } +}; +}; // namespace session::config diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index 94d3531c..781ba146 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -5,6 +5,7 @@ extern "C" { #endif #include "base.h" +#include "pro.h" #include "profile_pic.h" /// API: user_profile/user_profile_init @@ -279,6 +280,101 @@ LIBSESSION_EXPORT void user_profile_set_blinded_msgreqs(config_object* conf, int /// information. Will be `0` if it's never been updated. LIBSESSION_EXPORT int64_t user_profile_get_profile_updated(config_object* conf); +/// API: user_profile/user_profile_get_pro_config +/// +/// Get the Pro data for the user profile if it exists which includes the users rotating private key +/// and their last authorised proof. +/// +/// Declaration: +/// ```cpp +/// BOOL user_profile_get_pro_config( +/// [in] const config_object* conf +/// [out] pro_pro* pro +/// ); +/// ``` +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `pro` -- [out] Pointer to the pro object where the retrieved details are written +/// +/// Outputs: +/// - `bool` -- True if the user profile had Pro data associated with it. Otherwise false and the +/// pro structure will remain untouched. +LIBSESSION_EXPORT bool user_profile_get_pro_config(const config_object* conf, pro_pro_config* pro); + +/// API: user_profile/user_profile_set_pro_config +/// +/// Update the pro data associated with the user profile. +/// +/// Declaration: +/// ```cpp +/// VOID user_profile_set_pro_config( +/// [in] config_object* conf, +/// [in] pro_pro* pro +/// ); +/// ``` +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `pro` -- [in] Pointer to the Pro data to write to the user profile +/// +/// Outputs: +/// - `void` -- Returns nothing +LIBSESSION_EXPORT void user_profile_set_pro_config(config_object* conf, const pro_pro_config* pro); + +/// API: user_profile/user_profile_remove_pro_config +/// +/// Remove the Session Pro components from the user profile. +/// +/// Declaration: +/// ```cpp +/// BOOL user_profile_remove_pro_config( +/// [in] config_object* conf +/// ); +/// ``` +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// +/// Outputs: +/// - `bool` - A flag indicating whether the config had Session Pro components which were removed. +bool user_profile_remove_pro_config(config_object* conf); + +/// API: user_profile/user_profile_get_pro_features +/// +/// Retrieves the bitset indicating which pro features the user currently has enabled. +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// +/// Outputs: +/// - `SESSION_PROTOCOL_PRO_FEATURES` - bitset indicating which pro features are enabled. +LIBSESSION_EXPORT SESSION_PROTOCOL_PRO_FEATURES +user_profile_get_pro_features(const config_object* conf); + +/// API: user_profile/user_profile_set_pro_badge +/// +/// Updates the bitset to specify whether the user wants their profile to show the pro badge. +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `enabled` -- Flag which specifies whether the user wants the pro badge to appear on their +/// profile or not. +LIBSESSION_EXPORT void user_profile_set_pro_badge(config_object* conf, bool enabled); + +/// API: user_profile/user_profile_set_animated_avatar +/// +/// Updates the bitset to specify whether the user has an animated profile picture, should be +/// set when uploading a profile picture. Note: This doesn't prevent a users profile picture +/// from animating, it's just a way to more easily synchronise the state between devices when +/// sending messages so we don't need the device to have successfully download the current +/// display picture in order to be able to determine this. +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `enabled` -- Flag which specifies whether the users display picture is animated or not. +LIBSESSION_EXPORT void user_profile_set_animated_avatar(config_object* conf, bool enabled); + #ifdef __cplusplus } // extern "C" #endif diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index 3fa48bb1..b4f6f3e0 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -6,6 +6,7 @@ #include "base.hpp" #include "namespaces.hpp" +#include "pro.hpp" #include "profile_pic.hpp" namespace session::config { @@ -23,6 +24,7 @@ using namespace std::literals; /// M - set to 1 if blinded message request retrieval is enabled, 0 if retrieval is *disabled*, and /// omitted if the setting has not been explicitly set (or has been explicitly cleared for some /// reason). +/// f - session pro features bitset /// t - The unix timestamp (seconds) that the user last explicitly updated their profile information /// (automatically updates when changing `name`, `profile_pic` or `set_blinded_msgreqs`). /// P - user profile url after re-uploading (should take precedence over `p` when `T > t`). @@ -32,6 +34,9 @@ using namespace std::literals; /// (automatically updates when calling `set_reupload_profile_pic`). class UserProfile : public ConfigBase { + private: + std::optional pro_config; + public: friend class UserProfileTester; @@ -240,6 +245,71 @@ class UserProfile : public ConfigBase { std::chrono::sys_seconds get_profile_updated() const; bool accepts_protobuf() const override { return true; } + + /// API: user_profile/UserProfile::get_pro_config + /// + /// Get the Session Pro data if any, for the current user profile. This may be missing if the + /// user does not have any entitlement to Session Pro config. + /// + /// Inputs: None + std::optional get_pro_config() const; + + /// API: user_profile/UserProfile::set_pro_config + /// + /// Attach the Session Pro components to the user profile including the proof entitling the user + /// to use Session Pro features as well as the Ed25519 key pair known as the Rotating Session + /// Pro key authorised to use the proof. + /// + /// Inputs: + /// - `pro` -- The Session Pro components to assign to the current user profile. This will + /// overwrite any existing Session Pro config if it exists. No verification of `pro` is done. + void set_pro_config(const ProConfig& pro); + + /// API: user_profile/UserProfile::remove_pro_config + /// + /// Remove the Session Pro components from the user profile. + /// + /// Inputs: None + /// + /// Outputs: + /// - `bool` - A flag indicating whether the config had Session Pro components which were + /// removed. + bool remove_pro_config(); + + /// API: user_profile/UserProfile::get_pro_features + /// + /// Retrieves the bitset indicating which pro features the user currently has enabled. + /// + /// Inputs: None + /// + /// Outputs: + /// - `SESSION_PROTOCOL_PRO_FEATURES` - bitset indicating which pro features are enabled. + SESSION_PROTOCOL_PRO_FEATURES get_pro_features() const; + + /// API: user_profile/UserProfile::set_pro_badge + /// + /// Updates the bitset to specify whether the user wants their profile to show the pro badge. + /// + /// Inputs: + /// - `enabled` -- Flag which specifies whether the user wants the pro badge to appear on their + /// profile or not. + void set_pro_badge(bool enabled); + + /// API: user_profile/UserProfile::set_animated_avatar + /// + /// Updates the bitset to specify whether the user has an animated profile picture, should be + /// set when uploading a profile picture. Note: This doesn't prevent a users profile picture + /// from animating, it's just a way to more easily synchronise the state between devices when + /// sending messages so we don't need the device to have successfully download the current + /// display picture in order to be able to determine this. + /// + /// Inputs: + /// - `enabled` -- Flag which specifies whether the users display picture is animated or not. + void set_animated_avatar(bool enabled); + + protected: + void extra_data(oxenc::bt_dict_producer&& extra) const override; + void load_extra_data(oxenc::bt_dict_consumer&& extra) override; }; } // namespace session::config diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 883993a0..5dc468a9 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -166,6 +166,12 @@ class ProProof { /// /// Create a 32-byte hash from the proof. This hash is the payload that is signed in the proof. array_uc32 hash() const; + + bool operator==(const ProProof& other) const { + return version == other.version && gen_index_hash == other.gen_index_hash && + rotating_pubkey == other.rotating_pubkey && expiry_unix_ts == other.expiry_unix_ts && + sig == other.sig; + } }; enum class ProFeaturesForMsgStatus { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16563923..af9bd4bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,6 +73,7 @@ add_libsession_util_library(config config/internal.cpp config/local.cpp config/protos.cpp + config/pro.cpp config/user_groups.cpp config/user_profile.cpp fields.cpp diff --git a/src/config/contacts.cpp b/src/config/contacts.cpp index bf1e6a6b..d59c761c 100644 --- a/src/config/contacts.cpp +++ b/src/config/contacts.cpp @@ -58,6 +58,13 @@ void contact_info::set_nickname_truncated(std::string n) { set_nickname(utf8_truncate(std::move(n), MAX_NAME_LENGTH)); } +void contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + pro_features = features; +} + Contacts::Contacts( std::span ed25519_secretkey, std::optional> dumped) : @@ -115,6 +122,7 @@ void contact_info::load(const dict& info_dict) { } created = to_epoch_seconds(int_or_0(info_dict, "j")); + pro_features = int_or_0(info_dict, "f"); } void contact_info::into(contacts_contact& c) const { @@ -139,6 +147,7 @@ void contact_info::into(contacts_contact& c) const { if (c.exp_seconds <= 0 && c.exp_mode != CONVO_EXPIRATION_NONE) c.exp_mode = CONVO_EXPIRATION_NONE; c.created = to_epoch_seconds(created); + c.pro_features = pro_features; } contact_info::contact_info(const contacts_contact& c) : session_id{c.session_id, 66} { @@ -163,6 +172,13 @@ contact_info::contact_info(const contacts_contact& c) : session_id{c.session_id, if (exp_timer <= 0s && exp_mode != expiration_mode::none) exp_mode = expiration_mode::none; created = to_epoch_seconds(c.created); + + // Strip features which aren't profile related + auto features = c.pro_features; + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + pro_features = features; } std::optional Contacts::get(std::string_view pubkey_hex) const { @@ -222,6 +238,13 @@ void Contacts::set(const contact_info& contact) { contact.exp_timer.count()); set_positive_int(info["j"], to_epoch_seconds(contact.created)); + + // Strip features which aren't profile related + auto features = contact.pro_features; + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + set_positive_int(info["f"], features); } void Contacts::set_name(std::string_view session_id, std::string name) { @@ -292,6 +315,17 @@ void Contacts::set_created(std::string_view session_id, int64_t timestamp) { set(c); } +void Contacts::set_pro_features( + std::string_view session_id, SESSION_PROTOCOL_PRO_FEATURES features) { + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) { + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + } + + auto c = get_or_construct(session_id); + c.pro_features = features; + set(c); +} + bool Contacts::erase(std::string_view session_id) { std::string pk = session_id_to_bytes(session_id); auto info = data["c"][pk]; @@ -336,6 +370,7 @@ void blinded_contact_info::load(const dict& info_dict) { priority = int_or_0(info_dict, "+"); legacy_blinding = int_or_0(info_dict, "y"); created = ts_or_epoch(info_dict, "j"); + pro_features = int_or_0(info_dict, "f"); } void blinded_contact_info::into(contacts_blinded_contact& c) const { @@ -356,6 +391,7 @@ void blinded_contact_info::into(contacts_blinded_contact& c) const { c.priority = priority; c.legacy_blinding = legacy_blinding; c.created = created.time_since_epoch().count(); + c.pro_features = pro_features; } blinded_contact_info::blinded_contact_info(const contacts_blinded_contact& c) { @@ -371,6 +407,13 @@ blinded_contact_info::blinded_contact_info(const contacts_blinded_contact& c) { priority = c.priority; legacy_blinding = c.legacy_blinding; created = to_sys_seconds(c.created); + + // Strip features which aren't profile related + auto features = c.pro_features; + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + pro_features = features; } const std::string blinded_contact_info::session_id() const { @@ -404,6 +447,13 @@ void blinded_contact_info::set_pubkey(std::string_view pubkey) { comm.set_pubkey(pubkey); } +void blinded_contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + pro_features = features; +} + ConfigBase::DictFieldProxy Contacts::blinded_contact_field( const blinded_contact_info& bc, std::span* get_pubkey) const { auto record = data["b"][bc.comm.base_url()]; @@ -484,6 +534,13 @@ void Contacts::set_blinded(const blinded_contact_info& bc) { set_nonzero_int(info["+"], bc.priority); set_positive_int(info["y"], bc.legacy_blinding); set_ts(info["j"], bc.created); + + // Strip features which aren't profile related + auto features = bc.pro_features; + if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) + features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + + set_positive_int(info["f"], features); } bool Contacts::erase_blinded(std::string_view base_url_, std::string_view blinded_id) { diff --git a/src/config/convo_info_volatile.cpp b/src/config/convo_info_volatile.cpp index a48e7dd7..334e4d7d 100644 --- a/src/config/convo_info_volatile.cpp +++ b/src/config/convo_info_volatile.cpp @@ -16,7 +16,6 @@ #include "session/export.h" #include "session/types.hpp" #include "session/util.hpp" - using namespace std::literals; namespace session::config { @@ -30,12 +29,33 @@ namespace convo { check_session_id(session_id); } one_to_one::one_to_one(const convo_info_volatile_1to1& c) : - base{c.last_read, c.unread}, session_id{c.session_id, 66} {} + base{c.last_read, c.unread}, session_id{c.session_id, 66} { + if (c.has_pro_gen_index_hash) { + pro_gen_index_hash.emplace(); + std::memcpy( + pro_gen_index_hash->data(), + c.pro_gen_index_hash.data, + pro_gen_index_hash->size()); + } + pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(c.pro_expiry_unix_ts_ms)); + } void one_to_one::into(convo_info_volatile_1to1& c) const { std::memcpy(c.session_id, session_id.data(), 67); c.last_read = last_read; c.unread = unread; + + if (pro_gen_index_hash) { + c.has_pro_gen_index_hash = true; + std::memcpy( + c.pro_gen_index_hash.data, + pro_gen_index_hash->data(), + pro_gen_index_hash->size()); + } else { + c.has_pro_gen_index_hash = false; + } + c.pro_expiry_unix_ts_ms = pro_expiry_unix_ts.time_since_epoch().count(); } community::community(const convo_info_volatile_community& c) : @@ -103,13 +123,34 @@ namespace convo { blinded_one_to_one::blinded_one_to_one(const convo_info_volatile_blinded_1to1& c) : base{c.last_read, c.unread}, blinded_session_id{c.blinded_session_id, 66}, - legacy_blinding{c.legacy_blinding} {} + legacy_blinding{c.legacy_blinding} { + if (c.has_pro_gen_index_hash) { + pro_gen_index_hash.emplace(); + std::memcpy( + pro_gen_index_hash->data(), + c.pro_gen_index_hash.data, + pro_gen_index_hash->size()); + } + pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(c.pro_expiry_unix_ts_ms)); + } void blinded_one_to_one::into(convo_info_volatile_blinded_1to1& c) const { std::memcpy(c.blinded_session_id, blinded_session_id.data(), 67); c.last_read = last_read; c.unread = unread; c.legacy_blinding = legacy_blinding; + + if (pro_gen_index_hash) { + c.has_pro_gen_index_hash = true; + std::memcpy( + c.pro_gen_index_hash.data, + pro_gen_index_hash->data(), + pro_gen_index_hash->size()); + } else { + c.has_pro_gen_index_hash = false; + } + c.pro_expiry_unix_ts_ms = pro_expiry_unix_ts.time_since_epoch().count(); } void base::load(const dict& info_dict) { @@ -135,9 +176,24 @@ std::optional ConvoInfoVolatile::get_1to1(std::string_view pu auto result = std::make_optional(std::string{pubkey_hex}); result->load(*info_dict); + + result->pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(int_or_0(*info_dict, "e"))); + + std::optional> maybe_pro_gen_index_hash = + maybe_vector(*info_dict, "g"); + if (maybe_pro_gen_index_hash && maybe_pro_gen_index_hash->size() == 32) { + result->pro_gen_index_hash.emplace(); + std::memcpy( + result->pro_gen_index_hash->data(), + maybe_pro_gen_index_hash->data(), + result->pro_gen_index_hash->size()); + } + return result; } - +// TODO: The 'has_gen_index_hash' value is incorrectly returning true (is the above 'maybe_vector' +// resolving incorrectly?) convo::one_to_one ConvoInfoVolatile::get_or_construct_1to1(std::string_view pubkey_hex) const { if (auto maybe = get_1to1(pubkey_hex)) return *std::move(maybe); @@ -260,6 +316,20 @@ std::optional ConvoInfoVolatile::get_blinded_1to1( auto result = std::make_optional(std::string{pubkey_hex}); result->load(*info_dict); + + result->pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(int_or_0(*info_dict, "e"))); + + std::optional> maybe_pro_gen_index_hash = + maybe_vector(*info_dict, "g"); + if (maybe_pro_gen_index_hash && maybe_pro_gen_index_hash->size() == 32) { + result->pro_gen_index_hash.emplace(); + std::memcpy( + result->pro_gen_index_hash->data(), + maybe_pro_gen_index_hash->data(), + result->pro_gen_index_hash->size()); + } + return result; } @@ -274,6 +344,15 @@ convo::blinded_one_to_one ConvoInfoVolatile::get_or_construct_blinded_1to1( void ConvoInfoVolatile::set(const convo::one_to_one& c) { auto info = data["1"][session_id_to_bytes(c.session_id)]; set_base(c, info); + + // If the base values weren't stored it means the data was too old so the record shouldn't be + // added + if (auto* d = info.dict(); !d || d->empty()) + return; + + set_nonzero_int(info["e"], c.pro_expiry_unix_ts.time_since_epoch().count()); + if (c.pro_gen_index_hash) + info["g"] = *c.pro_gen_index_hash; } void ConvoInfoVolatile::set_base(const convo::base& c, DictFieldProxy& info) { @@ -348,8 +427,18 @@ void ConvoInfoVolatile::set(const convo::blinded_one_to_one& c) { std::string pubkey = session_id_to_bytes(c.blinded_session_id, c.legacy_blinding ? "15" : "25"); auto info = data["b"][pubkey]; - set_nonzero_int(info["y"], c.legacy_blinding); set_base(c, info); + + // If the base values weren't stored it means the data was too old so the record shouldn't be + // added + if (auto* d = info.dict(); !d || d->empty()) + return; + + set_nonzero_int(info["y"], c.legacy_blinding); + + set_nonzero_int(info["e"], c.pro_expiry_unix_ts.time_since_epoch().count()); + if (c.pro_gen_index_hash) + info["g"] = *c.pro_gen_index_hash; } template diff --git a/src/config/pro.cpp b/src/config/pro.cpp new file mode 100644 index 00000000..3efdadf4 --- /dev/null +++ b/src/config/pro.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include + +#include +#include + +#include "internal.hpp" + +namespace session::config { + +bool ProConfig::load(bt_dict_consumer& root) { + // Get proof fields from session pro data sitting in the 'p' (proof) dictionary + if (!root.skip_until("p")) + return false; + + // Lookup and get 'p' + auto pd = root.consume_dict_consumer(); + + if (!root.skip_until("r")) + return false; + + auto rotating_privkey_ = root.consume_string_view(); + + if (rotating_privkey_.size() != rotating_privkey.max_size()) + return false; + + // NOTE: Load into the proof object + { + if (!pd.skip_until("@")) + return false; + + proof.version = pd.consume_integer(); + + if (!pd.skip_until("e")) + return false; + + proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(pd.consume_integer())); + + if (!pd.skip_until("g")) + return false; + + auto gen_index_hash = to_vector(pd.consume_string_view()); + if (gen_index_hash.size() != proof.gen_index_hash.size()) + return false; + + if (!pd.skip_until("r")) + return false; + + auto rotating_pubkey = to_vector(pd.consume_string_view()); + if (rotating_pubkey.size() != proof.rotating_pubkey.max_size()) + return false; + + if (!pd.skip_until("s")) + return false; + + auto sig = to_vector(pd.consume_string_view()); + if (sig.size() != proof.sig.max_size()) + return false; + + std::memcpy( + proof.gen_index_hash.data(), gen_index_hash.data(), proof.gen_index_hash.size()); + std::memcpy( + proof.rotating_pubkey.data(), rotating_pubkey.data(), proof.rotating_pubkey.size()); + std::memcpy(proof.sig.data(), sig.data(), proof.sig.size()); + } + + std::memcpy(rotating_privkey.data(), rotating_privkey_.data(), rotating_privkey.size()); + return true; +} + +}; // namespace session::config diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 8153e02f..ee9dae5c 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -5,8 +5,11 @@ #include "internal.hpp" #include "session/config/contacts.hpp" #include "session/config/error.h" +#include "session/config/pro.h" +#include "session/config/pro.hpp" #include "session/config/user_profile.hpp" #include "session/export.h" +#include "session/types.hpp" using namespace session::config; @@ -17,6 +20,33 @@ UserProfile::UserProfile( load_key(ed25519_secretkey); } +void UserProfile::extra_data(oxenc::bt_dict_producer&& extra) const { + if (pro_config) { + auto root = extra.append_dict("pro_config"); + + const ProProof& pro_proof = pro_config->proof; + { + auto proof_dict = root.append_dict("p"); + proof_dict.append("@", pro_proof.version); + proof_dict.append("e", pro_proof.expiry_unix_ts.time_since_epoch().count()); + proof_dict.append("g", pro_proof.gen_index_hash); + proof_dict.append("r", pro_proof.rotating_pubkey); + proof_dict.append("s", pro_proof.sig); + } + + root.append("r", pro_config->rotating_privkey); + } +} + +void UserProfile::load_extra_data(oxenc::bt_dict_consumer&& extra) { + if (extra.skip_until("pro_config")) { + auto pd = extra.consume_dict_consumer(); + ProConfig pro = {}; + if (pro.load(pd)) + pro_config = std::move(pro); + } +} + std::optional UserProfile::get_name() const { if (auto* s = data["n"].string(); s && !s->empty()) return *s; @@ -146,6 +176,75 @@ std::chrono::sys_seconds UserProfile::get_profile_updated() const { return std::chrono::sys_seconds{}; } +std::optional UserProfile::get_pro_config() const { + return pro_config; +} + +void UserProfile::set_pro_config(ProConfig const& pro) { + if (pro_config != pro) { + pro_config = pro; + _needs_dump = true; + } +} + +bool UserProfile::remove_pro_config() { + if (pro_config) { + pro_config = std::nullopt; + _needs_dump = true; + return true; + } + + return false; +} + +SESSION_PROTOCOL_PRO_FEATURES UserProfile::get_pro_features() const { + if (auto f = data["f"].integer()) + return static_cast(*f); + return SESSION_PROTOCOL_PRO_FEATURES_NIL; +} + +void UserProfile::set_pro_badge(bool enabled) { + SESSION_PROTOCOL_PRO_FEATURES current_value = SESSION_PROTOCOL_PRO_FEATURES_NIL; + if (auto f = data["f"].integer()) + current_value = static_cast(*f); + + auto updated_value = + (enabled ? (current_value | SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE) // Add + : (current_value & ~SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE)); // Remove + + if (current_value == updated_value) + return; + + if (updated_value == SESSION_PROTOCOL_PRO_FEATURES_NIL) + data["f"].erase(); + else + data["f"] = static_cast(updated_value); + + const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" : "T"); + data[target_timestamp] = ts_now(); +} + +void UserProfile::set_animated_avatar(bool enabled) { + SESSION_PROTOCOL_PRO_FEATURES current_value = SESSION_PROTOCOL_PRO_FEATURES_NIL; + if (auto f = data["f"].integer()) + current_value = static_cast(*f); + + auto updated_value = + (enabled ? (current_value | SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR) // Add + : (current_value & ~SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR)); // Remove + + if (current_value == updated_value) + return; + + if (updated_value == SESSION_PROTOCOL_PRO_FEATURES_NIL) + data["f"].erase(); + else + data["f"] = static_cast(updated_value); + + const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" : "T"); + data[target_timestamp] = ts_now(); +} + extern "C" { using namespace session; @@ -251,4 +350,60 @@ LIBSESSION_C_API void user_profile_set_blinded_msgreqs(config_object* conf, int LIBSESSION_C_API int64_t user_profile_get_profile_updated(config_object* conf) { return unbox(conf)->get_profile_updated().time_since_epoch().count(); } + +LIBSESSION_C_API bool user_profile_get_pro_config(const config_object* conf, pro_pro_config* pro) { + if (auto val = unbox(conf)->get_pro_config(); val) { + static_assert(sizeof pro->proof.gen_index_hash == sizeof(val->proof.gen_index_hash)); + static_assert(sizeof pro->proof.rotating_pubkey == sizeof(val->proof.rotating_pubkey)); + static_assert(sizeof pro->proof.sig == sizeof(val->proof.sig)); + pro->proof.version = val->proof.version; + std::memcpy( + pro->proof.gen_index_hash.data, + val->proof.gen_index_hash.data(), + val->proof.gen_index_hash.size()); + std::memcpy( + pro->proof.rotating_pubkey.data, + val->proof.rotating_pubkey.data(), + val->proof.rotating_pubkey.size()); + pro->proof.expiry_unix_ts_ms = val->proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro->proof.sig.data, val->proof.sig.data(), val->proof.sig.size()); + return true; + } + return false; +} + +LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro_pro_config* pro) { + ProConfig val = {}; + val.proof.version = pro->proof.version; + std::memcpy( + val.proof.gen_index_hash.data(), + pro->proof.gen_index_hash.data, + val.proof.gen_index_hash.size()); + std::memcpy( + val.proof.rotating_pubkey.data(), + pro->proof.rotating_pubkey.data, + val.proof.rotating_pubkey.size()); + val.proof.expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(pro->proof.expiry_unix_ts_ms)); + std::memcpy(val.proof.sig.data(), pro->proof.sig.data, val.proof.sig.size()); + unbox(conf)->set_pro_config(val); +} + +LIBSESSION_C_API bool user_profile_remove_pro_config(config_object* conf) { + return unbox(conf)->remove_pro_config(); +} + +LIBSESSION_EXPORT SESSION_PROTOCOL_PRO_FEATURES +user_profile_get_pro_features(const config_object* conf) { + return unbox(conf)->get_pro_features(); +} + +LIBSESSION_EXPORT void user_profile_set_pro_badge(config_object* conf, bool enabled) { + unbox(conf)->set_pro_badge(enabled); +} + +LIBSESSION_EXPORT void user_profile_set_animated_avatar(config_object* conf, bool enabled) { + unbox(conf)->set_animated_avatar(enabled); +} + } // extern "C" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 09e93084..16983201 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,6 +16,7 @@ set(LIB_SESSION_UTESTS_SOURCES test_config_contacts.cpp test_config_convo_info_volatile.cpp test_config_local.cpp + test_config_pro.cpp test_curve25519.cpp test_ed25519.cpp test_encrypt.cpp diff --git a/tests/test_config_contacts.cpp b/tests/test_config_contacts.cpp index d5a0a1f8..7e1b8fa7 100644 --- a/tests/test_config_contacts.cpp +++ b/tests/test_config_contacts.cpp @@ -1116,3 +1116,38 @@ TEST_CASE("Contacts", "[config][blinded_contacts]") { CHECK_THROWS(contacts.get_or_construct_blinded(comm_base_url, comm_pubkey_hex, invalid_id_1)); CHECK_THROWS(contacts.get_or_construct_blinded(comm_base_url, comm_pubkey_hex, invalid_id_2)); } + +TEST_CASE("Contacts Pro Storage", "[config][contacts][pro]") { + + const auto seed = "0123456789abcdef0123456789abcdef00000000000000000000000000000000"_hexbytes; + + session::config::Contacts contacts{std::span{seed}, std::nullopt}; + + auto c = contacts.get_or_construct( + "050000000000000000000000000000000000000000000000000000000000000000"sv); + CHECK(c.pro_features == SESSION_PROTOCOL_PRO_FEATURES_NIL); + + c.pro_features = SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE; + contacts.set(c); + + c = contacts.get_or_construct( + "050000000000000000000000000000000000000000000000000000000000000000"sv); + CHECK(c.pro_features == SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); + + // Check that it strips the `10K_CHARACTER_LIMIT` feature when setting + c.pro_features = c.pro_features |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; + CHECK(c.pro_features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); + + contacts.set(c); + c = contacts.get_or_construct( + "050000000000000000000000000000000000000000000000000000000000000000"sv); + CHECK_FALSE(c.pro_features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); + + c.pro_features = c.pro_features |= SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR; + contacts.set(c); + c = contacts.get_or_construct( + "050000000000000000000000000000000000000000000000000000000000000000"sv); + + CHECK(c.pro_features & SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); + CHECK(c.pro_features & SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); +} \ No newline at end of file diff --git a/tests/test_config_convo_info_volatile.cpp b/tests/test_config_convo_info_volatile.cpp index 31e88dc6..93f4f7af 100644 --- a/tests/test_config_convo_info_volatile.cpp +++ b/tests/test_config_convo_info_volatile.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -619,6 +620,14 @@ TEST_CASE("Conversation pruning", "[config][conversations][pruning]") { c.last_read = unix_timestamp(i); if (i % 5 == 0) c.unread = true; + + c.pro_expiry_unix_ts = + std::chrono::time_point_cast(now + 24h); + + session::array_uc32 hash{}; + std::fill(hash.begin(), hash.end(), static_cast(i % 256)); + c.pro_gen_index_hash = hash; + convos.set(c); } else if (i % 3 == 1) { auto c = convos.get_or_construct_legacy_group(some_session_id(i)); @@ -784,3 +793,70 @@ TEST_CASE("Conversation dump/load state bug", "[config][conversations][dump-load free(dump); CHECK_FALSE(config_needs_dump(conf2)); } + +TEST_CASE("Conversation pro data", "[config][conversations][pro]") { + + const auto seed = "0123456789abcdef0123456789abcdef00000000000000000000000000000000"_hexbytes; + std::array ed_pk, curve_pk; + std::array ed_sk; + crypto_sign_ed25519_seed_keypair( + ed_pk.data(), ed_sk.data(), reinterpret_cast(seed.data())); + int rc = crypto_sign_ed25519_pk_to_curve25519(curve_pk.data(), ed_pk.data()); + REQUIRE(rc == 0); + + REQUIRE(oxenc::to_hex(ed_pk.begin(), ed_pk.end()) == + "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"); + REQUIRE(oxenc::to_hex(curve_pk.begin(), curve_pk.end()) == + "d2ad010eeb72d72e561d9de7bd7b6989af77dcabffa03a5111a6c859ae5c3a72"); + CHECK(oxenc::to_hex(seed.begin(), seed.end()) == + oxenc::to_hex(ed_sk.begin(), ed_sk.begin() + 32)); + + config_object* conf; + REQUIRE(0 == convo_info_volatile_init(&conf, ed_sk.data(), NULL, 0, NULL)); + + convo_info_volatile_1to1 c; + CHECK(convo_info_volatile_get_or_construct_1to1( + conf, &c, "051111111111111111111111111111111111111111111111111111111111111111")); + c.last_read = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + c.pro_expiry_unix_ts_ms = 10000; + + session::array_uc32 hash{}; + std::fill(hash.begin(), hash.end(), static_cast(3)); + std::memcpy(c.pro_gen_index_hash.data, hash.data(), hash.size()); + c.has_pro_gen_index_hash = true; + convo_info_volatile_set_1to1(conf, &c); + + // Fake push: + config_push_data* to_push = config_push(conf); + seqno_t seqno = to_push->seqno; + REQUIRE(to_push->n_configs == 1); + free(to_push); + CHECK(seqno == 1); + + const char* tmphash; // test suite cheat: &(tmphash = "asdf") to fake a length-1 array. + + config_confirm_pushed(conf, seqno, &(tmphash = "somehash"), 1); + CHECK(config_needs_dump(conf)); + + // Dump: + unsigned char* dump; + size_t dumplen; + config_dump(conf, &dump, &dumplen); + + // Load the dump: + config_object* conf2; + REQUIRE(0 == convo_info_volatile_init(&conf2, ed_sk.data(), dump, dumplen, NULL)); + + free(dump); + + convo_info_volatile_1to1 c2; + CHECK(convo_info_volatile_get_or_construct_1to1( + conf2, &c2, "051111111111111111111111111111111111111111111111111111111111111111")); + + CHECK(c2.pro_expiry_unix_ts_ms == c.pro_expiry_unix_ts_ms); + CHECK(c.has_pro_gen_index_hash); + CHECK(c2.has_pro_gen_index_hash); + CHECK(oxenc::to_hex(c2.pro_gen_index_hash.data) == oxenc::to_hex(c.pro_gen_index_hash.data)); +} \ No newline at end of file diff --git a/tests/test_config_pro.cpp b/tests/test_config_pro.cpp new file mode 100644 index 00000000..d8913c17 --- /dev/null +++ b/tests/test_config_pro.cpp @@ -0,0 +1,157 @@ +#include +#include +#include +#include + +#include +#include +#include +using namespace oxenc::literals; + +TEST_CASE("Pro", "[config][pro]") { + // Setup keys + std::array rotating_pk, signing_pk; + session::cleared_uc64 rotating_sk, signing_sk; + { + crypto_sign_ed25519_keypair(rotating_pk.data(), rotating_sk.data()); + crypto_sign_ed25519_keypair(signing_pk.data(), signing_sk.data()); + } + + // Setup the Pro data structure + session::config::ProConfig pro_cpp = {}; + pro_pro_config pro = {}; + { + // CPP + pro_cpp.rotating_privkey = rotating_sk; + pro_cpp.proof.version = 2; + pro_cpp.proof.rotating_pubkey = rotating_pk; + pro_cpp.proof.expiry_unix_ts = std::chrono::sys_time(1s); + constexpr auto gen_index_hash = + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hex_u; + static_assert(pro_cpp.proof.gen_index_hash.max_size() == gen_index_hash.size()); + std::memcpy( + pro_cpp.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); + + // C + std::memcpy(pro.rotating_privkey.data, rotating_sk.data(), rotating_sk.size()); + pro.proof.version = pro_cpp.proof.version; + std::memcpy(pro.proof.rotating_pubkey.data, rotating_pk.data(), rotating_pk.size()); + pro.proof.expiry_unix_ts_ms = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro.proof.gen_index_hash.data, gen_index_hash.data(), gen_index_hash.size()); + } + + // Generate and write the hashes that are signed by the faux pro backend into the proof + { + // Generate the hashes + static_assert(crypto_sign_ed25519_BYTES == pro_cpp.proof.sig.max_size()); + std::array hash_to_sign_cpp = pro_cpp.proof.hash(); + bytes32 hash_to_sign = session_protocol_pro_proof_hash(&pro.proof); + + static_assert(hash_to_sign_cpp.size() == sizeof(hash_to_sign)); + CHECK(std::memcmp(hash_to_sign_cpp.data(), hash_to_sign.data, hash_to_sign_cpp.size()) == + 0); + + // Write the signature into the proof + int sig_result = crypto_sign_ed25519_detached( + pro_cpp.proof.sig.data(), + nullptr, + hash_to_sign_cpp.data(), + hash_to_sign_cpp.size(), + signing_sk.data()); + CHECK(sig_result == 0); + + sig_result = crypto_sign_ed25519_detached( + pro.proof.sig.data, + nullptr, + hash_to_sign.data, + sizeof(hash_to_sign.data), + signing_sk.data()); + CHECK(sig_result == 0); + } + + // Verify expiry + { + CHECK(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts)); + CHECK_FALSE(pro_cpp.proof.is_active(pro_cpp.proof.expiry_unix_ts + 1ms)); + + CHECK(session_protocol_pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms)); + CHECK_FALSE( + session_protocol_pro_proof_is_active(&pro.proof, pro.proof.expiry_unix_ts_ms + 1)); + } + + // Verify it can verify messages signed with the rotating public key + { + std::string_view body = "hello world"; + std::array sig = {}; + int sign_result = crypto_sign_ed25519_detached( + sig.data(), + nullptr, + reinterpret_cast(body.data()), + body.size(), + rotating_sk.data()); + CHECK(sign_result == 0); + CHECK(pro_cpp.proof.verify_message(sig, session::to_span(body))); + CHECK(session_protocol_pro_proof_verify_message( + &pro.proof, + sig.data(), + sig.size(), + reinterpret_cast(body.data()), + body.size())); + } + + // Try loading the proof from dict + { + oxenc::bt_dict_producer good_dict; + + // clang-format off + const session::ProProof& proof = pro_cpp.proof; + { + auto p = good_dict.append_dict("p"); + /*version*/ p.append("@", proof.version); + /*expiry unix ts*/ p.append("e", proof.expiry_unix_ts.time_since_epoch().count()); + /*gen_index_hash*/ p.append("g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())); + /*rotating pubkey*/ p.append("r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())); + /*signature*/ p.append("s", std::string{reinterpret_cast(proof.sig.data()), proof.sig.size()}); + } + + good_dict.append("r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())); + // clang-format on + + session::config::ProConfig loaded_pro = {}; + auto good_dict_consumer = oxenc::bt_dict_consumer{good_dict.view()}; + CHECK(loaded_pro.load(good_dict_consumer)); + CHECK(loaded_pro.rotating_privkey == pro_cpp.rotating_privkey); + CHECK(loaded_pro.proof.version == pro_cpp.proof.version); + CHECK(loaded_pro.proof.gen_index_hash == pro_cpp.proof.gen_index_hash); + CHECK(loaded_pro.proof.rotating_pubkey == pro_cpp.proof.rotating_pubkey); + CHECK(loaded_pro.proof.expiry_unix_ts == pro_cpp.proof.expiry_unix_ts); + CHECK(loaded_pro.proof.sig == pro_cpp.proof.sig); + CHECK(loaded_pro.proof.verify_signature(signing_pk)); + } + + // Try loading a proof with a bad signature in it from dict + { + oxenc::bt_dict_producer bad_dict; + std::array broken_sig = pro_cpp.proof.sig; + broken_sig[0] = ~broken_sig[0]; // Break the sig + + // clang-format off + const session::ProProof& proof = pro_cpp.proof; + { + auto p = bad_dict.append_dict("p"); + /*version*/ p.append("@", proof.version); + /*expiry unix ts*/ p.append("e", proof.expiry_unix_ts.time_since_epoch().count()); + /*gen_index_hash*/ p.append("g", std::string(reinterpret_cast(proof.gen_index_hash.data()), proof.gen_index_hash.size())); + /*rotating pubkey*/ p.append("r", std::string(reinterpret_cast(proof.rotating_pubkey.data()), proof.rotating_pubkey.size())); + /*signature*/ p.append("s", std::string{reinterpret_cast(broken_sig.data()), broken_sig.size()}); + } + + bad_dict.append("r", std::string(reinterpret_cast(rotating_sk.data()), rotating_sk.size())); + // clang-format on + + session::config::ProConfig loaded_pro = {}; + auto bad_dict_consumer = oxenc::bt_dict_consumer{bad_dict.view()}; + CHECK(loaded_pro.load(bad_dict_consumer)); + CHECK_FALSE(loaded_pro.proof.verify_signature(signing_pk)); + } +} diff --git a/tests/test_config_userprofile.cpp b/tests/test_config_userprofile.cpp index 7f0a37b5..cb0e8566 100644 --- a/tests/test_config_userprofile.cpp +++ b/tests/test_config_userprofile.cpp @@ -555,4 +555,83 @@ TEST_CASE("user profile timestamp update bug", "[config][user_profile]") { // Also make sure it does change profile.set_name("Nibbler1"); CHECK(profile.get_profile_updated() != seconds_before_call); +} + +TEST_CASE("UserProfile Pro Storage", "[config][user_profile][pro]") { + + const auto seed = "0123456789abcdef0123456789abcdef00000000000000000000000000000000"_hexbytes; + + session::config::UserProfile profile{std::span{seed}, std::nullopt}; + + // Ensure the bitset is being updated correctly + CHECK(profile.get_pro_features() == SESSION_PROTOCOL_PRO_FEATURES_NIL); + + profile.set_pro_badge(true); + CHECK(profile.get_pro_features() == SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); + + profile.set_pro_badge(false); + CHECK(profile.get_pro_features() == SESSION_PROTOCOL_PRO_FEATURES_NIL); + + profile.set_animated_avatar(true); + CHECK(profile.get_pro_features() == SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); + + profile.set_animated_avatar(false); + CHECK(profile.get_pro_features() == SESSION_PROTOCOL_PRO_FEATURES_NIL); + + profile.set_pro_badge(true); + profile.set_animated_avatar(true); + CHECK(profile.get_pro_features() & SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); + CHECK(profile.get_pro_features() & SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); + + profile.set_animated_avatar(false); + CHECK(profile.get_pro_features() & SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); + CHECK_FALSE(profile.get_pro_features() & SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); + + { + session::config::UserProfile profile2{std::span{seed}, profile.dump()}; + CHECK(profile2.get_pro_features() & SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE); + CHECK_FALSE(profile2.get_pro_features() & SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR); + } + + // Ensure the pro config is being stored correctly + std::array rotating_pk, signing_pk; + session::cleared_uc64 rotating_sk, signing_sk; + { + crypto_sign_ed25519_keypair(rotating_pk.data(), rotating_sk.data()); + crypto_sign_ed25519_keypair(signing_pk.data(), signing_sk.data()); + } + + session::config::ProConfig pro_cpp = {}; + pro_pro_config pro = {}; + { + // CPP + pro_cpp.rotating_privkey = rotating_sk; + pro_cpp.proof.version = 2; + pro_cpp.proof.rotating_pubkey = rotating_pk; + pro_cpp.proof.expiry_unix_ts = std::chrono::sys_time(1s); + constexpr auto gen_index_hash = + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"_hex_u; + static_assert(pro_cpp.proof.gen_index_hash.max_size() == gen_index_hash.size()); + std::memcpy( + pro_cpp.proof.gen_index_hash.data(), gen_index_hash.data(), gen_index_hash.size()); + + // C + std::memcpy(pro.rotating_privkey.data, rotating_sk.data(), rotating_sk.size()); + pro.proof.version = pro_cpp.proof.version; + std::memcpy(pro.proof.rotating_pubkey.data, rotating_pk.data(), rotating_pk.size()); + pro.proof.expiry_unix_ts_ms = pro_cpp.proof.expiry_unix_ts.time_since_epoch().count(); + std::memcpy(pro.proof.gen_index_hash.data, gen_index_hash.data(), gen_index_hash.size()); + } + + CHECK_FALSE(profile.get_pro_config().has_value()); + profile.set_pro_config(pro_cpp); + CHECK(profile.get_pro_config() == pro_cpp); + + { + session::config::UserProfile profile2{std::span{seed}, profile.dump()}; + CHECK(profile.get_pro_config() == pro_cpp); + } + + profile.remove_pro_config(); + CHECK_FALSE(profile.get_pro_config().has_value()); } \ No newline at end of file From fc42369c3b63773a0660a135490979fb0ff3aa07 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 18 Nov 2025 13:07:15 +1100 Subject: [PATCH 149/171] Comment tweak --- include/session/config/pro.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/session/config/pro.hpp b/include/session/config/pro.hpp index 204a4d07..fd8b9fac 100644 --- a/include/session/config/pro.hpp +++ b/include/session/config/pro.hpp @@ -21,9 +21,7 @@ namespace session::config { /// +-- r - rotating ed25519 pubkey class ProConfig { public: - /// Private key for the public key key specified in the proof. This is synced between clients - /// to allow multiple clients to synchronise the Session Pro Proof and also the keys necessary - /// to use the proof. + /// Private key for the public key key specified in the proof. cleared_uc64 rotating_privkey; /// A cryptographic proof for entitling an Ed25519 key to Session Pro From a8ba4d7763e407a9fa9344d28beb3df33a923d76 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 18 Nov 2025 14:31:03 +1100 Subject: [PATCH 150/171] Updated some url variable names --- include/session/pro_backend.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 2290f50f..6ab3bce7 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -110,15 +110,15 @@ struct session_pro_backend_payment_provider_metadata { string8 store; string8 platform; string8 platform_account; - string8 refund_url; + string8 refund_platform_url; /// Some platforms disallow a refund via their native support channels after some time period /// (e.g. 48 hours after a purchase on Google, refunds must be dealt by the developers /// themselves). If a platform does not have this restriction, this URL is typically the same as - /// the `refund_url`. - string8 refund_after_platform_deadline_url; - + /// the `refund_platform_url`. string8 refund_support_url; + + string8 refund_status_url; string8 update_subscription_url; string8 cancel_subscription_url; }; @@ -132,9 +132,9 @@ const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_ .store = string8_literal(""), .platform = string8_literal(""), .platform_account = string8_literal(""), - .refund_url = string8_literal(""), - .refund_after_platform_deadline_url = string8_literal(""), + .refund_platform_url = string8_literal(""), .refund_support_url = string8_literal(""), + .refund_status_url = string8_literal(""), .update_subscription_url = string8_literal(""), .cancel_subscription_url = string8_literal(""), }, @@ -143,9 +143,9 @@ const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_ .store = string8_literal("Google Play Store"), .platform = string8_literal("Google"), .platform_account = string8_literal("Google account"), - .refund_url = string8_literal("https://support.google.com/googleplay/workflow/9813244?"), - .refund_after_platform_deadline_url = string8_literal("https://getsession.org/android-refund"), + .refund_platform_url = string8_literal("https://support.google.com/googleplay/workflow/9813244?"), .refund_support_url = string8_literal("https://getsession.org/android-refund"), + .refund_status_url = string8_literal("https://getsession.org/android-refund"), .update_subscription_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger"), .cancel_subscription_url = string8_literal("https://play.google.com/store/account/subscriptions?package=network.loki.messenger"), }, @@ -154,9 +154,9 @@ const session_pro_backend_payment_provider_metadata SESSION_PRO_BACKEND_PAYMENT_ .store = string8_literal("Apple App Store"), .platform = string8_literal("Apple"), .platform_account = string8_literal("Apple account"), - .refund_url = string8_literal("https://support.apple.com/118223"), - .refund_after_platform_deadline_url = string8_literal("https://support.apple.com/118223"), - .refund_support_url = string8_literal("https://support.apple.com/118224"), + .refund_platform_url = string8_literal("https://support.apple.com/118223"), + .refund_support_url = string8_literal("https://support.apple.com/118223"), + .refund_status_url = string8_literal("https://support.apple.com/118224"), .update_subscription_url = string8_literal("https://apps.apple.com/account/subscriptions"), .cancel_subscription_url = string8_literal("https://account.apple.com/account/manage/section/subscriptions"), } From 6d9441ccd5cdeb2456a912293d1132649e1e781f Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 18 Nov 2025 15:48:41 +1100 Subject: [PATCH 151/171] Fixed a couple of bugs with the pro config syncing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed an issue where `load_extra_data` wasn't getting called • Fixed an issue where the `rotating_privkey` wasn't being copied between C/C++ --- src/config/user_profile.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index ee9dae5c..4e271597 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -15,8 +15,8 @@ using namespace session::config; UserProfile::UserProfile( std::span ed25519_secretkey, - std::optional> dumped) : - ConfigBase{dumped} { + std::optional> dumped) { + init(dumped, std::nullopt, ed25519_secretkey); load_key(ed25519_secretkey); } @@ -367,6 +367,10 @@ LIBSESSION_C_API bool user_profile_get_pro_config(const config_object* conf, pro val->proof.rotating_pubkey.size()); pro->proof.expiry_unix_ts_ms = val->proof.expiry_unix_ts.time_since_epoch().count(); std::memcpy(pro->proof.sig.data, val->proof.sig.data(), val->proof.sig.size()); + std::memcpy( + pro->rotating_privkey.data, + val->rotating_privkey.data(), + val->rotating_privkey.size()); return true; } return false; @@ -386,6 +390,8 @@ LIBSESSION_C_API void user_profile_set_pro_config(config_object* conf, const pro val.proof.expiry_unix_ts = std::chrono::sys_time( std::chrono::milliseconds(pro->proof.expiry_unix_ts_ms)); std::memcpy(val.proof.sig.data(), pro->proof.sig.data, val.proof.sig.size()); + std::memcpy( + val.rotating_privkey.data(), pro->rotating_privkey.data, val.rotating_privkey.size()); unbox(conf)->set_pro_config(val); } From 47854939dd5cce04ccd0574d8035e05468c4334c Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 19 Nov 2025 12:35:27 +1100 Subject: [PATCH 152/171] Addressed PR comments --- src/config/contacts.cpp | 4 +-- src/config/convo_info_volatile.cpp | 50 +++++++++++++++++------------- src/config/groups/info.cpp | 5 +-- src/config/local.cpp | 4 +-- src/config/user_groups.cpp | 4 +-- 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/config/contacts.cpp b/src/config/contacts.cpp index d59c761c..f6647591 100644 --- a/src/config/contacts.cpp +++ b/src/config/contacts.cpp @@ -67,8 +67,8 @@ void contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { Contacts::Contacts( std::span ed25519_secretkey, - std::optional> dumped) : - ConfigBase{dumped} { + std::optional> dumped) { + init(dumped, std::nullopt, ed25519_secretkey); load_key(ed25519_secretkey); } diff --git a/src/config/convo_info_volatile.cpp b/src/config/convo_info_volatile.cpp index 334e4d7d..a93e6abc 100644 --- a/src/config/convo_info_volatile.cpp +++ b/src/config/convo_info_volatile.cpp @@ -36,9 +36,9 @@ namespace convo { pro_gen_index_hash->data(), c.pro_gen_index_hash.data, pro_gen_index_hash->size()); + pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(c.pro_expiry_unix_ts_ms)); } - pro_expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(c.pro_expiry_unix_ts_ms)); } void one_to_one::into(convo_info_volatile_1to1& c) const { @@ -52,10 +52,12 @@ namespace convo { c.pro_gen_index_hash.data, pro_gen_index_hash->data(), pro_gen_index_hash->size()); + + c.pro_expiry_unix_ts_ms = pro_expiry_unix_ts.time_since_epoch().count(); } else { c.has_pro_gen_index_hash = false; + c.pro_expiry_unix_ts_ms = 0; } - c.pro_expiry_unix_ts_ms = pro_expiry_unix_ts.time_since_epoch().count(); } community::community(const convo_info_volatile_community& c) : @@ -130,9 +132,9 @@ namespace convo { pro_gen_index_hash->data(), c.pro_gen_index_hash.data, pro_gen_index_hash->size()); + pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(c.pro_expiry_unix_ts_ms)); } - pro_expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(c.pro_expiry_unix_ts_ms)); } void blinded_one_to_one::into(convo_info_volatile_blinded_1to1& c) const { @@ -147,10 +149,11 @@ namespace convo { c.pro_gen_index_hash.data, pro_gen_index_hash->data(), pro_gen_index_hash->size()); + c.pro_expiry_unix_ts_ms = pro_expiry_unix_ts.time_since_epoch().count(); } else { c.has_pro_gen_index_hash = false; + c.pro_expiry_unix_ts_ms = 0; } - c.pro_expiry_unix_ts_ms = pro_expiry_unix_ts.time_since_epoch().count(); } void base::load(const dict& info_dict) { @@ -162,8 +165,8 @@ namespace convo { ConvoInfoVolatile::ConvoInfoVolatile( std::span ed25519_secretkey, - std::optional> dumped) : - ConfigBase{dumped} { + std::optional> dumped) { + init(dumped, std::nullopt, ed25519_secretkey); load_key(ed25519_secretkey); } @@ -177,12 +180,12 @@ std::optional ConvoInfoVolatile::get_1to1(std::string_view pu auto result = std::make_optional(std::string{pubkey_hex}); result->load(*info_dict); - result->pro_expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(int_or_0(*info_dict, "e"))); - + auto pro_expiry = int_or_0(*info_dict, "e"); std::optional> maybe_pro_gen_index_hash = maybe_vector(*info_dict, "g"); - if (maybe_pro_gen_index_hash && maybe_pro_gen_index_hash->size() == 32) { + if (pro_expiry > 0 && maybe_pro_gen_index_hash && maybe_pro_gen_index_hash->size() == 32) { + result->pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(pro_expiry)); result->pro_gen_index_hash.emplace(); std::memcpy( result->pro_gen_index_hash->data(), @@ -192,8 +195,7 @@ std::optional ConvoInfoVolatile::get_1to1(std::string_view pu return result; } -// TODO: The 'has_gen_index_hash' value is incorrectly returning true (is the above 'maybe_vector' -// resolving incorrectly?) + convo::one_to_one ConvoInfoVolatile::get_or_construct_1to1(std::string_view pubkey_hex) const { if (auto maybe = get_1to1(pubkey_hex)) return *std::move(maybe); @@ -317,12 +319,12 @@ std::optional ConvoInfoVolatile::get_blinded_1to1( auto result = std::make_optional(std::string{pubkey_hex}); result->load(*info_dict); - result->pro_expiry_unix_ts = std::chrono::sys_time( - std::chrono::milliseconds(int_or_0(*info_dict, "e"))); - + auto pro_expiry = int_or_0(*info_dict, "e"); std::optional> maybe_pro_gen_index_hash = maybe_vector(*info_dict, "g"); - if (maybe_pro_gen_index_hash && maybe_pro_gen_index_hash->size() == 32) { + if (pro_expiry > 0 && maybe_pro_gen_index_hash && maybe_pro_gen_index_hash->size() == 32) { + result->pro_expiry_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(pro_expiry)); result->pro_gen_index_hash.emplace(); std::memcpy( result->pro_gen_index_hash->data(), @@ -350,9 +352,11 @@ void ConvoInfoVolatile::set(const convo::one_to_one& c) { if (auto* d = info.dict(); !d || d->empty()) return; - set_nonzero_int(info["e"], c.pro_expiry_unix_ts.time_since_epoch().count()); - if (c.pro_gen_index_hash) + auto pro_expiry = c.pro_expiry_unix_ts.time_since_epoch().count(); + if (pro_expiry > 0 && c.pro_gen_index_hash) { + set_nonzero_int(info["e"], pro_expiry); info["g"] = *c.pro_gen_index_hash; + } } void ConvoInfoVolatile::set_base(const convo::base& c, DictFieldProxy& info) { @@ -436,9 +440,11 @@ void ConvoInfoVolatile::set(const convo::blinded_one_to_one& c) { set_nonzero_int(info["y"], c.legacy_blinding); - set_nonzero_int(info["e"], c.pro_expiry_unix_ts.time_since_epoch().count()); - if (c.pro_gen_index_hash) + auto pro_expiry = c.pro_expiry_unix_ts.time_since_epoch().count(); + if (pro_expiry > 0 && c.pro_gen_index_hash) { + set_nonzero_int(info["e"], pro_expiry); info["g"] = *c.pro_gen_index_hash; + } } template diff --git a/src/config/groups/info.cpp b/src/config/groups/info.cpp index 2025ca0a..fb6b6e43 100644 --- a/src/config/groups/info.cpp +++ b/src/config/groups/info.cpp @@ -20,8 +20,9 @@ Info::Info( std::span ed25519_pubkey, std::optional> ed25519_secretkey, std::optional> dumped) : - ConfigBase{dumped, ed25519_pubkey, ed25519_secretkey}, - id{"03" + oxenc::to_hex(ed25519_pubkey.begin(), ed25519_pubkey.end())} {} + id{"03" + oxenc::to_hex(ed25519_pubkey.begin(), ed25519_pubkey.end())} { + init(dumped, ed25519_pubkey, ed25519_secretkey); +} std::optional Info::get_name() const { if (auto* s = data["n"].string(); s && !s->empty()) diff --git a/src/config/local.cpp b/src/config/local.cpp index cd726c5b..e34c2421 100644 --- a/src/config/local.cpp +++ b/src/config/local.cpp @@ -12,8 +12,8 @@ using namespace session::config; Local::Local( std::span ed25519_secretkey, - std::optional> dumped) : - ConfigBase{dumped} { + std::optional> dumped) { + init(dumped, std::nullopt, ed25519_secretkey); load_key(ed25519_secretkey); } diff --git a/src/config/user_groups.cpp b/src/config/user_groups.cpp index 7c8bf724..0db68b83 100644 --- a/src/config/user_groups.cpp +++ b/src/config/user_groups.cpp @@ -281,8 +281,8 @@ void community_info::load(const dict& info_dict) { UserGroups::UserGroups( std::span ed25519_secretkey, - std::optional> dumped) : - ConfigBase{dumped} { + std::optional> dumped) { + init(dumped, std::nullopt, ed25519_secretkey); load_key(ed25519_secretkey); } From 156fb112e391ce0829580c1835a1dcce68d0e38f Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 19 Nov 2025 17:04:29 +1100 Subject: [PATCH 153/171] Additional PR feedback --- src/config/contacts.cpp | 38 +++++++------------------------------- src/config/pro.cpp | 6 +++--- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/config/contacts.cpp b/src/config/contacts.cpp index f6647591..8d82c55f 100644 --- a/src/config/contacts.cpp +++ b/src/config/contacts.cpp @@ -59,10 +59,7 @@ void contact_info::set_nickname_truncated(std::string n) { } void contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - - pro_features = features; + pro_features = (features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); } Contacts::Contacts( @@ -174,11 +171,7 @@ contact_info::contact_info(const contacts_contact& c) : session_id{c.session_id, created = to_epoch_seconds(c.created); // Strip features which aren't profile related - auto features = c.pro_features; - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - - pro_features = features; + pro_features = (c.pro_features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); } std::optional Contacts::get(std::string_view pubkey_hex) const { @@ -240,10 +233,7 @@ void Contacts::set(const contact_info& contact) { set_positive_int(info["j"], to_epoch_seconds(contact.created)); // Strip features which aren't profile related - auto features = contact.pro_features; - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - + auto features = (contact.pro_features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); set_positive_int(info["f"], features); } @@ -317,12 +307,8 @@ void Contacts::set_created(std::string_view session_id, int64_t timestamp) { void Contacts::set_pro_features( std::string_view session_id, SESSION_PROTOCOL_PRO_FEATURES features) { - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) { - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - } - auto c = get_or_construct(session_id); - c.pro_features = features; + c.pro_features = (features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); set(c); } @@ -409,11 +395,7 @@ blinded_contact_info::blinded_contact_info(const contacts_blinded_contact& c) { created = to_sys_seconds(c.created); // Strip features which aren't profile related - auto features = c.pro_features; - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - - pro_features = features; + pro_features = (c.pro_features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); } const std::string blinded_contact_info::session_id() const { @@ -448,10 +430,7 @@ void blinded_contact_info::set_pubkey(std::string_view pubkey) { } void blinded_contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - - pro_features = features; + pro_features = (features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); } ConfigBase::DictFieldProxy Contacts::blinded_contact_field( @@ -536,10 +515,7 @@ void Contacts::set_blinded(const blinded_contact_info& bc) { set_ts(info["j"], bc.created); // Strip features which aren't profile related - auto features = bc.pro_features; - if (features & SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT) - features &= ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT; - + auto features = (bc.pro_features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); set_positive_int(info["f"], features); } diff --git a/src/config/pro.cpp b/src/config/pro.cpp index 3efdadf4..f8c81195 100644 --- a/src/config/pro.cpp +++ b/src/config/pro.cpp @@ -42,21 +42,21 @@ bool ProConfig::load(bt_dict_consumer& root) { if (!pd.skip_until("g")) return false; - auto gen_index_hash = to_vector(pd.consume_string_view()); + auto gen_index_hash = pd.consume_string_view(); if (gen_index_hash.size() != proof.gen_index_hash.size()) return false; if (!pd.skip_until("r")) return false; - auto rotating_pubkey = to_vector(pd.consume_string_view()); + auto rotating_pubkey = pd.consume_string_view(); if (rotating_pubkey.size() != proof.rotating_pubkey.max_size()) return false; if (!pd.skip_until("s")) return false; - auto sig = to_vector(pd.consume_string_view()); + auto sig = pd.consume_string_view(); if (sig.size() != proof.sig.max_size()) return false; From e0357e2df5181da6cabee5851a5bafe63bca3158 Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Wed, 19 Nov 2025 17:21:31 +1100 Subject: [PATCH 154/171] Add utf16_len_for_codepoints --- include/session/util.hpp | 4 ++ src/CMakeLists.txt | 1 + src/util.cpp | 70 +++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 1 + tests/test_unicode_operations.cpp | 32 ++++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 tests/test_unicode_operations.cpp diff --git a/include/session/util.hpp b/include/session/util.hpp index 4f94a932..20ec4845 100644 --- a/include/session/util.hpp +++ b/include/session/util.hpp @@ -252,6 +252,10 @@ inline std::string utf8_truncate(std::string val, size_t n) { return val; } +/// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not +/// truncate in the middle of a surrogate pair. +size_t utf16_len_for_codepoints(std::span utf16_string, size_t codepoint_len); + // Helper function to transform a timestamp provided in seconds, milliseconds or microseconds to // seconds inline int64_t to_epoch_seconds(int64_t timestamp) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16563923..b6eb6f9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,6 +85,7 @@ target_link_libraries(util common oxen::logging libzstd::static + simdutf ) target_link_libraries(crypto diff --git a/src/util.cpp b/src/util.cpp index 30bc4dcc..bbe1aa7d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -150,4 +151,73 @@ std::optional> zstd_decompress( return decompressed; } + +inline bool is_utf16_low_surrogate(char16_t c) { + return c >= 0xDC00 && c <= 0xDFFF; +} + +inline bool is_utf16_high_surrogate(char16_t c) { + return c >= 0xD800 && c <= 0xDBFF; +} + +size_t utf16_len_for_codepoints( + const std::span utf16_string, const size_t codepoint_len) { + // If the requested codepoint length is longer than the UTF-16 string length, + // we can safely assume the entire string is needed. + if (utf16_string.size() <= codepoint_len) { + return utf16_string.size(); + } + + if (codepoint_len == 0) { + return 0; + } + + // Take a gamble that the UTF-16 string is all BMP characters (1 code unit per codepoint), + // this will be true for the cases for ASCII strings. This way we can use the faster + // simdutf implementation to count codepoints. If we gamble wrong, we fall back to the slower + // method below. + auto current_codepoint_len = simdutf::count_utf16(utf16_string.data(), utf16_string.size()); + if (current_codepoint_len <= codepoint_len) { + return utf16_string.size(); + } + + // Fallback: iterate through the UTF-16 string and count codepoints properly, + size_t counted_codepoints = 0; + bool expecting_low_surrogate = false; + for (size_t i = 0; i < utf16_string.size(); ++i) { + if (const char16_t c = utf16_string[i]; is_utf16_high_surrogate(c)) { + if (expecting_low_surrogate) { + throw std::runtime_error("Invalid UTF-16 string"); + } + + // Start of a surrogate pair. Only count the codepoint when we see the low surrogate. + expecting_low_surrogate = true; + } + else if (is_utf16_low_surrogate(c)) { + if (!expecting_low_surrogate) { + throw std::runtime_error("Invalid UTF-16 string"); + } + + counted_codepoints++; + expecting_low_surrogate = false; + } + else { + // Regular BMP character + if (expecting_low_surrogate) { + throw std::runtime_error("Invalid UTF-16 string"); + } + counted_codepoints++; + } + + if (counted_codepoints == codepoint_len) { + return i + 1; + } + } + + // Should not be here, as the case of codepoint_len > actual codepoint count should have + // been handled at the start of the function. + throw std::runtime_error("Invalid UTF-16 string"); +} + + } // namespace session diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 09e93084..8f3f8432 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,6 +31,7 @@ set(LIB_SESSION_UTESTS_SOURCES test_session_encrypt.cpp test_session_protocol.cpp test_xed25519.cpp + test_unicode_operations.cpp case_logger.cpp ) diff --git a/tests/test_unicode_operations.cpp b/tests/test_unicode_operations.cpp new file mode 100644 index 00000000..c1d2ca90 --- /dev/null +++ b/tests/test_unicode_operations.cpp @@ -0,0 +1,32 @@ +#include + +#include + +#include + +static std::vector operator""_utf16(const char* str, size_t len) { + std::vector out(simdutf::utf16_length_from_utf8(str, len)); + out.resize(simdutf::convert_utf8_to_utf16(str, len, out.data())); + return out; +} + + +TEST_CASE("utf16_len_for_codepoint_len works", "[util]") { + // Given simple ASCII string, should return length equal to codepoints requested + CHECK(session::utf16_len_for_codepoints("hello_world"_utf16, 11) == 11); + + // Given zero codepoints requested, should return zero length + CHECK(session::utf16_len_for_codepoints("hello_world"_utf16, 0) == 0); + + // Given UTF-16 has surrogate pairs, should count them as single codepoints + CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 11) == 12); + + // Given UTF-16 has more codepoints than requested, should return length up to that point + CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 6) == 7); + + // Given UTF-16 has exactly the requested number of codepoints, should return full length + CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 5) == 5); + + // Given UTF-16 has less codepoints than requested, should return full length + CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 13) == 12); +} \ No newline at end of file From a84edeee0f2f4e1cd87de299e580dd95a92cff0c Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Wed, 19 Nov 2025 17:29:16 +1100 Subject: [PATCH 155/171] Add C API --- include/session/util.h | 11 +++++++++++ src/util.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 include/session/util.h diff --git a/include/session/util.h b/include/session/util.h new file mode 100644 index 00000000..a0bfe36d --- /dev/null +++ b/include/session/util.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +/// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not +/// truncate in the middle of a surrogate pair. +size_t utf16_len_for_codepoints( + const char16_t *utf16_string, + size_t utf16_string_len, + size_t codepoint_len +); \ No newline at end of file diff --git a/src/util.cpp b/src/util.cpp index bbe1aa7d..dcfa5984 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace session { @@ -221,3 +222,14 @@ size_t utf16_len_for_codepoints( } // namespace session + +size_t utf16_len_for_codepoints( + const char16_t *utf16_string, + size_t utf16_string_len, + size_t codepoint_len +) { + return session::utf16_len_for_codepoints( + std::span{utf16_string, utf16_string_len}, + codepoint_len + ); +} \ No newline at end of file From 2d910d7dd32d70bcce8209ee88ead2f91445f3f4 Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Thu, 20 Nov 2025 09:07:24 +1100 Subject: [PATCH 156/171] Update C header --- include/session/util.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/session/util.h b/include/session/util.h index a0bfe36d..3ec56d29 100644 --- a/include/session/util.h +++ b/include/session/util.h @@ -1,11 +1,20 @@ #pragma once +#include "export.h" #include +#ifdef __cplusplus +extern "C" { +#endif + /// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not /// truncate in the middle of a surrogate pair. -size_t utf16_len_for_codepoints( +LIBSESSION_EXPORT size_t utf16_len_for_codepoints( const char16_t *utf16_string, size_t utf16_string_len, size_t codepoint_len -); \ No newline at end of file +); + +#ifdef __cplusplus +} +#endif From 8a3da7b38bcaf21159694a03144290254a4ff851 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Thu, 20 Nov 2025 10:09:39 +1100 Subject: [PATCH 157/171] Fixed failing tests --- src/config/contacts.cpp | 2 +- src/config/convo_info_volatile.cpp | 2 +- src/config/local.cpp | 2 +- src/config/user_groups.cpp | 2 +- src/config/user_profile.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config/contacts.cpp b/src/config/contacts.cpp index 8d82c55f..c862a846 100644 --- a/src/config/contacts.cpp +++ b/src/config/contacts.cpp @@ -65,7 +65,7 @@ void contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { Contacts::Contacts( std::span ed25519_secretkey, std::optional> dumped) { - init(dumped, std::nullopt, ed25519_secretkey); + init(dumped, std::nullopt, std::nullopt); load_key(ed25519_secretkey); } diff --git a/src/config/convo_info_volatile.cpp b/src/config/convo_info_volatile.cpp index a93e6abc..274004c6 100644 --- a/src/config/convo_info_volatile.cpp +++ b/src/config/convo_info_volatile.cpp @@ -166,7 +166,7 @@ namespace convo { ConvoInfoVolatile::ConvoInfoVolatile( std::span ed25519_secretkey, std::optional> dumped) { - init(dumped, std::nullopt, ed25519_secretkey); + init(dumped, std::nullopt, std::nullopt); load_key(ed25519_secretkey); } diff --git a/src/config/local.cpp b/src/config/local.cpp index e34c2421..3b6575d3 100644 --- a/src/config/local.cpp +++ b/src/config/local.cpp @@ -13,7 +13,7 @@ using namespace session::config; Local::Local( std::span ed25519_secretkey, std::optional> dumped) { - init(dumped, std::nullopt, ed25519_secretkey); + init(dumped, std::nullopt, std::nullopt); load_key(ed25519_secretkey); } diff --git a/src/config/user_groups.cpp b/src/config/user_groups.cpp index 0db68b83..a87638d7 100644 --- a/src/config/user_groups.cpp +++ b/src/config/user_groups.cpp @@ -282,7 +282,7 @@ void community_info::load(const dict& info_dict) { UserGroups::UserGroups( std::span ed25519_secretkey, std::optional> dumped) { - init(dumped, std::nullopt, ed25519_secretkey); + init(dumped, std::nullopt, std::nullopt); load_key(ed25519_secretkey); } diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 4e271597..3706979b 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -16,7 +16,7 @@ using namespace session::config; UserProfile::UserProfile( std::span ed25519_secretkey, std::optional> dumped) { - init(dumped, std::nullopt, ed25519_secretkey); + init(dumped, std::nullopt, std::nullopt); load_key(ed25519_secretkey); } From 4c3e879336de92cbbdf1cd32329050666375ea0d Mon Sep 17 00:00:00 2001 From: doylet Date: Thu, 20 Nov 2025 11:08:52 +1100 Subject: [PATCH 158/171] Fix pro backend tests which now require DEV. prefix on faux payments for tests --- tests/test_pro_backend.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 00c4d7df..5bec0027 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -110,13 +110,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { crypto_sign_ed25519_keypair(rotating_pubkey.data, rotating_privkey.data); { - char fake_google_payment_token[16]; + char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); - std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token); + std::string fake_google_payment_token_hex = "DEV." + oxenc::to_hex(fake_google_payment_token); - char fake_google_order_id[16]; + char fake_google_order_id[8]; randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); - std::string fake_google_order_id_hex = oxenc::to_hex(fake_google_order_id); + std::string fake_google_order_id_hex = "DEV." + oxenc::to_hex(fake_google_order_id); session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; @@ -775,13 +775,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Add pro payment session_protocol_pro_proof first_pro_proof = {}; { - char fake_google_payment_token[16]; + char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); - std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token); + std::string fake_google_payment_token_hex = "DEV." + oxenc::to_hex(fake_google_payment_token); - char fake_google_order_id[16]; + char fake_google_order_id[8]; randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); - std::string fake_google_order_id_hex = oxenc::to_hex(fake_google_order_id); + std::string fake_google_order_id_hex = "DEV." + oxenc::to_hex(fake_google_order_id); session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; @@ -1023,13 +1023,13 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { // Add _another_ payment, same details { - char fake_google_payment_token[16]; + char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); - std::string fake_google_payment_token_hex = oxenc::to_hex(fake_google_payment_token); + std::string fake_google_payment_token_hex = "DEV." + oxenc::to_hex(fake_google_payment_token); - char fake_google_order_id[16]; + char fake_google_order_id[8]; randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); - std::string fake_google_order_id_hex = oxenc::to_hex(fake_google_order_id); + std::string fake_google_order_id_hex = "DEV." + oxenc::to_hex(fake_google_order_id); session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; From a1f2909dd53b34944331e622dd8d2219406ab5d4 Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Thu, 20 Nov 2025 12:19:55 +1100 Subject: [PATCH 159/171] Address PR feedback --- include/session/util.h | 3 ++- include/session/util.hpp | 3 ++- src/CMakeLists.txt | 1 - src/util.cpp | 36 +++++++++++++++++++----------------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/session/util.h b/include/session/util.h index 3ec56d29..6ef94576 100644 --- a/include/session/util.h +++ b/include/session/util.h @@ -8,7 +8,8 @@ extern "C" { #endif /// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not -/// truncate in the middle of a surrogate pair. +/// truncate in the middle of a surrogate pair. Notes that if the input string contains invalid +/// UTF-16 sequences (e.g. unpaired surrogates) the behavior here is undefined. LIBSESSION_EXPORT size_t utf16_len_for_codepoints( const char16_t *utf16_string, size_t utf16_string_len, diff --git a/include/session/util.hpp b/include/session/util.hpp index 20ec4845..cd53d330 100644 --- a/include/session/util.hpp +++ b/include/session/util.hpp @@ -253,7 +253,8 @@ inline std::string utf8_truncate(std::string val, size_t n) { } /// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not -/// truncate in the middle of a surrogate pair. +/// truncate in the middle of a surrogate pair. Notes that if the input string contains invalid +/// UTF-16 sequences (e.g. unpaired surrogates) the behavior here is undefined. size_t utf16_len_for_codepoints(std::span utf16_string, size_t codepoint_len); // Helper function to transform a timestamp provided in seconds, milliseconds or microseconds to diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fee67eda..4354c189 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,7 +96,6 @@ target_link_libraries(crypto libsodium::sodium-internal nlohmann_json::nlohmann_json libsession::protos - simdutf ) target_link_libraries(config diff --git a/src/util.cpp b/src/util.cpp index dcfa5984..a1b04d0d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace session { std::vector split(std::string_view str, const std::string_view delim, bool trim) { @@ -173,40 +175,39 @@ size_t utf16_len_for_codepoints( return 0; } - // Take a gamble that the UTF-16 string is all BMP characters (1 code unit per codepoint), - // this will be true for the cases for ASCII strings. This way we can use the faster - // simdutf implementation to count codepoints. If we gamble wrong, we fall back to the slower - // method below. + // Call simdutf to count the codepoint for the entirety of the UTF-16 string. + // This is an optimistic optimisation: if we don't need to do the truncation, we can leverage + // simdutf's optimized counting. + // However if the truncation is needed, we will fall back to a slower version that + // iterates through the UTF-16 string properly handling surrogate pairs. + // + // Hence the overall cost to pay for the optimization: + // * Truncation not needed: fast simdutf counting. + // * Truncation needed: fast simdutf counting + slower iteration. auto current_codepoint_len = simdutf::count_utf16(utf16_string.data(), utf16_string.size()); if (current_codepoint_len <= codepoint_len) { return utf16_string.size(); } - // Fallback: iterate through the UTF-16 string and count codepoints properly, + // Fallback: iterate through the UTF-16 string and count codepoints properly size_t counted_codepoints = 0; bool expecting_low_surrogate = false; for (size_t i = 0; i < utf16_string.size(); ++i) { if (const char16_t c = utf16_string[i]; is_utf16_high_surrogate(c)) { - if (expecting_low_surrogate) { - throw std::runtime_error("Invalid UTF-16 string"); - } + assert(!expecting_low_surrogate); // Start of a surrogate pair. Only count the codepoint when we see the low surrogate. expecting_low_surrogate = true; } else if (is_utf16_low_surrogate(c)) { - if (!expecting_low_surrogate) { - throw std::runtime_error("Invalid UTF-16 string"); - } + assert(expecting_low_surrogate); counted_codepoints++; expecting_low_surrogate = false; } else { // Regular BMP character - if (expecting_low_surrogate) { - throw std::runtime_error("Invalid UTF-16 string"); - } + assert(!expecting_low_surrogate); counted_codepoints++; } @@ -216,14 +217,15 @@ size_t utf16_len_for_codepoints( } // Should not be here, as the case of codepoint_len > actual codepoint count should have - // been handled at the start of the function. - throw std::runtime_error("Invalid UTF-16 string"); + // been handled at the start of the function. As this indicates an invalid UTF-16 string, + // we will treat it as UB and return the whole string length. + return utf16_string.size(); } } // namespace session -size_t utf16_len_for_codepoints( +LIBSESSION_EXPORT size_t utf16_len_for_codepoints( const char16_t *utf16_string, size_t utf16_string_len, size_t codepoint_len From 7d70e55a6c81c85810d593481149d34f9e372d45 Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Thu, 20 Nov 2025 15:22:34 +1100 Subject: [PATCH 160/171] PR feedback --- include/session/util.h | 7 ++++++- include/session/util.hpp | 5 ++++- src/util.cpp | 26 +++++++++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/session/util.h b/include/session/util.h index 6ef94576..d2081c5b 100644 --- a/include/session/util.h +++ b/include/session/util.h @@ -10,12 +10,17 @@ extern "C" { /// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not /// truncate in the middle of a surrogate pair. Notes that if the input string contains invalid /// UTF-16 sequences (e.g. unpaired surrogates) the behavior here is undefined. -LIBSESSION_EXPORT size_t utf16_len_for_codepoints( +LIBSESSION_EXPORT size_t utf16_count_truncated_to_codepoints( const char16_t *utf16_string, size_t utf16_string_len, size_t codepoint_len ); +LIBSESSION_EXPORT size_t utf16_count( + const char16_t *utf16_string, + size_t utf16_string_len +); + #ifdef __cplusplus } #endif diff --git a/include/session/util.hpp b/include/session/util.hpp index cd53d330..68cfa578 100644 --- a/include/session/util.hpp +++ b/include/session/util.hpp @@ -255,7 +255,10 @@ inline std::string utf8_truncate(std::string val, size_t n) { /// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not /// truncate in the middle of a surrogate pair. Notes that if the input string contains invalid /// UTF-16 sequences (e.g. unpaired surrogates) the behavior here is undefined. -size_t utf16_len_for_codepoints(std::span utf16_string, size_t codepoint_len); +size_t utf16_count_truncated_to_codepoints(std::span utf16_string, size_t codepoint_len); + +/// Returns the number of unicode codepoints in a utf-16 encoded string. +size_t utf16_count(std::span utf16_string); // Helper function to transform a timestamp provided in seconds, milliseconds or microseconds to // seconds diff --git a/src/util.cpp b/src/util.cpp index a1b04d0d..7ecb7c8a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -163,8 +163,8 @@ inline bool is_utf16_high_surrogate(char16_t c) { return c >= 0xD800 && c <= 0xDBFF; } -size_t utf16_len_for_codepoints( - const std::span utf16_string, const size_t codepoint_len) { +size_t utf16_count_truncated_to_codepoints( + std::span utf16_string, size_t codepoint_len) { // If the requested codepoint length is longer than the UTF-16 string length, // we can safely assume the entire string is needed. if (utf16_string.size() <= codepoint_len) { @@ -216,22 +216,34 @@ size_t utf16_len_for_codepoints( } } - // Should not be here, as the case of codepoint_len > actual codepoint count should have + // Should not be here, as the case of codepoint_len >= actual codepoint count should have // been handled at the start of the function. As this indicates an invalid UTF-16 string, // we will treat it as UB and return the whole string length. return utf16_string.size(); } +size_t utf16_count(std::span utf16_string) { + return simdutf::count_utf16(utf16_string.data(), utf16_string.size()); +} } // namespace session -LIBSESSION_EXPORT size_t utf16_len_for_codepoints( +LIBSESSION_C_API size_t utf16_count_truncated_to_codepoints( const char16_t *utf16_string, size_t utf16_string_len, size_t codepoint_len ) { - return session::utf16_len_for_codepoints( - std::span{utf16_string, utf16_string_len}, - codepoint_len + return session::utf16_count_truncated_to_codepoints( + std::span{utf16_string, utf16_string_len}, + codepoint_len + ); +} + +LIBSESSION_C_API size_t utf16_count( + const char16_t *utf16_string, + size_t utf16_string_len +) { + return session::utf16_count( + std::span{utf16_string, utf16_string_len} ); } \ No newline at end of file From e552632967f8c338d1c386dce217733445684533 Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Thu, 20 Nov 2025 15:43:03 +1100 Subject: [PATCH 161/171] Add comments and test --- include/session/util.h | 1 + tests/test_unicode_operations.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/session/util.h b/include/session/util.h index d2081c5b..973bb1a9 100644 --- a/include/session/util.h +++ b/include/session/util.h @@ -16,6 +16,7 @@ LIBSESSION_EXPORT size_t utf16_count_truncated_to_codepoints( size_t codepoint_len ); +/// Returns the number of unicode codepoints in a utf-16 encoded string. LIBSESSION_EXPORT size_t utf16_count( const char16_t *utf16_string, size_t utf16_string_len diff --git a/tests/test_unicode_operations.cpp b/tests/test_unicode_operations.cpp index c1d2ca90..c0026970 100644 --- a/tests/test_unicode_operations.cpp +++ b/tests/test_unicode_operations.cpp @@ -11,22 +11,29 @@ static std::vector operator""_utf16(const char* str, size_t len) { } -TEST_CASE("utf16_len_for_codepoint_len works", "[util]") { +TEST_CASE("utf16_count_truncated_to_codepoints works", "[util]") { // Given simple ASCII string, should return length equal to codepoints requested - CHECK(session::utf16_len_for_codepoints("hello_world"_utf16, 11) == 11); + CHECK(session::utf16_count_truncated_to_codepoints("hello_world"_utf16, 11) == 11); // Given zero codepoints requested, should return zero length - CHECK(session::utf16_len_for_codepoints("hello_world"_utf16, 0) == 0); + CHECK(session::utf16_count_truncated_to_codepoints("hello_world"_utf16, 0) == 0); // Given UTF-16 has surrogate pairs, should count them as single codepoints - CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 11) == 12); + CHECK(session::utf16_count_truncated_to_codepoints("hello🎂world"_utf16, 11) == 12); // Given UTF-16 has more codepoints than requested, should return length up to that point - CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 6) == 7); + CHECK(session::utf16_count_truncated_to_codepoints("hello🎂world"_utf16, 6) == 7); // Given UTF-16 has exactly the requested number of codepoints, should return full length - CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 5) == 5); + CHECK(session::utf16_count_truncated_to_codepoints("hello🎂world"_utf16, 5) == 5); // Given UTF-16 has less codepoints than requested, should return full length - CHECK(session::utf16_len_for_codepoints("hello🎂world"_utf16, 13) == 12); + CHECK(session::utf16_count_truncated_to_codepoints("hello🎂world"_utf16, 13) == 12); +} + +TEST_CASE("utf16_count works", "[util]") { + CHECK(session::utf16_count("hello_world"_utf16) == 11); + CHECK(session::utf16_count("hello🎂world"_utf16) == 11); + CHECK(session::utf16_count("🎂🎉🎈🎁"_utf16) == 4); + CHECK(session::utf16_count(""_utf16) == 0); } \ No newline at end of file From 09d2a372979aa7ff24791d558d17cfe87df95f0b Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Thu, 20 Nov 2025 16:13:12 +1100 Subject: [PATCH 162/171] Added syncing for a 'pro_access_expiry_ts' value --- include/session/config/user_profile.h | 24 +++++++++++++++++ include/session/config/user_profile.hpp | 28 +++++++++++++++++-- src/config/user_profile.cpp | 36 ++++++++++++++++++++++--- tests/test_config_userprofile.cpp | 4 +++ tests/test_pro_backend.cpp | 9 ++++--- 5 files changed, 93 insertions(+), 8 deletions(-) diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index 781ba146..78cc7997 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -375,6 +375,30 @@ LIBSESSION_EXPORT void user_profile_set_pro_badge(config_object* conf, bool enab /// - `enabled` -- Flag which specifies whether the users display picture is animated or not. LIBSESSION_EXPORT void user_profile_set_animated_avatar(config_object* conf, bool enabled); +/// API: user_profile/user_profile_get_pro_access_expiry_ms +/// +/// Retrieves the Session Pro access expiry unix timestamp if it has been set, this should generally +/// be the expiry value returned from /get_pro_details. +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// +/// Outputs: +/// - `uint64_t` - The unix timestamp in milliseconds that the users pro access will expire, or 0 if +/// unset. +LIBSESSION_EXPORT uint64_t user_profile_get_pro_access_expiry_ms(const config_object* conf); + +/// API: user_profile/user_profile_set_pro_access_expiry_ms +/// +/// Updates the Session Pro access expiry unix timestamp. +/// +/// Inputs: +/// - `conf` -- [in] Pointer to the config object +/// - `access_expiry_ts_ms` -- The timestamp that the users Session Pro access will expire, or 0 to +/// remove the value. +LIBSESSION_EXPORT void user_profile_set_pro_access_expiry_ms( + config_object* conf, uint64_t access_expiry_ts_ms); + #ifdef __cplusplus } // extern "C" #endif diff --git a/include/session/config/user_profile.hpp b/include/session/config/user_profile.hpp index b4f6f3e0..11946a3e 100644 --- a/include/session/config/user_profile.hpp +++ b/include/session/config/user_profile.hpp @@ -27,8 +27,10 @@ using namespace std::literals; /// f - session pro features bitset /// t - The unix timestamp (seconds) that the user last explicitly updated their profile information /// (automatically updates when changing `name`, `profile_pic` or `set_blinded_msgreqs`). -/// P - user profile url after re-uploading (should take precedence over `p` when `T > t`). -/// Q - user profile decryption key (binary) after re-uploading (should take precedence over `q` +/// E - user pro access expiry unix timestamp (in milliseconds). Note: This can be different from +/// the pro proof expiry which can be sooner. P - user profile url after re-uploading (should take +/// precedence over `p` when `T > t`). Q - user profile decryption key (binary) after re-uploading +/// (should take precedence over `q` /// when `T > t`). /// T - The unix timestamp (seconds) that the user last re-uploaded their profile information /// (automatically updates when calling `set_reupload_profile_pic`). @@ -307,6 +309,28 @@ class UserProfile : public ConfigBase { /// - `enabled` -- Flag which specifies whether the users display picture is animated or not. void set_animated_avatar(bool enabled); + /// API: user_profile/UserProfile::get_pro_access_expiry + /// + /// Retrieves the Session Pro access expiry unix timestamp if it has been set, this should + /// generally be the expiry value returned from /get_pro_details. + /// + /// Inputs: None + /// + /// Outputs: + /// - `std::optional>` - The unix timestamp in + /// milliseconds that the users pro access will expire, or nullopt if unset. + std::optional> get_pro_access_expiry() const; + + /// API: user_profile/UserProfile::set_pro_access_expiry + /// + /// Updates the Session Pro access expiry unix timestamp. + /// + /// Inputs: + /// - `access_expiry_ts_ms` -- The timestamp that the users Session Pro access will expire, or + /// nullopt to remove the value. + void set_pro_access_expiry( + std::optional> access_expiry_ts_ms); + protected: void extra_data(oxenc::bt_dict_producer&& extra) const override; void load_extra_data(oxenc::bt_dict_consumer&& extra) override; diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 3706979b..1166e212 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -245,6 +245,21 @@ void UserProfile::set_animated_avatar(bool enabled) { data[target_timestamp] = ts_now(); } +std::optional> UserProfile::get_pro_access_expiry() + const { + if (auto* E = data["E"].integer(); E) + return std::chrono::sys_time{std::chrono::milliseconds{*E}}; + return std::nullopt; +} + +void UserProfile::set_pro_access_expiry( + std::optional> access_expiry_ts_ms) { + if (access_expiry_ts_ms) + data["E"] = static_cast(access_expiry_ts_ms->time_since_epoch().count()); + else + data["E"].erase(); +} + extern "C" { using namespace session; @@ -399,17 +414,32 @@ LIBSESSION_C_API bool user_profile_remove_pro_config(config_object* conf) { return unbox(conf)->remove_pro_config(); } -LIBSESSION_EXPORT SESSION_PROTOCOL_PRO_FEATURES +LIBSESSION_C_API SESSION_PROTOCOL_PRO_FEATURES user_profile_get_pro_features(const config_object* conf) { return unbox(conf)->get_pro_features(); } -LIBSESSION_EXPORT void user_profile_set_pro_badge(config_object* conf, bool enabled) { +LIBSESSION_C_API void user_profile_set_pro_badge(config_object* conf, bool enabled) { unbox(conf)->set_pro_badge(enabled); } -LIBSESSION_EXPORT void user_profile_set_animated_avatar(config_object* conf, bool enabled) { +LIBSESSION_C_API void user_profile_set_animated_avatar(config_object* conf, bool enabled) { unbox(conf)->set_animated_avatar(enabled); } +LIBSESSION_C_API uint64_t user_profile_get_pro_access_expiry_ms(const config_object* conf) { + if (auto expiry = unbox(conf)->get_pro_access_expiry(); expiry) + return expiry->time_since_epoch().count(); + return 0; +} + +LIBSESSION_C_API void user_profile_set_pro_access_expiry_ms( + config_object* conf, uint64_t access_expiry_ts_ms) { + if (access_expiry_ts_ms <= 0) + unbox(conf)->set_pro_access_expiry(std::nullopt); + else + unbox(conf)->set_pro_access_expiry( + std::chrono::sys_time{std::chrono::milliseconds{access_expiry_ts_ms}}); +} + } // extern "C" diff --git a/tests/test_config_userprofile.cpp b/tests/test_config_userprofile.cpp index cb0e8566..97ef3f1a 100644 --- a/tests/test_config_userprofile.cpp +++ b/tests/test_config_userprofile.cpp @@ -634,4 +634,8 @@ TEST_CASE("UserProfile Pro Storage", "[config][user_profile][pro]") { profile.remove_pro_config(); CHECK_FALSE(profile.get_pro_config().has_value()); + + auto access_expiry_ms = std::chrono::sys_time{std::chrono::milliseconds{500}}; + profile.set_pro_access_expiry(access_expiry_ms); + CHECK(profile.get_pro_access_expiry() == access_expiry_ms); } \ No newline at end of file diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 5bec0027..7203a869 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -112,7 +112,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { { char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); - std::string fake_google_payment_token_hex = "DEV." + oxenc::to_hex(fake_google_payment_token); + std::string fake_google_payment_token_hex = + "DEV." + oxenc::to_hex(fake_google_payment_token); char fake_google_order_id[8]; randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); @@ -777,7 +778,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { { char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); - std::string fake_google_payment_token_hex = "DEV." + oxenc::to_hex(fake_google_payment_token); + std::string fake_google_payment_token_hex = + "DEV." + oxenc::to_hex(fake_google_payment_token); char fake_google_order_id[8]; randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); @@ -1025,7 +1027,8 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { { char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); - std::string fake_google_payment_token_hex = "DEV." + oxenc::to_hex(fake_google_payment_token); + std::string fake_google_payment_token_hex = + "DEV." + oxenc::to_hex(fake_google_payment_token); char fake_google_order_id[8]; randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); From 660c4c527521930be98d03d2e9ef121e2d06b722 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 21 Nov 2025 12:23:18 +1100 Subject: [PATCH 163/171] Avoid char16_t in the C interface, requires C11 --- include/session/util.h | 18 +++++++----------- src/util.cpp | 19 +++++-------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/include/session/util.h b/include/session/util.h index 973bb1a9..e4c598a0 100644 --- a/include/session/util.h +++ b/include/session/util.h @@ -1,26 +1,22 @@ #pragma once +#include +#include + #include "export.h" -#include #ifdef __cplusplus extern "C" { #endif -/// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not -/// truncate in the middle of a surrogate pair. Notes that if the input string contains invalid +/// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to +/// not truncate in the middle of a surrogate pair. Notes that if the input string contains invalid /// UTF-16 sequences (e.g. unpaired surrogates) the behavior here is undefined. LIBSESSION_EXPORT size_t utf16_count_truncated_to_codepoints( - const char16_t *utf16_string, - size_t utf16_string_len, - size_t codepoint_len -); + const uint16_t* utf16_string, size_t utf16_string_len, size_t codepoint_len); /// Returns the number of unicode codepoints in a utf-16 encoded string. -LIBSESSION_EXPORT size_t utf16_count( - const char16_t *utf16_string, - size_t utf16_string_len -); +LIBSESSION_EXPORT size_t utf16_count(const uint16_t* utf16_string, size_t utf16_string_len); #ifdef __cplusplus } diff --git a/src/util.cpp b/src/util.cpp index 7ecb7c8a..df309b52 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -229,21 +229,12 @@ size_t utf16_count(std::span utf16_string) { } // namespace session LIBSESSION_C_API size_t utf16_count_truncated_to_codepoints( - const char16_t *utf16_string, - size_t utf16_string_len, - size_t codepoint_len -) { + const uint16_t* utf16_string, size_t utf16_string_len, size_t codepoint_len) { return session::utf16_count_truncated_to_codepoints( - std::span{utf16_string, utf16_string_len}, - codepoint_len - ); + {reinterpret_cast(utf16_string), utf16_string_len}, codepoint_len); } -LIBSESSION_C_API size_t utf16_count( - const char16_t *utf16_string, - size_t utf16_string_len -) { +LIBSESSION_C_API size_t utf16_count(const uint16_t* utf16_string, size_t utf16_string_len) { return session::utf16_count( - std::span{utf16_string, utf16_string_len} - ); -} \ No newline at end of file + {reinterpret_cast(utf16_string), utf16_string_len}); +} From 3731a9f90fb6be5e98a970ad8a2956c8fcb2e68c Mon Sep 17 00:00:00 2001 From: SessionHero01 Date: Fri, 21 Nov 2025 16:01:29 +1100 Subject: [PATCH 164/171] Fix compile issue for Android --- src/config/user_profile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 1166e212..71ecd227 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -248,7 +248,7 @@ void UserProfile::set_animated_avatar(bool enabled) { std::optional> UserProfile::get_pro_access_expiry() const { if (auto* E = data["E"].integer(); E) - return std::chrono::sys_time{std::chrono::milliseconds{*E}}; + return std::chrono::sys_time{std::chrono::milliseconds{*E}}; return std::nullopt; } @@ -439,7 +439,7 @@ LIBSESSION_C_API void user_profile_set_pro_access_expiry_ms( unbox(conf)->set_pro_access_expiry(std::nullopt); else unbox(conf)->set_pro_access_expiry( - std::chrono::sys_time{std::chrono::milliseconds{access_expiry_ts_ms}}); + std::chrono::sys_time{std::chrono::milliseconds{access_expiry_ts_ms}}); } } // extern "C" From 193eb69fe776e4bedd3f87d6f7c6dd97475e9b28 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 21 Nov 2025 16:25:50 +1100 Subject: [PATCH 165/171] Add mission symbol export for user_profile_remove_pro_config --- include/session/config/user_profile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/session/config/user_profile.h b/include/session/config/user_profile.h index 78cc7997..2d989919 100644 --- a/include/session/config/user_profile.h +++ b/include/session/config/user_profile.h @@ -338,7 +338,7 @@ LIBSESSION_EXPORT void user_profile_set_pro_config(config_object* conf, const pr /// /// Outputs: /// - `bool` - A flag indicating whether the config had Session Pro components which were removed. -bool user_profile_remove_pro_config(config_object* conf); +LIBSESSION_EXPORT bool user_profile_remove_pro_config(config_object* conf); /// API: user_profile/user_profile_get_pro_features /// From a75482bd34ab60384c8cdce8c3248c19f4ec1595 Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 21 Nov 2025 16:26:08 +1100 Subject: [PATCH 166/171] Formatting --- include/session/util.hpp | 7 ++++--- src/config/user_profile.cpp | 3 ++- src/util.cpp | 11 ++++------- tests/test_unicode_operations.cpp | 6 ++---- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/session/util.hpp b/include/session/util.hpp index 68cfa578..8ee05286 100644 --- a/include/session/util.hpp +++ b/include/session/util.hpp @@ -252,10 +252,11 @@ inline std::string utf8_truncate(std::string val, size_t n) { return val; } -/// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to not -/// truncate in the middle of a surrogate pair. Notes that if the input string contains invalid +/// Truncates an utf-16 encoded string to at most `codepoint_len` codepoints long, taking care to +/// not truncate in the middle of a surrogate pair. Notes that if the input string contains invalid /// UTF-16 sequences (e.g. unpaired surrogates) the behavior here is undefined. -size_t utf16_count_truncated_to_codepoints(std::span utf16_string, size_t codepoint_len); +size_t utf16_count_truncated_to_codepoints( + std::span utf16_string, size_t codepoint_len); /// Returns the number of unicode codepoints in a utf-16 encoded string. size_t utf16_count(std::span utf16_string); diff --git a/src/config/user_profile.cpp b/src/config/user_profile.cpp index 71ecd227..d5809597 100644 --- a/src/config/user_profile.cpp +++ b/src/config/user_profile.cpp @@ -439,7 +439,8 @@ LIBSESSION_C_API void user_profile_set_pro_access_expiry_ms( unbox(conf)->set_pro_access_expiry(std::nullopt); else unbox(conf)->set_pro_access_expiry( - std::chrono::sys_time{std::chrono::milliseconds{access_expiry_ts_ms}}); + std::chrono::sys_time{ + std::chrono::milliseconds{access_expiry_ts_ms}}); } } // extern "C" diff --git a/src/util.cpp b/src/util.cpp index df309b52..a8b24360 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,12 +1,11 @@ +#include +#include #include #include #include #include #include -#include - -#include namespace session { @@ -198,14 +197,12 @@ size_t utf16_count_truncated_to_codepoints( // Start of a surrogate pair. Only count the codepoint when we see the low surrogate. expecting_low_surrogate = true; - } - else if (is_utf16_low_surrogate(c)) { + } else if (is_utf16_low_surrogate(c)) { assert(expecting_low_surrogate); counted_codepoints++; expecting_low_surrogate = false; - } - else { + } else { // Regular BMP character assert(!expecting_low_surrogate); counted_codepoints++; diff --git a/tests/test_unicode_operations.cpp b/tests/test_unicode_operations.cpp index c0026970..e38a1136 100644 --- a/tests/test_unicode_operations.cpp +++ b/tests/test_unicode_operations.cpp @@ -1,8 +1,7 @@ -#include +#include #include - -#include +#include static std::vector operator""_utf16(const char* str, size_t len) { std::vector out(simdutf::utf16_length_from_utf8(str, len)); @@ -10,7 +9,6 @@ static std::vector operator""_utf16(const char* str, size_t len) { return out; } - TEST_CASE("utf16_count_truncated_to_codepoints works", "[util]") { // Given simple ASCII string, should return length equal to codepoints requested CHECK(session::utf16_count_truncated_to_codepoints("hello_world"_utf16, 11) == 11); From 0aadb44c628ac2a9ab36084b62076697ca85af0a Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 24 Nov 2025 10:46:45 +1100 Subject: [PATCH 167/171] fix: add get_pro_features body --- src/config/contacts.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config/contacts.cpp b/src/config/contacts.cpp index c862a846..12f1dff9 100644 --- a/src/config/contacts.cpp +++ b/src/config/contacts.cpp @@ -58,6 +58,10 @@ void contact_info::set_nickname_truncated(std::string n) { set_nickname(utf8_truncate(std::move(n), MAX_NAME_LENGTH)); } +SESSION_PROTOCOL_PRO_FEATURES contact_info::get_pro_features() const { + return pro_features; +} + void contact_info::set_pro_features(SESSION_PROTOCOL_PRO_FEATURES features) { pro_features = (features & ~SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT); } From b4e90ef1180b15d63b344202e664d608d71f07ac Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 24 Nov 2025 14:33:56 +1100 Subject: [PATCH 168/171] Add set payment refund requested endpoint support --- include/session/pro_backend.h | 110 ++++++++- include/session/pro_backend.hpp | 142 +++++++++++- src/pro_backend.cpp | 386 +++++++++++++++++++++++++++++++- src/session_protocol.cpp | 6 +- tests/test_pro_backend.cpp | 192 ++++++++++++++-- 5 files changed, 799 insertions(+), 37 deletions(-) diff --git a/include/session/pro_backend.h b/include/session/pro_backend.h index 6ab3bce7..ed4ed843 100644 --- a/include/session/pro_backend.h +++ b/include/session/pro_backend.h @@ -286,6 +286,7 @@ struct session_pro_backend_pro_payment_item { uint64_t grace_period_duration_ms; uint64_t platform_refund_expiry_unix_ts_ms; uint64_t revoked_unix_ts_ms; + uint64_t refund_requested_unix_ts_ms; char google_payment_token[128]; size_t google_payment_token_count; @@ -311,9 +312,29 @@ struct session_pro_backend_get_pro_details_response { bool auto_renewing; uint64_t expiry_unix_ts_ms; uint64_t grace_period_duration_ms; + uint64_t refund_requested_unix_ts_ms; uint32_t payments_total; }; +typedef struct session_pro_backend_set_payment_refund_requested_request + session_pro_backend_set_payment_refund_requested_request; +struct session_pro_backend_set_payment_refund_requested_request { + uint8_t version; + bytes32 master_pkey; + bytes64 master_sig; + uint64_t unix_ts_ms; + uint64_t refund_requested_unix_ts_ms; + session_pro_backend_add_pro_payment_user_transaction payment_tx; +}; + +typedef struct session_pro_backend_set_payment_refund_requested_response + session_pro_backend_set_payment_refund_requested_response; +struct session_pro_backend_set_payment_refund_requested_response { + session_pro_backend_response_header header; + uint8_t version; + bool updated; +}; + /// API: session_pro_backend/add_pro_payment_request_build_sigs /// /// Builds master and rotating signatures for an `add_pro_payment_request`. @@ -514,8 +535,8 @@ session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( /// API: session_pro_backend/get_pro_revocations_response_parse /// -/// Parses a JSON string into a GetProRevocationsResponse struct. -/// The caller must free the response using session_pro_backend_get_pro_revocations_response_free. +/// Parses a JSON string into a `session_pro_backend_get_pro_revocations_response` struct. +/// The caller must free the response using `session_pro_backend_get_pro_revocations_response_free`. /// /// Inputs: /// - `json` -- JSON string to parse. @@ -536,6 +557,85 @@ LIBSESSION_EXPORT session_pro_backend_get_pro_details_response session_pro_backend_get_pro_details_response_parse( const char* json, size_t json_len); +/// API: session_pro_backend/set_payment_refund_requested_request_build_sigs +/// +/// Builds master and rotating signatures for an `set_payment_refund_requested_request`. +/// Returns false if the keys (32-byte or 64-byte libsodium format) or payment token hash are +/// incorrectly sized. Using 64-byte libsodium keys is more efficient. +/// +/// Inputs: +/// - `request_version` -- Version of the request. +/// - `master_privkey` -- Ed25519 master private key (32-byte or 64-byte libsodium format). +/// - `master_privkey_len` -- Length of master_privkey. +/// - `unix_ts_ms` -- Unix timestamp for the request +/// - `refund_requested_unix_ts_ms` -- Unix timestamp to set as the timestamp that a refund was +/// requested on this payment +/// - `payment_tx_provider` -- Provider that the payment to register is coming from +/// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment provider. +/// See `AddProPaymentUserTransaction` +/// - `payment_tx_payment_id_len` -- Length of the `payment_tx_payment_id` payload +/// - `payment_tx_order_id` -- Order ID that is associated with the payment see +/// `AddProPaymentUserTransaction` +/// - `payment_tx_order_id_len` -- Length of the `payment_tx_order_id` payload +/// +/// Outputs: +/// - `bool` -- True if signatures are built successfully, false otherwise. +/// - `error` -- Backing error buffer for the signatures if `success` is false +/// - `errors_count` -- length of the error if `success` is false +/// - `sig` -- The generated signature +LIBSESSION_EXPORT +session_pro_backend_signature session_pro_backend_set_payment_refund_requested_request_build_sigs( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_ms, + uint64_t refund_requested_unix_ts_ms, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) NON_NULL_ARG(2, 7, 9); + +/// API: session_pro_backend/set_payment_refund_requested_request_build_to_json +/// +/// Builds the JSON for a `set_payment_refund_requested_request`. This function is the same as +/// filling in the struct and calling the corresponding `to_json` function. The caller must free the +/// returned string using `session_pro_backend_to_json_free`. +/// +/// See: session_pro_backend_set_payment_refund_requested_request_build_sigs +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_set_payment_refund_requested_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_ms, + uint64_t refund_requested_unix_ts_ms, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) NON_NULL_ARG(2, 7, 9); + +/// API: session_pro_backend/set_payment_refund_requested_request_to_json +/// +/// Serializes a `set_payment_refund_requested_request` to a JSON string. +/// The caller must free the returned string using `session_pro_backend_to_json_free`. +LIBSESSION_EXPORT +session_pro_backend_to_json session_pro_backend_set_payment_refund_requested_request_to_json( + const session_pro_backend_set_payment_refund_requested_request* request); + +/// API: session_pro_backend/set_payment_refund_requested_response_parse +/// +/// Parses a JSON string into a GetProPaymentsResponse struct. +/// The caller must free the response using +/// `session_pro_backend_set_payment_refund_requested_response_free`. +/// +/// Inputs: +/// - `json` -- JSON string to parse. +/// - `json_len` -- Length of the JSON string. +LIBSESSION_EXPORT session_pro_backend_set_payment_refund_requested_response +session_pro_backend_set_payment_refund_requested_response_parse(const char* json, size_t json_len); + /// API: session_pro_backend/to_json_free /// /// Frees the JSON @@ -563,6 +663,12 @@ LIBSESSION_EXPORT void session_pro_backend_get_pro_details_response_free( session_pro_backend_get_pro_details_response* response); +/// API: session_pro_backend/session_pro_backend_set_payment_refund_requested_response_free +/// +/// Frees the respone +LIBSESSION_EXPORT +void session_pro_backend_set_payment_refund_requested_response_free( + session_pro_backend_set_payment_refund_requested_response* response); #ifdef __cplusplus } // extern "C" #endif diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index 0eaa9ea8..e8dc08bc 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -158,9 +158,8 @@ struct AddProPaymentRequest { /// API: pro/AddProPaymentRequest::build_sigs /// /// Builds the master and rotating signatures using the provided private keys and payment token - /// hash. Throws if the keys (32-byte or 64-byte libsodium format) or 32-byte payment token hash - /// are passed with an incorrect size or the payment IDs are invalid. Using 64-byte libsodium - /// keys is more efficient. + /// hash. Throws if the keys (32-byte or 64-byte libsodium format) are incorrectly sized. + /// Using 64-byte libsodium keys is more efficient. /// /// Inputs: /// - `request_version` -- Version of the request to build a hash for @@ -224,7 +223,8 @@ struct AddProPaymentOrGenerateProProofResponse : public ResponseHeader { /// - `json` -- JSON string to parse. /// /// Outputs: - /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. + /// - The response struct with `status` set to an error state on failure. Errors are stored in + /// `errors` static AddProPaymentOrGenerateProProofResponse parse(std::string_view json); }; @@ -346,7 +346,8 @@ struct GetProRevocationsResponse : public ResponseHeader { /// - `json` -- JSON string to parse. /// /// Outputs: - /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. + /// - The response struct with `status` set to an error state on failure. Errors are stored in + /// `errors` static GetProRevocationsResponse parse(std::string_view json); }; @@ -461,6 +462,10 @@ struct ProPaymentItem { /// Unix timestamp of when the payment was revoked or refunded. 0 if not applicable. std::chrono::sys_time revoked_unix_ts; + /// UNIX timestamp at which a refund request was requested for this payment. This is set to 0 + /// if no refund has been requested for this payment yet. + std::chrono::sys_time refund_requested_unix_ts; + /// When payment provider is set to Google Play Store, this is the platform-specific purchase /// token. This information should be considered as confidential and stored appropriately. std::string google_payment_token; @@ -523,12 +528,18 @@ struct GetProDetailsResponse : public ResponseHeader { /// This timestamp may be in the past if the user no longer has active payments. Overtime the /// Pro Backend may prune user history and so after long lapses of activity, a user's /// subscription history may be deleted. - std::chrono::sys_time expiry_unix_ts_ms; + std::chrono::sys_time expiry_unix_ts; /// Duration that a user is entitled to for their grace period. This value is to be ignored if /// `auto_renewing` is false. It can be used to calculate the subscription expiry timestamp by /// subtracting `expiry_unix_ts_ms` from this value. - std::chrono::milliseconds grace_period_duration_ms; + std::chrono::milliseconds grace_period_duration; + + /// UNIX timestamp at which a refund request was requested by this user. This timestamp comes + /// from the latest payment that the backend has deemed to be active for the user (e.g. the + /// payment associated with the `expiry_unix_ts_ms`). This value is 0 if no refund has been + /// requested on the active payment. + std::chrono::sys_time refund_requested_unix_ts; /// Total number of payments known by the backend for the user. This may be greater than the /// length of items if the request, requested less than the number of payments the user has. @@ -542,9 +553,122 @@ struct GetProDetailsResponse : public ResponseHeader { /// - `json` -- JSON string to parse. /// /// Outputs: - /// - `bool` - True if parsing succeeds, false otherwise. Errors are stored in `errors`. + /// - The response struct with `status` set to an error state on failure. Errors are stored in + /// `errors` static GetProDetailsResponse parse(std::string_view json); }; -void make_blake2b32_hasher(struct crypto_generichash_blake2b_state* hasher); +struct SetPaymentRefundRequestedRequest { + /// Request version for the API + std::uint8_t version; + + /// 32-byte Ed25519 master public key to retrieve payments for + array_uc32 master_pkey; + + /// 64-byte signature proving knowledge of the master public key's secret component + array_uc64 master_sig; + + /// Unix timestamp of the current time + std::chrono::sys_time unix_ts; + + /// Unix timestamp to set as the timestamp that a refund was requested on this payment. + std::chrono::sys_time refund_requested_unix_ts; + + /// Payment details to set the refund request on + AddProPaymentUserTransaction payment_tx; + + /// API: pro/SetPaymentRefundRequested::build_sigs + /// + /// Builds the signature that must be included in the request to authenticate and permit + /// updating the refund requested status of a payment. Throws if the keys (32-byte or + /// 64-byte libsodium format) are incorrectly sized. Using 64-byte libsodium keys is more + /// efficient. + /// + /// Inputs: + /// - `request_version` -- Version of the request to build a hash for + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `unix_ts` -- Unix timestamp for the request. + /// - `refund_requested_unix_ts` -- Unix timestamp to set as the timestamp that a refund was + /// requested on this payment + /// - `payment_tx_provider` -- Provider that the payment to set a refund request on is coming + /// from + /// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment + /// provider. See `AddProPaymentUserTransaction` + /// this is the transaction ID). + /// - `payment_tx_order_id` -- Order ID that is associated with the payment see + /// `AddProPaymentUserTransaction` + /// + /// Outputs: + /// - `array_uc64` - the 64-byte signature + static array_uc64 build_sig( + uint8_t version, + std::span master_privkey, + std::chrono::sys_time unix_ts, + std::chrono::sys_time refund_requested_unix_ts, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id, + std::span payment_tx_order_id); + + /// API: pro/SetPaymentRefundRequested::build_to_json + /// + /// Builds a SetPaymentRefundRequested and serialize it to JSON. This function is the same as + /// filling the struct fields and calling `to_json`. + /// + /// Inputs: + /// - `version` -- Version of the request to build a request from + /// - `master_privkey` -- 64-byte libsodium style or 32 byte Ed25519 master private key + /// - `unix_ts` -- Unix timestamp for the request. + /// - `refund_requested_unix_ts` -- Unix timestamp to set as the timestamp that a refund was + /// requested on this payment + /// - `payment_tx_provider` -- Provider that the payment to set a refund request on is coming + /// from + /// - `payment_tx_payment_id` -- ID that is associated with the payment from the payment + /// provider. See `AddProPaymentUserTransaction` + /// this is the transaction ID). + /// - `payment_tx_order_id` -- Order ID that is associated with the payment see + /// `AddProPaymentUserTransaction` + /// + /// Outputs: + /// - `std::string` -- Request serialised to JSON + static std::string build_to_json( + std::uint8_t version, + std::span master_privkey, + std::chrono::sys_time unix_ts, + std::chrono::sys_time refund_requested_unix_ts, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id, + std::span payment_tx_order_id); + + /// API: pro/SetPaymentRefundRequested::to_json + /// + /// Serializes the request to a JSON string. + /// + /// Outputs: + /// - `std::string` - JSON representation of the request. + std::string to_json() const; +}; + +struct SetPaymentRefundRequestedResponse : public ResponseHeader { + /// Version from the request + std::uint8_t version; + + /// True if a payment was found matching the given payment information and that the refund + /// request unix timestamp was set + bool updated; + + /// API: pro/SetPaymentRefundRequestedResponse::parse + /// + /// Parses a JSON string into the response struct. + /// + /// Inputs: + /// - `json` -- JSON string to parse. + /// + /// Outputs: + /// - The response struct with `status` set to an error state on failure. Errors are stored in + /// `errors` + static SetPaymentRefundRequestedResponse parse(std::string_view json); +}; + +void make_blake2b32_hasher( + struct crypto_generichash_blake2b_state* hasher, std::string_view personalisation); } // namespace session::pro_backend diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index ad6fc03b..d8f0b0ea 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -16,11 +16,19 @@ namespace { +// TODO: Personalise this for each use-case instead of a generic catch-all // NOTE: Personalization data must match // https://github.com/Doy-lee/session-pro-backend/blob/2afe310adad52f211e3b2cfcbdfc9eda6ff1778e/backend.py#L156 -constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALIZATION = "SeshProBackend__"; +// https://github.com/Doy-lee/session-pro-backend/blob/a9cdc0920f5ad3506962e7a0c36be769ab61baee/server.py#L573 +constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALISATION = "SeshProBackend__"; +constexpr std::string_view PRO_BACKEND_BLAKE2B_SET_PAYMENT_REFUND_REQUESTED_PERSONALISATION = + "ProSetRefundReq_"; + +static_assert( + PRO_BACKEND_BLAKE2B_PERSONALISATION.size() == crypto_generichash_blake2b_PERSONALBYTES); static_assert( - PRO_BACKEND_BLAKE2B_PERSONALIZATION.size() == crypto_generichash_blake2b_PERSONALBYTES); + PRO_BACKEND_BLAKE2B_SET_PAYMENT_REFUND_REQUESTED_PERSONALISATION.size() == + crypto_generichash_blake2b_PERSONALBYTES); const nlohmann::json json_parse(std::string_view json, std::vector& errors) { nlohmann::json result; @@ -185,7 +193,7 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( // https://github.com/Doy-lee/session-pro-backend/blob/5b66b1a4a64dc8da0225507019cbe21d7642fa78/backend.py#L171 array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; - make_blake2b32_hasher(&state); + make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, @@ -363,7 +371,7 @@ MasterRotatingSignatures GenerateProProofRequest::build_sigs( uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; - make_blake2b32_hasher(&state); + make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, master_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); @@ -528,7 +536,7 @@ array_uc64 GetProDetailsRequest::build_sig( array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); - make_blake2b32_hasher(&state); + make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, @@ -625,9 +633,13 @@ GetProDetailsResponse GetProDetailsResponse::parse(std::string_view json) { json_require(result_obj, "expiry_unix_ts_ms", result.errors); uint64_t grace_period_duration_ms = json_require(result_obj, "grace_period_duration_ms", result.errors); - result.expiry_unix_ts_ms = std::chrono::sys_time( + uint64_t refund_requested_unix_ts_ms = + json_require(result_obj, "refund_requested_unix_ts_ms", result.errors); + result.expiry_unix_ts = std::chrono::sys_time( std::chrono::milliseconds(expiry_unix_ts_ms)); - result.grace_period_duration_ms = std::chrono::milliseconds(grace_period_duration_ms); + result.grace_period_duration = std::chrono::milliseconds(grace_period_duration_ms); + result.refund_requested_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(refund_requested_unix_ts_ms)); auto array = json_require(result_obj, "items", result.errors); result.items.reserve(array.size()); @@ -653,6 +665,8 @@ GetProDetailsResponse GetProDetailsResponse::parse(std::string_view json) { auto platform_refund_expiry_ts = json_require(obj, "platform_refund_expiry_unix_ts_ms", result.errors); auto revoked_ts = json_require(obj, "revoked_unix_ts_ms", result.errors); + auto refund_requested_ts = + json_require(obj, "refund_requested_unix_ts_ms", result.errors); ProPaymentItem item = {}; if (status > SESSION_PRO_BACKEND_PAYMENT_STATUS_NIL && @@ -691,6 +705,8 @@ GetProDetailsResponse GetProDetailsResponse::parse(std::string_view json) { std::chrono::milliseconds(platform_refund_expiry_ts)); item.revoked_unix_ts = std::chrono::sys_time( std::chrono::milliseconds(revoked_ts)); + item.refund_requested_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds(refund_requested_ts)); switch (item.payment_provider) { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: [[fallthrough]]; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: { @@ -731,14 +747,169 @@ GetProDetailsResponse GetProDetailsResponse::parse(std::string_view json) { return result; } -void make_blake2b32_hasher(crypto_generichash_blake2b_state* hasher) { +array_uc64 SetPaymentRefundRequestedRequest::build_sig( + uint8_t version, + std::span master_privkey, + std::chrono::sys_time unix_ts, + std::chrono::sys_time refund_requested_unix_ts, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id, + std::span payment_tx_order_id) { + cleared_uc64 master_from_seed; + if (master_privkey.size() == crypto_sign_ed25519_SEEDBYTES) { + array_uc32 master_pubkey; + crypto_sign_ed25519_seed_keypair( + master_pubkey.data(), master_from_seed.data(), master_privkey.data()); + master_privkey = master_from_seed; + } else if (master_privkey.size() != crypto_sign_ed25519_SECRETKEYBYTES) { + throw std::invalid_argument{"Invalid master_privkey: expected 32 or 64 bytes"}; + } + + // Hash components to 32 bytes, must match: + // https://github.com/Doy-lee/session-pro-backend/blob/5962925d7f18f83a3ff5774885495e5dd55ecb0a/server.py#L634 + array_uc32 hash_to_sign = {}; + crypto_generichash_blake2b_state state = {}; + make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_SET_PAYMENT_REFUND_REQUESTED_PERSONALISATION); + crypto_generichash_blake2b_update(&state, &version, sizeof(version)); + crypto_generichash_blake2b_update( + &state, + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + + // Timestamps + uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); + uint64_t refund_requested_unix_ts_ms = refund_requested_unix_ts.time_since_epoch().count(); + crypto_generichash_blake2b_update( + &state, reinterpret_cast(&unix_ts_ms), sizeof(unix_ts_ms)); + crypto_generichash_blake2b_update( + &state, + reinterpret_cast(&refund_requested_unix_ts_ms), + sizeof(refund_requested_unix_ts_ms)); + + // Payment provider + uint8_t provider_u8 = payment_tx_provider; + crypto_generichash_blake2b_update(&state, &provider_u8, sizeof(provider_u8)); + crypto_generichash_blake2b_update( + &state, + reinterpret_cast(payment_tx_payment_id.data()), + payment_tx_payment_id.size()); + if (payment_tx_order_id.size()) { + crypto_generichash_blake2b_update( + &state, + reinterpret_cast(payment_tx_order_id.data()), + payment_tx_order_id.size()); + } + crypto_generichash_blake2b_final(&state, hash_to_sign.data(), hash_to_sign.size()); + + // Sign the hash + array_uc64 result = {}; + crypto_sign_ed25519_detached( + result.data(), + nullptr, + hash_to_sign.data(), + hash_to_sign.size(), + master_privkey.data()); + return result; +} + +std::string SetPaymentRefundRequestedRequest::build_to_json( + uint8_t version, + std::span master_privkey, + std::chrono::sys_time unix_ts, + std::chrono::sys_time refund_requested_unix_ts, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + std::span payment_tx_payment_id, + std::span payment_tx_order_id) { + array_uc64 sig = SetPaymentRefundRequestedRequest::build_sig( + version, + master_privkey, + unix_ts, + refund_requested_unix_ts, + payment_tx_provider, + payment_tx_payment_id, + payment_tx_order_id); + + SetPaymentRefundRequestedRequest request = {}; + request.version = version; + std::memcpy( + request.master_pkey.data(), + master_privkey.data() + crypto_sign_ed25519_SEEDBYTES, + crypto_sign_ed25519_PUBLICKEYBYTES); + request.payment_tx.provider = payment_tx_provider; + request.payment_tx.payment_id = std::string( + reinterpret_cast(payment_tx_payment_id.data()), + payment_tx_payment_id.size()); + request.payment_tx.order_id = std::string( + reinterpret_cast(payment_tx_order_id.data()), payment_tx_order_id.size()); + request.master_sig = sig; + request.unix_ts = unix_ts; + request.refund_requested_unix_ts = refund_requested_unix_ts; + + std::string result = request.to_json(); + return result; +} + +std::string SetPaymentRefundRequestedRequest::to_json() const { + nlohmann::json j; + j["version"] = version; + j["master_pkey"] = oxenc::to_hex(master_pkey); + j["unix_ts_ms"] = unix_ts.time_since_epoch().count(); + j["refund_requested_unix_ts_ms"] = refund_requested_unix_ts.time_since_epoch().count(); + j["payment_tx"]["provider"] = payment_tx.provider; + switch (payment_tx.provider) { + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE: { + j["payment_tx"]["google_payment_token"] = payment_tx.payment_id; + j["payment_tx"]["google_order_id"] = payment_tx.order_id; + } break; + case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_IOS_APP_STORE: { + j["payment_tx"]["apple_tx_id"] = payment_tx.payment_id; + } break; + } + j["master_sig"] = oxenc::to_hex(master_sig); + std::string result = j.dump(); + return result; +} + +SetPaymentRefundRequestedResponse SetPaymentRefundRequestedResponse::parse(std::string_view json) { + // Parse basics + SetPaymentRefundRequestedResponse result = {}; + nlohmann::json j = json_parse(json, result.errors); + result.status = json_require(j, "status", result.errors); + if (result.errors.size()) { + result.status = SESSION_PRO_BACKEND_STATUS_GENERIC_ERROR; + return result; + } + + // Parse errors + if (result.status != SESSION_PRO_BACKEND_STATUS_SUCCESS) { + parse_json_response_errors(j, result.errors); + return result; + } + + auto result_obj = json_require(j, "result", result.errors); + if (result.errors.size()) + return result; + + // Parse payload + result.version = json_require(result_obj, "version", result.errors); + result.updated = json_require(result_obj, "updated", result.errors); + return result; +} + +void make_blake2b32_hasher( + crypto_generichash_blake2b_state* hasher, std::string_view personalization) { + assert(personalization.data() == nullptr || + (personalization.data() && + personalization.size() == crypto_generichash_blake2b_PERSONALBYTES)); crypto_generichash_blake2b_init_salt_personal( hasher, /*key*/ nullptr, 0, 32, /*salt*/ nullptr, - reinterpret_cast(PRO_BACKEND_BLAKE2B_PERSONALIZATION.data())); + reinterpret_cast(personalization.data())); } } // namespace session::pro_backend @@ -1269,8 +1440,9 @@ session_pro_backend_get_pro_details_response_parse(const char* json, size_t json result.items = (session_pro_backend_pro_payment_item*)arena_alloc( &arena, result.items_count * sizeof(*result.items)); result.auto_renewing = cpp.auto_renewing; - result.expiry_unix_ts_ms = cpp.expiry_unix_ts_ms.time_since_epoch().count(); - result.grace_period_duration_ms = cpp.grace_period_duration_ms.count(); + result.expiry_unix_ts_ms = cpp.expiry_unix_ts.time_since_epoch().count(); + result.grace_period_duration_ms = cpp.grace_period_duration.count(); + result.refund_requested_unix_ts_ms = cpp.refund_requested_unix_ts.time_since_epoch().count(); result.payments_total = cpp.payments_total; for (size_t index = 0; index < result.items_count; ++index) { @@ -1299,6 +1471,9 @@ session_pro_backend_get_pro_details_response_parse(const char* json, size_t json dest.revoked_unix_ts_ms = std::chrono::duration_cast( src.revoked_unix_ts.time_since_epoch()) .count(); + dest.refund_requested_unix_ts_ms = std::chrono::duration_cast( + src.refund_requested_unix_ts.time_since_epoch()) + .count(); switch (dest.payment_provider) { case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_NIL: [[fallthrough]]; case SESSION_PRO_BACKEND_PAYMENT_PROVIDER_COUNT: break; @@ -1341,6 +1516,187 @@ session_pro_backend_get_pro_details_response_parse(const char* json, size_t json return result; } +LIBSESSION_C_API +session_pro_backend_signature session_pro_backend_set_payment_refund_requested_request_build_sigs( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_ms, + uint64_t refund_requested_unix_ts_ms, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) { + // Convert C inputs to C++ types + std::span master_span{master_privkey, master_privkey_len}; + std::chrono::sys_time unix_ts{std::chrono::milliseconds(unix_ts_ms)}; + std::chrono::sys_time refund_requested_unix_ts{ + std::chrono::milliseconds(refund_requested_unix_ts_ms)}; + std::span payment_tx_payment_id_span( + payment_tx_payment_id, payment_tx_payment_id_len); + std::span payment_tx_order_id_span(payment_tx_order_id, payment_tx_order_id_len); + + session_pro_backend_signature result = {}; + try { + auto sig = SetPaymentRefundRequestedRequest::build_sig( + request_version, + master_span, + unix_ts, + refund_requested_unix_ts, + payment_tx_provider, + payment_tx_payment_id_span, + payment_tx_order_id_span); + std::memcpy(result.sig.data, sig.data(), sig.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_to_json +session_pro_backend_set_payment_refund_requested_request_build_to_json( + uint8_t request_version, + const uint8_t* master_privkey, + size_t master_privkey_len, + uint64_t unix_ts_ms, + uint64_t refund_requested_unix_ts_ms, + SESSION_PRO_BACKEND_PAYMENT_PROVIDER payment_tx_provider, + const uint8_t* payment_tx_payment_id, + size_t payment_tx_payment_id_len, + const uint8_t* payment_tx_order_id, + size_t payment_tx_order_id_len) { + + // Convert C inputs to C++ types + std::span master_span{master_privkey, master_privkey_len}; + std::chrono::sys_time unix_ts{std::chrono::milliseconds(unix_ts_ms)}; + std::chrono::sys_time refund_requested_unix_ts{ + std::chrono::milliseconds(refund_requested_unix_ts_ms)}; + std::span payment_tx_payment_id_span( + payment_tx_payment_id, payment_tx_payment_id_len); + std::span payment_tx_order_id_span(payment_tx_order_id, payment_tx_order_id_len); + + session_pro_backend_to_json result = {}; + try { + auto json = SetPaymentRefundRequestedRequest::build_to_json( + request_version, + master_span, + unix_ts, + refund_requested_unix_ts, + payment_tx_provider, + payment_tx_payment_id_span, + payment_tx_order_id_span); + result.json = session::string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + return result; +} + +LIBSESSION_C_API session_pro_backend_to_json +session_pro_backend_set_payment_refund_requested_request_to_json( + const session_pro_backend_set_payment_refund_requested_request* request) { + session_pro_backend_to_json result = {}; + if (!request) + return result; + + // Construct C++ struct + SetPaymentRefundRequestedRequest cpp = {}; + cpp.version = request->version; + std::memcpy( + cpp.master_pkey.data(), request->master_pkey.data, sizeof(request->master_pkey.data)); + std::memcpy(cpp.master_sig.data(), request->master_sig.data, sizeof(request->master_sig.data)); + cpp.unix_ts = std::chrono::sys_time{ + std::chrono::milliseconds{request->unix_ts_ms}}; + cpp.refund_requested_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds{request->refund_requested_unix_ts_ms}); + cpp.payment_tx.provider = request->payment_tx.provider; + cpp.payment_tx.payment_id = + std::string(request->payment_tx.payment_id, request->payment_tx.payment_id_count); + cpp.payment_tx.order_id = + std::string(request->payment_tx.order_id, request->payment_tx.order_id_count); + + try { + std::string json = cpp.to_json(); + result.json = session::string8_copy_or_throw(json.data(), json.size()); + result.success = true; + } catch (const std::exception& e) { + const std::string& error = e.what(); + result.error_count = snprintf_clamped( + result.error, + sizeof(result.error_count), + "%.*s", + static_cast(error.size()), + error.data()); + } + + return result; +} + +LIBSESSION_C_API session_pro_backend_set_payment_refund_requested_response +session_pro_backend_set_payment_refund_requested_response_parse(const char* json, size_t json_len) { + session_pro_backend_set_payment_refund_requested_response result = {}; + if (!json) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_INVALID_ARGS; + result.header.errors_count = 1; + return result; + } + + // Note, parse is written to not throw so we can safely read without try-catch crap + auto cpp = SetPaymentRefundRequestedResponse::parse({json, json_len}); + + // Calculate how much memory we need and create an arena + arena_t arena = {}; + { + for (auto it : cpp.errors) + arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); + + if (arena.max) + arena.data = static_cast(malloc(arena.max)); + + if (arena.max && !arena.data) { + result.header.status = 1; + result.header.errors = &C_PARSE_ERROR_OUT_OF_MEMORY; + result.header.errors_count = 1; + return result; + } + + // Store the pointer to the backing memory. Upon freeing, we release this one pointer + result.header.internal_arena_buf_ = arena.data; + } + + // Copy to C struct + result.header.status = cpp.status; + result.version = cpp.version; + result.updated = cpp.updated; + + // Copy errors + result.header.errors_count = cpp.errors.size(); + result.header.errors = (string8*)arena_alloc( + &arena, result.header.errors_count * sizeof(*result.header.errors)); + for (size_t index = 0; index < cpp.errors.size(); index++) { + const std::string& it = cpp.errors[index]; + result.header.errors[index] = arena_alloc_to_string8(&arena, it.data(), it.size()); + } + + return result; +} + LIBSESSION_C_API void session_pro_backend_to_json_free(session_pro_backend_to_json* to_json) { if (to_json) { free(to_json->json.data); @@ -1371,3 +1727,11 @@ LIBSESSION_C_API void session_pro_backend_get_pro_details_response_free( *response = {}; } } + +LIBSESSION_C_API void session_pro_backend_set_payment_refund_requested_response_free( + session_pro_backend_set_payment_refund_requested_response* response) { + if (response) { + free(response->header.internal_arena_buf_); + *response = {}; + } +} diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 603d622f..5647cf44 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -23,11 +23,15 @@ session::array_uc32 proof_hash_internal( std::span gen_index_hash, std::span rotating_pubkey, std::uint64_t expiry_unix_ts_ms) { + + // TODO: Personalise this for each use-case instead of a generic catch-all + constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALISATION = "SeshProBackend__"; + // This must match the hashing routine at // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 session::array_uc32 result = {}; crypto_generichash_blake2b_state state = {}; - session::pro_backend::make_blake2b32_hasher(&state); + session::pro_backend::make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); diff --git a/tests/test_pro_backend.cpp b/tests/test_pro_backend.cpp index 7203a869..76feeba8 100644 --- a/tests/test_pro_backend.cpp +++ b/tests/test_pro_backend.cpp @@ -642,6 +642,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"auto_renewing", true}, {"expiry_unix_ts_ms", unix_ts_ms + 2}, {"grace_period_duration_ms", 1000}, + {"refund_requested_unix_ts_ms", unix_ts_ms + 3602}, {"payments_total", 3}, {"items", nlohmann::json::array( @@ -656,6 +657,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { {"grace_period_duration_ms", 1001}, {"platform_refund_expiry_unix_ts_ms", unix_ts_ms + 1}, {"revoked_unix_ts_ms", unix_ts_ms + 3600}, + {"refund_requested_unix_ts_ms", unix_ts_ms + 3601}, {"google_payment_token", std::string(payment_tx.payment_id, payment_tx.payment_id_count)}, {"google_order_id", @@ -681,6 +683,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.auto_renewing == true); REQUIRE(result.grace_period_duration_ms == 1000); REQUIRE(result.expiry_unix_ts_ms == unix_ts_ms + 2); + REQUIRE(result.refund_requested_unix_ts_ms == unix_ts_ms + 3602); REQUIRE(result.payments_total == 3); REQUIRE(result.items != nullptr); REQUIRE(result.items[0].status == SESSION_PRO_BACKEND_PAYMENT_STATUS_REDEEMED); @@ -693,6 +696,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(result.items[0].grace_period_duration_ms == 1001); REQUIRE(result.items[0].platform_refund_expiry_unix_ts_ms == unix_ts_ms + 1); REQUIRE(result.items[0].revoked_unix_ts_ms == unix_ts_ms + 3600); + REQUIRE(result.items[0].refund_requested_unix_ts_ms == unix_ts_ms + 3601); REQUIRE(result.items[0].google_payment_token_count == payment_tx.payment_id_count); REQUIRE(std::memcmp( result.items[0].google_payment_token, @@ -753,6 +757,117 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { session_pro_backend_get_pro_details_response_free(&pay_response); REQUIRE(pay_response.header.internal_arena_buf_ == nullptr); } + + SECTION("session_pro_backend_set_payment_refund_requested_request_to_json") { + session_pro_backend_set_payment_refund_requested_request request = {}; + request.version = 0; + request.master_pkey = master_pubkey; + request.unix_ts_ms = unix_ts_ms; + request.refund_requested_unix_ts_ms = unix_ts_ms + 1; + + session_pro_backend_signature sig = + session_pro_backend_set_payment_refund_requested_request_build_sigs( + request.version, + master_privkey.data, + sizeof(master_privkey.data), + request.unix_ts_ms, + request.refund_requested_unix_ts_ms, + payment_tx.provider, + reinterpret_cast(payment_tx.payment_id), + payment_tx.payment_id_count, + reinterpret_cast(payment_tx.order_id), + payment_tx.order_id_count); + request.master_sig = sig.sig; + REQUIRE(sig.success); + + // Valid request + auto result = + session_pro_backend_set_payment_refund_requested_request_to_json(&request); + { + scope_exit result_free{[&]() { session_pro_backend_to_json_free(&result); }}; + REQUIRE(result.success); + REQUIRE(result.json.data != nullptr); + REQUIRE(result.json.size > 0); + + // Verify JSON matches C++ implementation + SetPaymentRefundRequestedRequest cpp = {}; + cpp.version = request.version; + std::memcpy( + cpp.master_pkey.data(), + request.master_pkey.data, + sizeof(request.master_pkey.data)); + cpp.unix_ts = std::chrono::sys_time( + std::chrono::milliseconds{unix_ts_ms}); + cpp.refund_requested_unix_ts = std::chrono::sys_time( + std::chrono::milliseconds{request.refund_requested_unix_ts_ms}); + std::memcpy( + cpp.master_sig.data(), + request.master_sig.data, + sizeof(request.master_sig.data)); + + std::string cpp_json = cpp.to_json(); + REQUIRE(string8_equals(result.json, cpp_json)); + } + + // After freeing + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + + // Null request + result = session_pro_backend_set_payment_refund_requested_request_to_json(nullptr); + REQUIRE(!result.success); + REQUIRE(result.json.data == nullptr); + REQUIRE(result.json.size == 0); + } + + SECTION("session_pro_backend_set_payment_refund_requested_response_parse") { + nlohmann::json j; + j["status"] = SESSION_PRO_BACKEND_STATUS_SUCCESS; + j["result"] = {{"updated", true}, {"version", 0}}; + std::string json = j.dump(); + + // Valid JSON + auto result = session_pro_backend_set_payment_refund_requested_response_parse( + json.data(), json.size()); + { + scope_exit result_free{[&]() { + session_pro_backend_set_payment_refund_requested_response_free(&result); + }}; + for (size_t index = 0; index < result.header.errors_count; index++) + INFO(result.header.errors[index].data); + REQUIRE(result.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 0); + REQUIRE(result.header.errors == nullptr); + REQUIRE(result.updated); + REQUIRE(result.version == 0); + } + + // After freeing + REQUIRE(result.header.internal_arena_buf_ == nullptr); + + // Invalid JSON + json = "{invalid}"; + { + result = session_pro_backend_set_payment_refund_requested_response_parse( + json.data(), json.size()); + scope_exit result_free{[&]() { + session_pro_backend_set_payment_refund_requested_response_free(&result); + }}; + for (size_t index = 0; index < result.header.errors_count; index++) + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count > 0); + REQUIRE(result.header.errors != nullptr); + } + + // After freeing + REQUIRE(result.header.internal_arena_buf_ == nullptr); + + // Null JSON + result = session_pro_backend_set_payment_refund_requested_response_parse(nullptr, 0); + REQUIRE(result.header.status != SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(result.header.errors_count == 1); + REQUIRE(result.header.errors != nullptr); + } } #if defined(TEST_PRO_BACKEND_WITH_DEV_SERVER) @@ -1024,6 +1139,7 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { } // Add _another_ payment, same details + session_pro_backend_add_pro_payment_user_transaction another_payment_tx = {}; { char fake_google_payment_token[8]; randombytes_buf(fake_google_payment_token, sizeof(fake_google_payment_token)); @@ -1034,18 +1150,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { randombytes_buf(fake_google_order_id, sizeof(fake_google_order_id)); std::string fake_google_order_id_hex = "DEV." + oxenc::to_hex(fake_google_order_id); - session_pro_backend_add_pro_payment_user_transaction payment_tx = {}; - payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; - payment_tx.payment_id_count = fake_google_payment_token_hex.size(); - payment_tx.order_id_count = fake_google_order_id_hex.size(); + another_payment_tx.provider = SESSION_PRO_BACKEND_PAYMENT_PROVIDER_GOOGLE_PLAY_STORE; + another_payment_tx.payment_id_count = fake_google_payment_token_hex.size(); + another_payment_tx.order_id_count = fake_google_order_id_hex.size(); std::memcpy( - payment_tx.payment_id, + another_payment_tx.payment_id, fake_google_payment_token_hex.data(), - payment_tx.payment_id_count); + another_payment_tx.payment_id_count); std::memcpy( - payment_tx.order_id, + another_payment_tx.order_id, fake_google_order_id_hex.data(), - payment_tx.order_id_count); + another_payment_tx.order_id_count); // Build request session_pro_backend_master_rotating_signatures add_pro_sigs = @@ -1055,17 +1170,17 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { sizeof(master_privkey), rotating_privkey.data, sizeof(rotating_privkey), - payment_tx.provider, - reinterpret_cast(payment_tx.payment_id), - payment_tx.payment_id_count, - reinterpret_cast(payment_tx.order_id), - payment_tx.order_id_count); + another_payment_tx.provider, + reinterpret_cast(another_payment_tx.payment_id), + another_payment_tx.payment_id_count, + reinterpret_cast(another_payment_tx.order_id), + another_payment_tx.order_id_count); session_pro_backend_add_pro_payment_request request = {}; request.version = 0; request.master_pkey = master_pubkey; request.rotating_pkey = rotating_pubkey; - request.payment_tx = payment_tx; + request.payment_tx = another_payment_tx; request.master_sig = add_pro_sigs.master_sig; request.rotating_sig = add_pro_sigs.rotating_sig; @@ -1137,6 +1252,55 @@ TEST_CASE("Session Pro Backend C API", "[session_pro_backend]") { REQUIRE(response.ticket == 0); REQUIRE(response.items_count == 0); } + + // Set payment refund requested + { + // Build request + uint64_t now_unix_ts_ms = time(nullptr) * 1000; + session_pro_backend_to_json request_json = + session_pro_backend_set_payment_refund_requested_request_build_to_json( + /*version*/ 0, + master_privkey.data, + sizeof(master_privkey.data), + /*unix_ts_ms*/ now_unix_ts_ms, + /*refund_requested_unix_ts_ms*/ now_unix_ts_ms, + another_payment_tx.provider, + reinterpret_cast(another_payment_tx.payment_id), + another_payment_tx.payment_id_count, + reinterpret_cast(another_payment_tx.order_id), + another_payment_tx.order_id_count); + + scope_exit request_json_free{ + [&]() { session_pro_backend_to_json_free(&request_json); }}; + + // Do curl request + std::string response_json = curl_do_basic_blocking_post_request( + curl, + curl_headers, + g_test_pro_backend_dev_server_url + "/set_payment_refund_requested", + std::string_view(request_json.json.data, request_json.json.size)); + + // Parse response + session_pro_backend_set_payment_refund_requested_response response = + session_pro_backend_set_payment_refund_requested_response_parse( + response_json.data(), response_json.size()); + scope_exit response_free{[&]() { + session_pro_backend_set_payment_refund_requested_response_free(&response); + }}; + + // Verify response + INFO("ERROR: JSON response: " << response_json.c_str()); + for (size_t index = 0; index < response.header.errors_count; index++) { + string8 error = response.header.errors[index]; + fprintf(stderr, "ERROR: %s\n", error.data); + } + + // Verify the response + REQUIRE(response.header.errors_count == 0); + REQUIRE(response.header.status == SESSION_PRO_BACKEND_STATUS_SUCCESS); + REQUIRE(response.version == 0); + REQUIRE(response.updated); + } } #endif } From 47acb57697cd1ec22c3ac4b40252bd2e3fac0a84 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 24 Nov 2025 15:07:55 +1100 Subject: [PATCH 169/171] Zero initialise arena memory in pro backend --- src/pro_backend.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index d8f0b0ea..17b114fb 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -1289,7 +1289,7 @@ session_pro_backend_add_pro_payment_or_generate_pro_proof_response_parse( arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); if (arena.max) - arena.data = static_cast(malloc(arena.max)); + arena.data = static_cast(calloc(1, arena.max)); if (arena.max && !arena.data) { result.header.status = 1; @@ -1356,7 +1356,7 @@ session_pro_backend_get_pro_revocations_response_parse(const char* json, size_t arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); if (arena.max) - arena.data = static_cast(malloc(arena.max)); + arena.data = static_cast(calloc(1, arena.max)); if (arena.max && !arena.data) { result.header.status = 1; @@ -1419,7 +1419,7 @@ session_pro_backend_get_pro_details_response_parse(const char* json, size_t json arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); if (arena.max) - arena.data = static_cast(malloc(arena.max)); + arena.data = static_cast(calloc(1, arena.max)); if (arena.max && !arena.data) { result.header.status = 1; @@ -1667,7 +1667,7 @@ session_pro_backend_set_payment_refund_requested_response_parse(const char* json arena.max += sizeof(*result.header.errors) + (it.size() + 1 /*null-terminator*/); if (arena.max) - arena.data = static_cast(malloc(arena.max)); + arena.data = static_cast(calloc(1, arena.max)); if (arena.max && !arena.data) { result.header.status = 1; From cd4c5c650214f03348c1c66d05bad0af8d4266a2 Mon Sep 17 00:00:00 2001 From: doylet Date: Mon, 24 Nov 2025 15:30:52 +1100 Subject: [PATCH 170/171] Update Session Pro personalisation keys to avoid hash collisions --- include/session/pro_backend.hpp | 3 -- include/session/session_protocol.h | 11 ++++++ include/session/session_protocol.hpp | 4 +++ src/pro_backend.cpp | 51 +++++++++------------------- src/session_protocol.cpp | 41 ++++++++++++++++++++-- 5 files changed, 69 insertions(+), 41 deletions(-) diff --git a/include/session/pro_backend.hpp b/include/session/pro_backend.hpp index e8dc08bc..6222d2a7 100644 --- a/include/session/pro_backend.hpp +++ b/include/session/pro_backend.hpp @@ -668,7 +668,4 @@ struct SetPaymentRefundRequestedResponse : public ResponseHeader { /// `errors` static SetPaymentRefundRequestedResponse parse(std::string_view json); }; - -void make_blake2b32_hasher( - struct crypto_generichash_blake2b_state* hasher, std::string_view personalisation); } // namespace session::pro_backend diff --git a/include/session/session_protocol.h b/include/session/session_protocol.h index 5d00e0f1..686ff257 100644 --- a/include/session/session_protocol.h +++ b/include/session/session_protocol.h @@ -31,6 +31,17 @@ enum { SESSION_PROTOCOL_COMMUNITY_OR_1O1_MSG_PADDING = 160, }; +// NOTE: Must match +// https://github.com/Doy-lee/session-pro-backend/blob/fca5e10c9c5014d394cf15934cd2af8e911607b9/backend.py#L21 +// https://github.com/Doy-lee/session-pro-backend/blob/fca5e10c9c5014d394cf15934cd2af8e911607b9/server.py#L571 +// clang-format off +static const char SESSION_PROTOCOL_GENERATE_PROOF_HASH_PERSONALISATION[] = "ProGenerateProof"; +static const char SESSION_PROTOCOL_BUILD_PROOF_HASH_PERSONALISATION[] = "ProProof________"; +static const char SESSION_PROTOCOL_ADD_PRO_PAYMENT_HASH_PERSONALISATION[] = "ProAddPayment___"; +static const char SESSION_PROTOCOL_SET_PAYMENT_REFUND_REQUESTED_HASH_PERSONALISATION[] = "ProSetRefundReq_"; +static const char SESSION_PROTOCOL_GET_PRO_DETAILS_HASH_PERSONALISATION[] = "ProGetProDetReq_"; +// clang-format on + typedef enum SESSION_PROTOCOL_PRO_STATUS { // See session::ProStatus SESSION_PROTOCOL_PRO_STATUS_NIL, SESSION_PROTOCOL_PRO_STATUS_INVALID_PRO_BACKEND_SIG, diff --git a/include/session/session_protocol.hpp b/include/session/session_protocol.hpp index 5dc468a9..ac0ccde0 100644 --- a/include/session/session_protocol.hpp +++ b/include/session/session_protocol.hpp @@ -634,4 +634,8 @@ DecodedCommunityMessage decode_for_community( std::span content_or_envelope_payload, std::chrono::sys_time unix_ts, const array_uc32& pro_backend_pubkey); + +/// Initialiser the blake2b hashing context to generate 32 byte hashes for Session Pro features. +void make_blake2b32_hasher( + struct crypto_generichash_blake2b_state* hasher, std::string_view personalization); } // namespace session diff --git a/src/pro_backend.cpp b/src/pro_backend.cpp index 17b114fb..c203edc3 100644 --- a/src/pro_backend.cpp +++ b/src/pro_backend.cpp @@ -12,24 +12,7 @@ #include #include -#include "SessionProtos.pb.h" - namespace { - -// TODO: Personalise this for each use-case instead of a generic catch-all -// NOTE: Personalization data must match -// https://github.com/Doy-lee/session-pro-backend/blob/2afe310adad52f211e3b2cfcbdfc9eda6ff1778e/backend.py#L156 -// https://github.com/Doy-lee/session-pro-backend/blob/a9cdc0920f5ad3506962e7a0c36be769ab61baee/server.py#L573 -constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALISATION = "SeshProBackend__"; -constexpr std::string_view PRO_BACKEND_BLAKE2B_SET_PAYMENT_REFUND_REQUESTED_PERSONALISATION = - "ProSetRefundReq_"; - -static_assert( - PRO_BACKEND_BLAKE2B_PERSONALISATION.size() == crypto_generichash_blake2b_PERSONALBYTES); -static_assert( - PRO_BACKEND_BLAKE2B_SET_PAYMENT_REFUND_REQUESTED_PERSONALISATION.size() == - crypto_generichash_blake2b_PERSONALBYTES); - const nlohmann::json json_parse(std::string_view json, std::vector& errors) { nlohmann::json result; try { @@ -193,7 +176,10 @@ MasterRotatingSignatures AddProPaymentRequest::build_sigs( // https://github.com/Doy-lee/session-pro-backend/blob/5b66b1a4a64dc8da0225507019cbe21d7642fa78/backend.py#L171 array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; - make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); + make_blake2b32_hasher( + &state, + {SESSION_PROTOCOL_ADD_PRO_PAYMENT_HASH_PERSONALISATION, + sizeof(SESSION_PROTOCOL_ADD_PRO_PAYMENT_HASH_PERSONALISATION) - 1}); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, @@ -371,7 +357,10 @@ MasterRotatingSignatures GenerateProProofRequest::build_sigs( uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; - make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); + make_blake2b32_hasher( + &state, + {SESSION_PROTOCOL_GENERATE_PROOF_HASH_PERSONALISATION, + sizeof(SESSION_PROTOCOL_GENERATE_PROOF_HASH_PERSONALISATION) - 1}); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, master_privkey.data() + 32, crypto_sign_ed25519_PUBLICKEYBYTES); @@ -536,7 +525,10 @@ array_uc64 GetProDetailsRequest::build_sig( array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; uint64_t unix_ts_ms = unix_ts.time_since_epoch().count(); - make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); + make_blake2b32_hasher( + &state, + {SESSION_PROTOCOL_GET_PRO_DETAILS_HASH_PERSONALISATION, + sizeof(SESSION_PROTOCOL_GET_PRO_DETAILS_HASH_PERSONALISATION) - 1}); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, @@ -769,7 +761,10 @@ array_uc64 SetPaymentRefundRequestedRequest::build_sig( // https://github.com/Doy-lee/session-pro-backend/blob/5962925d7f18f83a3ff5774885495e5dd55ecb0a/server.py#L634 array_uc32 hash_to_sign = {}; crypto_generichash_blake2b_state state = {}; - make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_SET_PAYMENT_REFUND_REQUESTED_PERSONALISATION); + make_blake2b32_hasher( + &state, + {SESSION_PROTOCOL_SET_PAYMENT_REFUND_REQUESTED_HASH_PERSONALISATION, + sizeof(SESSION_PROTOCOL_SET_PAYMENT_REFUND_REQUESTED_HASH_PERSONALISATION) - 1}); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update( &state, @@ -897,20 +892,6 @@ SetPaymentRefundRequestedResponse SetPaymentRefundRequestedResponse::parse(std:: result.updated = json_require(result_obj, "updated", result.errors); return result; } - -void make_blake2b32_hasher( - crypto_generichash_blake2b_state* hasher, std::string_view personalization) { - assert(personalization.data() == nullptr || - (personalization.data() && - personalization.size() == crypto_generichash_blake2b_PERSONALBYTES)); - crypto_generichash_blake2b_init_salt_personal( - hasher, - /*key*/ nullptr, - 0, - 32, - /*salt*/ nullptr, - reinterpret_cast(personalization.data())); -} } // namespace session::pro_backend using namespace session::pro_backend; diff --git a/src/session_protocol.cpp b/src/session_protocol.cpp index 5647cf44..ba46af73 100644 --- a/src/session_protocol.cpp +++ b/src/session_protocol.cpp @@ -17,6 +17,26 @@ #include "WebSocketResources.pb.h" #include "session/export.h" +static_assert( + sizeof(SESSION_PROTOCOL_GENERATE_PROOF_HASH_PERSONALISATION) - 1 == + crypto_generichash_blake2b_PERSONALBYTES); + +static_assert( + sizeof(SESSION_PROTOCOL_BUILD_PROOF_HASH_PERSONALISATION) - 1 == + crypto_generichash_blake2b_PERSONALBYTES); + +static_assert( + sizeof(SESSION_PROTOCOL_ADD_PRO_PAYMENT_HASH_PERSONALISATION) - 1 == + crypto_generichash_blake2b_PERSONALBYTES); + +static_assert( + sizeof(SESSION_PROTOCOL_SET_PAYMENT_REFUND_REQUESTED_HASH_PERSONALISATION) - 1 == + crypto_generichash_blake2b_PERSONALBYTES); + +static_assert( + sizeof(SESSION_PROTOCOL_GET_PRO_DETAILS_HASH_PERSONALISATION) - 1 == + crypto_generichash_blake2b_PERSONALBYTES); + namespace { session::array_uc32 proof_hash_internal( std::uint8_t version, @@ -24,14 +44,15 @@ session::array_uc32 proof_hash_internal( std::span rotating_pubkey, std::uint64_t expiry_unix_ts_ms) { - // TODO: Personalise this for each use-case instead of a generic catch-all constexpr std::string_view PRO_BACKEND_BLAKE2B_PERSONALISATION = "SeshProBackend__"; - // This must match the hashing routine at // https://github.com/Doy-lee/session-pro-backend/blob/9417e00adbff3bf608b7ae831f87045bdab06232/backend.py#L545-L558 session::array_uc32 result = {}; crypto_generichash_blake2b_state state = {}; - session::pro_backend::make_blake2b32_hasher(&state, PRO_BACKEND_BLAKE2B_PERSONALISATION); + session::make_blake2b32_hasher( + &state, + {SESSION_PROTOCOL_BUILD_PROOF_HASH_PERSONALISATION, + sizeof(SESSION_PROTOCOL_BUILD_PROOF_HASH_PERSONALISATION) - 1}); crypto_generichash_blake2b_update(&state, &version, sizeof(version)); crypto_generichash_blake2b_update(&state, gen_index_hash.data(), gen_index_hash.size()); crypto_generichash_blake2b_update(&state, rotating_pubkey.data(), rotating_pubkey.size()); @@ -1060,6 +1081,20 @@ DecodedCommunityMessage decode_for_community( return result; } + +void make_blake2b32_hasher( + crypto_generichash_blake2b_state* hasher, std::string_view personalization) { + assert(personalization.data() == nullptr || + (personalization.data() && + personalization.size() == crypto_generichash_blake2b_PERSONALBYTES)); + crypto_generichash_blake2b_init_salt_personal( + hasher, + /*key*/ nullptr, + 0, + 32, + /*salt*/ nullptr, + reinterpret_cast(personalization.data())); +} } // namespace session using namespace session; From 41cfac4aabb77fc2165016cb06eb514e9fafe158 Mon Sep 17 00:00:00 2001 From: doylet Date: Tue, 25 Nov 2025 10:59:02 +1100 Subject: [PATCH 171/171] Fix macOS CI build complaining about missing template arg for sys_time in userprofile tests --- tests/test_config_userprofile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_config_userprofile.cpp b/tests/test_config_userprofile.cpp index 97ef3f1a..5646f562 100644 --- a/tests/test_config_userprofile.cpp +++ b/tests/test_config_userprofile.cpp @@ -635,7 +635,8 @@ TEST_CASE("UserProfile Pro Storage", "[config][user_profile][pro]") { profile.remove_pro_config(); CHECK_FALSE(profile.get_pro_config().has_value()); - auto access_expiry_ms = std::chrono::sys_time{std::chrono::milliseconds{500}}; + auto access_expiry_ms = + std::chrono::sys_time{std::chrono::milliseconds{500}}; profile.set_pro_access_expiry(access_expiry_ms); CHECK(profile.get_pro_access_expiry() == access_expiry_ms); -} \ No newline at end of file +}