mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
add multisig core test and factor multisig building blocks
This commit is contained in:
parent
f4eda44ce3
commit
66e34e85b1
17 changed files with 1019 additions and 127 deletions
|
@ -505,6 +505,54 @@ 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::hash vkh; \
|
||||
crypto::cn_fast_hash(&account[msidx_inner].get_keys().m_view_secret_key, sizeof(crypto::secret_key), vkh); \
|
||||
view_keys[msidx].push_back((const crypto::secret_key&)vkh); \
|
||||
spend_keys[msidx].push_back(account[msidx_inner].get_keys().m_account_address.m_spend_public_key); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
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(); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue