45{
46 std::vector<crypto::secret_key> all_view_keys;
47 std::vector<std::vector<crypto::public_key>> derivations(account.size());
48
49 std::unordered_set<crypto::public_key> exchanging_keys;
50
51 for (size_t msidx = 0; msidx < account.size(); ++msidx)
52 {
54 all_view_keys.push_back(vkh);
55
59
60 derivations[msidx].push_back(pskh);
61 exchanging_keys.insert(pskh);
62 }
63
67
68
69 std::vector<std::vector<crypto::secret_key>> multisig_keys(account.size());
70 std::vector<crypto::secret_key> spend_skey(account.size());
71 std::vector<crypto::public_key> spend_pkey(account.size());
72 for (
uint32_t round = 0; round < roundsTotal; ++round)
73 {
74 std::unordered_set<crypto::public_key> roundKeys;
75 for (size_t msidx = 0; msidx < account.size(); ++msidx)
76 {
77
78 auto myKeys = exchanging_keys;
79 for (const auto& d: derivations[msidx])
80 myKeys.erase(d);
81
83 {
85 }
86 else
87 {
89 roundKeys.insert(derivations[msidx].begin(), derivations[msidx].end());
90 }
91 }
92
93 exchanging_keys = roundKeys;
94 roundKeys.clear();
95 }
96
97 std::unordered_set<crypto::public_key> all_multisig_keys;
98 for (size_t msidx = 0; msidx < account.size(); ++msidx)
99 {
100 std::unordered_set<crypto::secret_key> view_keys(all_view_keys.begin(), all_view_keys.end());
101 view_keys.erase(all_view_keys[msidx]);
102
105 {
108 }
109 account[msidx].make_multisig(view_skey, spend_skey[msidx], spend_pkey[msidx], multisig_keys[msidx]);
110 for (const auto &k: multisig_keys[msidx]) {
112 }
113 }
114
116 {
117 std::vector<crypto::public_key> public_keys(std::vector<crypto::public_key>(all_multisig_keys.begin(), all_multisig_keys.end()));
119
120 for (size_t msidx = 0; msidx < account.size(); ++msidx)
121 account[msidx].finalize_multisig(spend_pkey);
122 }
123}
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
crypto::secret_key calculate_multisig_signer_key(const std::vector< crypto::secret_key > &multisig_keys)
crypto::public_key generate_multisig_M_N_spend_public_key(const std::vector< crypto::public_key > &pkeys)
generate_multisig_M_N_spend_public_key calculates multisig wallet's spend public key by summing all o...
crypto::secret_key get_multisig_blinded_secret_key(const crypto::secret_key &key)
std::vector< crypto::public_key > generate_multisig_derivations(const account_keys &keys, const std::vector< crypto::public_key > &derivations)
generate_multisig_derivations performs common DH key derivation. Each middle round in M/N scheme is D...
void generate_multisig_N_N(const account_keys &keys, const std::vector< crypto::public_key > &spend_keys, std::vector< crypto::secret_key > &multisig_keys, rct::key &spend_skey, rct::key &spend_pkey)
std::vector< crypto::secret_key > calculate_multisig_keys(const std::vector< crypto::public_key > &derivations)
calculate_multisig_keys. Calculates secret multisig keys from others' participants ones as follows: m...
crypto::secret_key generate_multisig_view_secret_key(const crypto::secret_key &skey, const std::vector< crypto::secret_key > &skeys)
void scalarmultBase(key &aG, const key &a)