Skip to content

Commit 0b24a80

Browse files
committed
feat: allow subaccount_sign to be called with provided user_ed_sk
1 parent c96505e commit 0b24a80

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

include/session/config/groups/keys.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ class Keys : public ConfigSig {
482482
swarm_auth swarm_subaccount_sign(
483483
ustring_view msg, ustring_view signing_value, bool binary = false) const;
484484

485+
static Keys::swarm_auth swarm_subaccount_sign_as_user(
486+
session::ustring_view user_ed25519_sk,
487+
session::ustring_view msg,
488+
session::ustring_view sign_val,
489+
bool binary = false);
490+
485491
/// API: groups/Keys::swarm_subaccount_token
486492
///
487493
/// Constructs the subaccount token for a session id. The main use of this is to submit a swarm

src/config/groups/keys.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,14 +649,14 @@ ustring Keys::swarm_subaccount_token(std::string_view session_id, bool write, bo
649649
return out;
650650
}
651651

652-
Keys::swarm_auth Keys::swarm_subaccount_sign(
653-
ustring_view msg, ustring_view sign_val, bool binary) const {
652+
Keys::swarm_auth Keys::swarm_subaccount_sign_as_user(
653+
session::ustring_view user_ed25519_sk,
654+
ustring_view msg,
655+
ustring_view sign_val,
656+
bool binary) {
654657
if (sign_val.size() != 100)
655658
throw std::logic_error{"Invalid signing value: size is wrong"};
656659

657-
if (!_sign_pk)
658-
throw std::logic_error{"Unable to verify: group pubkey is not set (!?)"};
659-
660660
Keys::swarm_auth result;
661661
auto& [token, sub_sig, sig] = result;
662662

@@ -769,6 +769,12 @@ Keys::swarm_auth Keys::swarm_subaccount_sign(
769769
return result;
770770
}
771771

772+
Keys::swarm_auth Keys::swarm_subaccount_sign(
773+
ustring_view msg, ustring_view sign_val, bool binary) const {
774+
auto user_ed25519_sk_buf = this->user_ed25519_sk.data();
775+
return Keys::swarm_subaccount_sign_as_user(user_ed25519_sk_buf, msg, sign_val, binary);
776+
}
777+
772778
bool Keys::swarm_verify_subaccount(ustring_view sign_val, bool write, bool del) const {
773779
if (!_sign_pk)
774780
return false;

0 commit comments

Comments
 (0)