Skip to content

Commit d6a48ed

Browse files
committed
feat: allow subaccount_sign to be called with provided user_ed_sk
1 parent 9c2618a commit d6a48ed

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

include/session/config/groups/keys.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ class Keys : public ConfigSig {
491491
std::span<const unsigned char> signing_value,
492492
bool binary = false) const;
493493

494+
static Keys::swarm_auth swarm_subaccount_sign_as_user(
495+
std::span<const unsigned char> user_ed25519_sk,
496+
std::span<const unsigned char> msg,
497+
std::span<const unsigned char> sign_val,
498+
bool binary = false);
499+
494500
/// API: groups/Keys::swarm_subaccount_token
495501
///
496502
/// 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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,15 @@ std::vector<unsigned char> Keys::swarm_subaccount_token(
653653
return out;
654654
}
655655

656-
Keys::swarm_auth Keys::swarm_subaccount_sign(
656+
Keys::swarm_auth Keys::swarm_subaccount_sign_as_user(
657+
std::span<const unsigned char> user_ed25519_sk,
657658
std::span<const unsigned char> msg,
658659
std::span<const unsigned char> sign_val,
659660
bool binary) const {
661+
660662
if (sign_val.size() != 100)
661663
throw std::logic_error{"Invalid signing value: size is wrong"};
662664

663-
if (!_sign_pk)
664-
throw std::logic_error{"Unable to verify: group pubkey is not set (!?)"};
665-
666665
Keys::swarm_auth result;
667666
auto& [token, sub_sig, sig] = result;
668667

@@ -775,6 +774,14 @@ Keys::swarm_auth Keys::swarm_subaccount_sign(
775774
return result;
776775
}
777776

777+
Keys::swarm_auth Keys::swarm_subaccount_sign(
778+
std::span<const unsigned char> msg,
779+
std::span<const unsigned char> sign_val,
780+
bool binary) const {
781+
auto user_ed25519_sk_buf = this->user_ed25519_sk.data();
782+
return Keys::swarm_subaccount_sign_as_user(user_ed25519_sk_buf, msg, sign_val, binary);
783+
}
784+
778785
bool Keys::swarm_verify_subaccount(
779786
std::span<const unsigned char> sign_val, bool write, bool del) const {
780787
if (!_sign_pk)

0 commit comments

Comments
 (0)