diff --git a/CMakeLists.txt b/CMakeLists.txt index 79d8cafb..3b471689 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,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}) diff --git a/include/session/config/groups/keys.hpp b/include/session/config/groups/keys.hpp index 5eaa27bb..1eb6f01e 100644 --- a/include/session/config/groups/keys.hpp +++ b/include/session/config/groups/keys.hpp @@ -491,6 +491,12 @@ class Keys : public ConfigSig { std::span signing_value, bool binary = false) const; + static Keys::swarm_auth swarm_subaccount_sign_as_user( + std::span user_ed25519_sk, + std::span msg, + std::span 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 86a7fd14..ab7eebb1 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/session_encrypt.hpp" +#include "session/util.hpp" #include "session/xed25519.hpp" using namespace std::literals; @@ -654,16 +655,14 @@ std::vector Keys::swarm_subaccount_token( return out; } -Keys::swarm_auth Keys::swarm_subaccount_sign( +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"}; - 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; @@ -776,6 +775,16 @@ Keys::swarm_auth Keys::swarm_subaccount_sign( return result; } +Keys::swarm_auth Keys::swarm_subaccount_sign( + std::span msg, + std::span sign_val, + bool binary) const { + auto user_ed25519_sk_buf = this->user_ed25519_sk.data(); + 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( std::span sign_val, bool write, bool del) const { if (!_sign_pk)