Skip to content

Commit 4ad2b80

Browse files
committed
CreatePAKListFromExtensionSpace just uses FromBytes for correctness
1 parent 6a5eaa1 commit 4ad2b80

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/primitives/pak.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,17 @@ bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash,
175175

176176
CPAKList CreatePAKListFromExtensionSpace(const std::vector<std::vector<unsigned char>>& extension_space)
177177
{
178+
CPAKList paklist;
178179
std::vector<std::vector<unsigned char>> offline_keys;
179180
std::vector<std::vector<unsigned char>> online_keys;
180181
for (const auto& entry : extension_space) {
181-
// As soon as we find something that is possibly not 2 serialized pubkeys
182-
// we stop looking. CPAKList::FromBytes does pubkey validation itself.
183182
if (entry.size() != 66) {
184-
break;
183+
return CPAKList();
185184
}
185+
// Dumbly tries to extract two pubkeys, relies on FromBytes to parse/validate
186186
offline_keys.emplace_back(entry.begin(), entry.begin()+33);
187187
online_keys.emplace_back(entry.begin()+33, entry.end());
188-
// Allow additional data, just ignore
189-
if (offline_keys.size() == SECP256K1_WHITELIST_MAX_N_KEYS) {
190-
break;
191-
}
192188
}
193-
CPAKList paklist;
194189
if (!CPAKList::FromBytes(paklist, offline_keys, online_keys)) {
195190
return CPAKList();
196191
}

0 commit comments

Comments
 (0)