Skip to content

Parallelize SHA-512 userId recovery (fixes #4 timeout) - #26

Open
official-Cheongae wants to merge 1 commit into
silver-flight-group:mainfrom
official-Cheongae:fix/parallel-userid-recovery
Open

Parallelize SHA-512 userId recovery (fixes #4 timeout)#26
official-Cheongae wants to merge 1 commit into
silver-flight-group:mainfrom
official-Cheongae:fix/parallel-userid-recovery

Conversation

@official-Cheongae

Copy link
Copy Markdown

Problem

DeviceInfo.recoverUserIdFromSHA512 scanned 0..1_000_000_000 single-threaded with a 10-second timeout. Modern KakaoTalk account numbers are 8–10 digit integers (hundreds of millions), so on a real machine the scan times out before reaching the pre-image and userId() throws — auth then falls back to "auto-detection failed" (issue #4).

Observed on macOS 26.5 / KakaoTalk 26.7.0: single-thread scan never reached the account id within 10s.

Fix

  • Shard the search across all cores with DispatchQueue.concurrentPerform.
  • Raise the ceiling to 5e9 and extend the deadline.
  • A small @unchecked Sendable result holder (guarded by NSLock) carries the first hit and a shared cancellation flag, so every worker stops the instant one finds the pre-image or the deadline passes.

No behavior change to the derivation itself — same CC_SHA512(String(i)) pre-image, just found in parallel.

Verification

  • Release build clean on macOS 26 / Swift 6.3.3.
  • Confirmed all cores engage during recovery (≈12× CPU on a 15-core M-series).

Note: on KakaoTalk 26.7.0 I still could not decrypt with the plist candidate ids — that looks like a separate key-derivation compatibility issue (cf. #14), out of scope for this PR. This PR only removes the recovery timeout so a valid id in range is actually found.

recoverUserIdFromSHA512 scanned 0..1e9 single-threaded with a 10s
timeout. Modern KakaoTalk account numbers are 8-10 digit integers
(hundreds of millions), so the scan reliably timed out before reaching
them and auto-detection fell back to "userId not found" (issue silver-flight-group#4).

Shard the search across all cores via DispatchQueue.concurrentPerform,
raise the ceiling to 5e9, and extend the timeout. A thread-safe result
holder carries the first hit and a shared cancellation flag so all
workers stop as soon as one finds the pre-image (or the deadline hits).

Verified: release build clean on macOS 26 / Swift 6.3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant