Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
README: what prod.keys is, where to put it, and how it is used
LNPANDY34e360f40d3a
diff --git a/README.md b/README.mdindex 97a4b414..c876b4b2 100644--- a/README.md+++ b/README.md@@ -65,9 +65,50 @@ brew install --cask dotnet-sdkpython3 -m pip install lz4 capstone fonttools backports.zstd```+### 2. What you need on disk++Three things, none of which ship with the repository:++| What | Where it comes from | Used by |+|---|---|---|+| **`prod.keys`** | dumped from **your own console** (see below) | the extractor, to decrypt your game |+| **The game's NSPs** | dumped from your own cartridge or eShop purchases | the extractor |+| **Xcode + iOS SDK** | the App Store | the app build |++`prod.keys` is the console's key set — a text file of `name = hex value` lines (~230 entries:+`master_key_xx`, `titlekek_xx`, `header_key`, `key_area_key_application_xx`, …). Every Switch+homebrew tool reads this format. It is **not** tied to a specific game: one `prod.keys` decrypts+any of your games. The only requirement is that the file contains keys for the key generation+(firmware era) the game was packaged with — a current dump covers every retail game.++Where to put it is up to you; you pass the path with `-k`:++```bash+# any layout works, e.g.+~/keys/prod.keys+# or keep it beside the game's NSPs+~/Games/Hades2/prod.keys+```++```bash+python3 scripts/build_ipa_from_nsp.py ~/Games/Hades2 -k ~/keys/prod.keys+```++How keys are dumped is documented across the Switch homebrew community (Lockpick_RCM from a+hacked console is the usual route); this repository does not cover that step and ships none of+it. Two practical notes from real dumps:++- **Malformed lines.** Some dumpers emit lines whose hex value has the wrong length (33 bad+ `master_kek_source_*` lines in one real dump), which makes the extraction tool refuse the whole+ file. Delete the offending lines and keep a backup of the original.+- **Updates.** An update NSP's ticket may carry a newer key generation than the base game's. The+ extractor reads the title key straight from the common ticket inside each NSP, so in practice+ both decrypt fine as long as `prod.keys` is reasonably current — verified here with a base+ game on generation 15 and its update on 16, using a keys file that only reached 15.+`backports.zstd` is needed for Tears of the Kingdom's zstd dictionaries; other games do not use it.-### 2. Pack the RomFS into an archive+### 3. Pack the RomFS into an archive```bashpython3 dm/tools/romfs_arc.py pack <RomFS dir> <output base> --shard-mib 200@@ -84,7 +125,7 @@ python3 dm/tools/romfs_arc.py verify <base> <RomFS dir> # byte-compares everypython3 dm/tools/romfs_arc.py list <base> [path] # list one directory```-### 3. Build the IPA without the RomFS+### 4. Build the IPA without the RomFS```bashDM_NO_ROMFS=1 GAME=<title id> W=<work dir> PATCHED=<patched dir> \@@ -94,7 +135,7 @@ DM_NO_ROMFS=1 GAME=<title id> W=<work dir> PATCHED=<patched dir> \Without `DM_NO_ROMFS=1` the script behaves exactly as upstream (the RomFS goes into the package).-### 4. Copy the archive to the phone+### 5. Copy the archive to the phonePut the whole set in the app's `Documents/romfs/`, keeping the base name:diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 83139241..5e3c2d96 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -61,7 +61,44 @@ python3 -m pip install lz4 capstone fonttools backports.zstd`backports.zstd` 是《王国之泪》的 zstd 字典需要的;其他游戏用不到。-### 2. 把 RomFS 打包成归档+### 2. 你需要准备的文件++三样东西,仓库里都不带:++| 内容 | 来源 | 用途 |+|---|---|---|+| **`prod.keys`** | 从**你自己的机器**导出(见下) | 解密你的游戏 |+| **游戏的 NSP** | 从你自己的卡带或 eShop 购买记录导出 | 供解包 |+| **Xcode + iOS SDK** | App Store | 构建 App |++`prod.keys` 是主机的密钥集——一个 `名字 = 十六进制值` 格式的文本文件(约 230 条:+`master_key_xx`、`titlekek_xx`、`header_key`、`key_area_key_application_xx`……)。所有 Switch+自制软件工具都读这个格式。它**不和某个游戏绑定**:一份 `prod.keys` 能解你所有的游戏。唯一+要求是文件里包含游戏打包时代(固件世代)对应的密钥——新导出的一份覆盖所有零售游戏。++放在哪里随意,用 `-k` 传路径即可:++```bash+# 任意布局,比如+~/keys/prod.keys+# 或者就放在游戏 NSP 旁边+~/Games/Hades2/prod.keys+```++```bash+python3 scripts/build_ipa_from_nsp.py ~/Games/Hades2 -k ~/keys/prod.keys+```++密钥的导出方式在 Switch 自制软件社区有完整文档(常见做法是在破解机上跑 Lockpick_RCM);+本仓库不涉及也不携带这一步。两条来自真实导出文件的实用提示:++- **格式错误的行。** 有的导出工具会写出十六进制值长度不对的行(真实案例:33 行长度错误的+ `master_kek_source_*`),解包工具会因此拒绝整个文件。删掉这些行,原文件留个备份。+- **更新包。** 更新 NSP 的 ticket 可能带比本体更新的密钥世代。解包工具直接从每个 NSP 内部的+ common ticket 读 title key,所以实际使用中只要 `prod.keys` 不算太旧,两份都能解开——这里+ 实测过本体是世代 15、更新是世代 16,keys 文件只到 15,两个包都正常解出。++### 3. 把 RomFS 打包成归档```bashpython3 dm/tools/romfs_arc.py pack <RomFS 目录> <输出基路径> --shard-mib 200@@ -78,7 +115,7 @@ python3 dm/tools/romfs_arc.py verify <基路径> <RomFS 目录> # 逐字节比python3 dm/tools/romfs_arc.py list <基路径> [路径] # 列出某个目录```-### 3. 构建不含 RomFS 的 IPA+### 4. 构建不含 RomFS 的 IPA```bashDM_NO_ROMFS=1 GAME=<title id> W=<工作目录> PATCHED=<改写目录> \@@ -88,7 +125,7 @@ DM_NO_ROMFS=1 GAME=<title id> W=<工作目录> PATCHED=<改写目录> \不设 `DM_NO_ROMFS=1` 时,脚本行为与上游完全一致(RomFS 进包)。-### 4. 把归档拷到手机+### 5. 把归档拷到手机整套放进 App 的 `Documents/romfs/`,保持基名不变: