跪拜 Guibai
← All articles
Frontend · macOS · AI Programming

Android to Mac Verification Code Relay with E2E Encryption and No Cloud

By Karl_fang ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

SMS verification codes no longer force a phone pickup when both devices sit on the same LAN. The design is a template for privacy-conscious cross-device utilities: local-only discovery, one-time QR pairing, and in-memory key exchange without any cloud dependency.

Summary

Verification Relay links an Android phone to a Mac menu bar app over the same Wi-Fi network. After a one-time QR pairing, incoming SMS messages are parsed locally on the phone; only the extracted 4-8 digit code and the sender name are encrypted and pushed to the Mac, where they appear with a one-click copy button. The crypto pipeline runs P-256 ECDH key exchange, HKDF-SHA256 session key derivation, and AES-256-GCM authenticated encryption, using device IDs as authenticated data. Private keys stay in Android's encrypted storage and the macOS Keychain.

The project also tackles Android's fragmentation head-on: vendor ROMs from Xiaomi, OPPO, vivo, and Honor require extra permissions for notification SMS or background activity, and the author documents each one. A fallback notification-reader channel only ingests the default SMS app to avoid overreach. The Mac advertises its receiver via Bonjour/DNS-SD, so Android auto-discovers it without typing an IP. Both ends show paired status, service availability, and recent operation states to cut down guesswork when codes don't arrive.

No cloud server, no account system, and no upload of full SMS. The tradeoff is that both devices must be on the same LAN, and the phone's credential storage must be unlocked after reboot before relay works again. The project is open source with a 28-second demo video and a published APK and macOS app.

Takeaways
— The Android app extracts 4-8 digit codes locally, matching keywords like 验证码, OTP, code, and passcode.
— Only the code and sender name are sent to the Mac; full SMS is never uploaded.
— Pairing uses a one-time QR token valid for five minutes, then invalidated.
— Private keys are stored in macOS Keychain and Android encrypted storage and never cross the network.
— Encryption stack: P-256 ECDH, HKDF-SHA256 (32-byte session key), AES-256-GCM with device ID as additional authenticated data.
— Mac discovers the receiver via Bonjour/DNS-SD; Android uses NsdManager, so no manual IP/port entry.
— Chinese OEM ROMs from Xiaomi, OPPO, vivo, and Honor often require extra notification-SMS and background activity permissions; the project documents each.
— After a phone reboot, the relay works only after the first unlock because Android's credential-encrypted storage is unavailable until then.
Conclusions

The author's decision to avoid any cloud server stems from the sensitivity of SMS content, a reasonable trade for a personal tool that forces same-LAN operation. That constraint is acceptable when the phone and Mac are physically together, which is the whole point of the relay.

The most time-consuming part isn't the cryptography but Android's vendor-specific background execution policies. This is a recurring reality for any Android automation tool, and the author turned it into documentation instead of fighting it.

The notification-read fallback deliberately restricts itself to the default SMS app, acknowledging that notification access is too powerful to scan broadly. That's a responsible privacy choice, even if it limits compatibility.

Concepts & terms
ECDH (Elliptic Curve Diffie-Hellman)
A key exchange protocol where two parties each generate a public/private key pair and combine their private key with the peer's public key to derive a shared secret over an insecure channel.
HKDF (HMAC-based Key Derivation Function)
A function that takes a shared secret and derives one or more cryptographically strong keys, using salt and optional context info.
AES-GCM
An authenticated encryption mode that simultaneously provides confidentiality and integrity verification via Galois/Counter Mode.
Bonjour/DNS-SD
Apple's zero-configuration networking implementation that lets devices advertise and discover services over a local network using multicast DNS and Service Discovery.
From the discussion
Featured comments
season_zhu

Actually, many Android vendors already have apps on the Mac side for phone–Mac syncing, but the key apps are all really large. With this app, I think the tricky part is still Android app background persistence: sometimes even after you've granted all permissions and fully allowed background activity, there can still be anomalies. Also, consider splitting the APK workflow into separate v7 and v8 builds to further reduce the package size.

Karl_fang

What are the specific signs of this anomaly?

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗