73682a92c79c
verify both PeachScript directions (browser->Android KAT in suite; Android export parsed by the browser's own parsePayload) and finalize BROWSER-SPEC integration contract; 104 tests green, assembleDebug+lintDebug pass
- time
- 2026-06-09 16:34 UTC · 5 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- cross-platform recovery and peachscript parity
- parent
- 1148aa0e29cf
↓ peach-android-73682a92.tar.gzatlas at this save
files changed2 files
app/drafts/MF1MF2/BROWSER-SPEC.md+17 −1app/drafts/MF1MF2/parse_android_export.mjs+22 −0app/drafts/MF1MF2/BROWSER-SPEC.md+17 −1
@@ -382,6 +382,18 @@382382 - **AES-256-GCM**: JCE `AES/GCM/NoPadding`, 12-byte nonce, 128-bit tag. The383383 PeachScript envelope uses **no AAD** (unlike the vault slots).384384 385+### [ANDROID BUG FOUND + FIXED] `rootKeyToWords` checksum sign-extension386+The cross-platform KAT surfaced a pre-existing Android bug: `RecoveryWords.kt`387+computed the BIP39 checksum as `entropyHash[0].toInt() ushr 4`. A `Byte` ≥ 0x80388+sign-extends to a negative `Int`, so the unsigned shift produced a 28-bit value389+instead of the 4-bit checksum — corrupting `rootKeyToWords` (and390+`wordsToRootKeyMaterial`'s check) for ~50% of root keys (those whose391+`SHA-256(entropy16)[0] >= 0x80`). It was latent because the old escrow keyed off392+BLAKE3 and never used `wordsToRootKeyMaterial`. Fixed to393+`(entropyHash[0].toInt() and 0xff) ushr 4` (browser parity, `recovery-words.ts:36`).394+Without this, no Android recovery word would match the browser. Both occurrences395+fixed (`rootKeyToWords`, `wordsToRootKeyMaterial`).396+385397 ### [SHARED LATENT BUG] duplicate-`abandon` root keys (~0.6%)386398 The browser's `createVault` (`vault.ts:947`) and `migrateToRecovery`387399 (`vault.ts:511`) call `generateAndWrapRootKey` with no retry, so ~0.6% of random@@ -443,8 +455,12 @@443455 444456 ### New dependency (`app/build.gradle`)445457 ```gradle446-implementation 'com.github.luben:zstd-jni:1.5.6-3'458+implementation "com.github.luben:zstd-jni:1.5.6-3@aar" // Android jniLibs (lib/<abi>/*.so)459+testImplementation "com.github.luben:zstd-jni:1.5.6-3" // desktop natives for host unit tests447460 ```461+The plain jar bundles only desktop natives (would `UnsatisfiedLinkError` on-device);462+the `@aar` ships the Android `.so`. Both are needed: the AAR for the device, the jar463+for JVM unit tests. Verified: APK contains `lib/{arm64-v8a,armeabi-v7a,x86,x86_64}/libzstd-jni-1.5.6-3.so`.448464 No `AndroidManifest.xml` changes.449465 450466 ### Integration orderapp/drafts/MF1MF2/parse_android_export.mjs+22 −0
@@ -0,0 +1,22 @@1+import { createServer } from "/Users/june/projects/peach-browser/node_modules/vite/dist/node/index.js";2+import { readFileSync } from "node:fs";3+4+const server = await createServer({5+ root: "/Users/june/projects/peach-browser",6+ configFile: false, logLevel: "silent",7+ server: { middlewareMode: true, hmr: false },8+});9+try {10+ const { parsePayload } = await server.ssrLoadModule("/src/crypto/peachPayload.ts");11+ const b64 = readFileSync("/tmp/android_export.b64", "utf8").trim();12+ const bytes = new Uint8Array(Buffer.from(b64, "base64"));13+ const parsed = await parsePayload(bytes, "android-pw");14+ console.log("BROWSER PARSED ANDROID EXPORT:", parsed.entries.length, "entries");15+ console.log(JSON.stringify(parsed.entries.map((e) => ({16+ type: e.type, title: e.title, username: e.username, password: e.password,17+ email: e.email, tags: e.tags, breach: e.breach, network: e.network,18+ cardNumber: e.cardNumber, notes: e.notes, canary: e.canary,19+ })), null, 2));20+} finally {21+ await server.close();22+}