From c96505e565c8d104289724e4adbed08a8297ccca Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Sun, 18 Aug 2024 12:16:10 +1000 Subject: [PATCH 1/4] fix: exceptions when compiling with emscripten --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79cfcd56..cbc12456 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,10 @@ else() set(static_default ON) endif() +if(EMSCRIPTEN) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sNO_DISABLE_EXCEPTION_CATCHING ") +endif() + option(BUILD_STATIC_DEPS "Build all dependencies statically rather than trying to link to them on the system" ${static_default}) option(STATIC_BUNDLE "Build a single static .a containing everything (both code and dependencies)" ${static_default}) From 0b24a805ff62903c8014c1473e74a52d0887ffe9 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Sun, 30 Mar 2025 13:37:43 +1100 Subject: [PATCH 2/4] feat: allow subaccount_sign to be called with provided user_ed_sk --- include/session/config/groups/keys.hpp | 6 ++++++ src/config/groups/keys.cpp | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/session/config/groups/keys.hpp b/include/session/config/groups/keys.hpp index fbe5e773..29184ac5 100644 --- a/include/session/config/groups/keys.hpp +++ b/include/session/config/groups/keys.hpp @@ -482,6 +482,12 @@ class Keys : public ConfigSig { swarm_auth swarm_subaccount_sign( ustring_view msg, ustring_view signing_value, bool binary = false) const; + static Keys::swarm_auth swarm_subaccount_sign_as_user( + session::ustring_view user_ed25519_sk, + session::ustring_view msg, + session::ustring_view sign_val, + bool binary = false); + /// API: groups/Keys::swarm_subaccount_token /// /// Constructs the subaccount token for a session id. The main use of this is to submit a swarm diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index 76c75969..a90d3663 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -649,14 +649,14 @@ ustring Keys::swarm_subaccount_token(std::string_view session_id, bool write, bo return out; } -Keys::swarm_auth Keys::swarm_subaccount_sign( - ustring_view msg, ustring_view sign_val, bool binary) const { +Keys::swarm_auth Keys::swarm_subaccount_sign_as_user( + session::ustring_view user_ed25519_sk, + ustring_view msg, + ustring_view sign_val, + bool binary) { if (sign_val.size() != 100) throw std::logic_error{"Invalid signing value: size is wrong"}; - if (!_sign_pk) - throw std::logic_error{"Unable to verify: group pubkey is not set (!?)"}; - Keys::swarm_auth result; auto& [token, sub_sig, sig] = result; @@ -769,6 +769,12 @@ Keys::swarm_auth Keys::swarm_subaccount_sign( return result; } +Keys::swarm_auth Keys::swarm_subaccount_sign( + ustring_view msg, ustring_view sign_val, bool binary) const { + auto user_ed25519_sk_buf = this->user_ed25519_sk.data(); + return Keys::swarm_subaccount_sign_as_user(user_ed25519_sk_buf, msg, sign_val, binary); +} + bool Keys::swarm_verify_subaccount(ustring_view sign_val, bool write, bool del) const { if (!_sign_pk) return false; From 3287941e4ef7c52a5ae9e774cf1b79aeaa55d611 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Sat, 6 Dec 2025 16:23:34 +1100 Subject: [PATCH 3/4] fix: build with new dev --- include/session/config/groups/keys.hpp | 6 +++--- src/config/groups/keys.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/session/config/groups/keys.hpp b/include/session/config/groups/keys.hpp index 6b102a7f..4917ec01 100644 --- a/include/session/config/groups/keys.hpp +++ b/include/session/config/groups/keys.hpp @@ -492,9 +492,9 @@ class Keys : public ConfigSig { bool binary = false) const; static Keys::swarm_auth swarm_subaccount_sign_as_user( - session::ustring_view user_ed25519_sk, - session::ustring_view msg, - session::ustring_view sign_val, + std::span user_ed25519_sk, + std::span msg, + std::span sign_val, bool binary = false); /// API: groups/Keys::swarm_subaccount_token diff --git a/src/config/groups/keys.cpp b/src/config/groups/keys.cpp index 8424790e..7a114950 100644 --- a/src/config/groups/keys.cpp +++ b/src/config/groups/keys.cpp @@ -22,6 +22,7 @@ #include "session/config/groups/keys.h" #include "session/config/groups/members.hpp" #include "session/multi_encrypt.hpp" +#include "session/util.hpp" #include "session/xed25519.hpp" using namespace std::literals; @@ -657,7 +658,7 @@ Keys::swarm_auth Keys::swarm_subaccount_sign_as_user( std::span user_ed25519_sk, std::span msg, std::span sign_val, - bool binary) const { + bool binary) { if (sign_val.size() != 100) throw std::logic_error{"Invalid signing value: size is wrong"}; @@ -774,9 +775,13 @@ Keys::swarm_auth Keys::swarm_subaccount_sign_as_user( } Keys::swarm_auth Keys::swarm_subaccount_sign( - ustring_view msg, ustring_view sign_val, bool binary) const { + std::span msg, + std::span sign_val, + bool binary) const { auto user_ed25519_sk_buf = this->user_ed25519_sk.data(); - return Keys::swarm_subaccount_sign_as_user(user_ed25519_sk_buf, msg, sign_val, binary); + std::span user_ed25519_sk( + user_ed25519_sk_buf, this->user_ed25519_sk.size()); + return Keys::swarm_subaccount_sign_as_user(user_ed25519_sk, msg, sign_val, binary); } bool Keys::swarm_verify_subaccount( From 6b05bb646a25f7cef0e07cdbdf48d5dbd5f891f2 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 15 Jan 2026 10:40:55 +1100 Subject: [PATCH 4/4] fix: typo --- src/multi_encrypt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multi_encrypt.cpp b/src/multi_encrypt.cpp index 42e61dfb..93c7f72c 100644 --- a/src/multi_encrypt.cpp +++ b/src/multi_encrypt.cpp @@ -9,7 +9,7 @@ #include #include -#include multi_encrypt +#include namespace session {