aboutsummaryrefslogtreecommitdiff
path: root/tests/core_tests/chaingen.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/core_tests/chaingen.h')
-rw-r--r--tests/core_tests/chaingen.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h
index 0dcbc7f0c..9fed95183 100644
--- a/tests/core_tests/chaingen.h
+++ b/tests/core_tests/chaingen.h
@@ -505,6 +505,56 @@ inline bool do_replay_file(const std::string& filename)
cryptonote::account_base account; \
account.generate();
+#define GENERATE_MULTISIG_ACCOUNT(account, threshold, total) \
+ CHECK_AND_ASSERT_MES(threshold >= 2 && threshold <= total, false, "Invalid multisig scheme"); \
+ std::vector<cryptonote::account_base> account(total); \
+ do \
+ { \
+ for (size_t msidx = 0; msidx < total; ++msidx) \
+ account[msidx].generate(); \
+ std::unordered_set<crypto::public_key> all_multisig_keys; \
+ std::vector<std::vector<crypto::secret_key>> view_keys(total); \
+ std::vector<std::vector<crypto::public_key>> spend_keys(total); \
+ for (size_t msidx = 0; msidx < total; ++msidx) \
+ { \
+ for (size_t msidx_inner = 0; msidx_inner < total; ++msidx_inner) \
+ { \
+ if (msidx_inner != msidx) \
+ { \
+ crypto::secret_key vkh = cryptonote::get_multisig_blinded_secret_key(account[msidx_inner].get_keys().m_view_secret_key); \
+ view_keys[msidx].push_back(vkh); \
+ crypto::secret_key skh = cryptonote::get_multisig_blinded_secret_key(account[msidx_inner].get_keys().m_spend_secret_key); \
+ crypto::public_key pskh; \
+ crypto::secret_key_to_public_key(skh, pskh); \
+ spend_keys[msidx].push_back(pskh); \
+ } \
+ } \
+ } \
+ for (size_t msidx = 0; msidx < total; ++msidx) \
+ { \
+ std::vector<crypto::secret_key> multisig_keys; \
+ crypto::secret_key spend_skey; \
+ crypto::public_key spend_pkey; \
+ if (threshold == total) \
+ cryptonote::generate_multisig_N_N(account[msidx].get_keys(), spend_keys[msidx], multisig_keys, (rct::key&)spend_skey, (rct::key&)spend_pkey); \
+ else \
+ cryptonote::generate_multisig_N1_N(account[msidx].get_keys(), spend_keys[msidx], multisig_keys, (rct::key&)spend_skey, (rct::key&)spend_pkey); \
+ crypto::secret_key view_skey = cryptonote::generate_multisig_view_secret_key(account[msidx].get_keys().m_view_secret_key, view_keys[msidx]); \
+ account[msidx].make_multisig(view_skey, spend_skey, spend_pkey, multisig_keys); \
+ for (const auto &k: multisig_keys) \
+ all_multisig_keys.insert(rct::rct2pk(rct::scalarmultBase(rct::sk2rct(k)))); \
+ } \
+ if (threshold < total) \
+ { \
+ std::vector<crypto::public_key> spend_public_keys; \
+ for (const auto &k: all_multisig_keys) \
+ spend_public_keys.push_back(k); \
+ crypto::public_key spend_pkey = cryptonote::generate_multisig_N1_N_spend_public_key(spend_public_keys); \
+ for (size_t msidx = 0; msidx < total; ++msidx) \
+ account[msidx].finalize_multisig(spend_pkey); \
+ } \
+ } while(0)
+
#define MAKE_ACCOUNT(VEC_EVENTS, account) \
cryptonote::account_base account; \
account.generate(); \