math-skill 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en-US.md CHANGED
@@ -2,9 +2,7 @@
2
2
  <a href="README.md">中文</a> | <a href="README.en-US.md">English</a>
3
3
  </p>
4
4
 
5
- # 📐 Math Skill A Mathematical Research Operating System for AI Architecture Design
6
-
7
- > **The thinking system does not hand out theorems. The knowledge system does not improvise inspiration. The design layer does not fake profundity.**
5
+ # 📐 Math Skill: A Mathematical Research Operating System for AI and Cryptography Innovation
8
6
 
9
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
8
  [![npm version](https://img.shields.io/npm/v/math-skill.svg)](https://www.npmjs.com/package/math-skill)
@@ -16,6 +14,14 @@
16
14
 
17
15
  ---
18
16
 
17
+ ## 📢 Community Announcements
18
+
19
+ > **This skill is under rapid iteration — your feedback and suggestions are warmly welcome!** Your input is the core driver of our continuous evolution. Feel free to reach out via GitHub Issues or Discussions.
20
+
21
+ > **v3.2.0 is live**: The cryptography track is officially integrated — 3 distilled classics of modern cryptography (Boneh-Shoup / Goldreich / Katz-Lindell) plus a Domain Router layer. AI and cryptography share mathematical foundations but each has exclusive specialty layers, with no cross-domain pollution. See the changelog for details.
22
+
23
+ ---
24
+
19
25
  ## Inspiration
20
26
 
21
27
  The story of Sophus Lie forging a "dragon-slaying blade" tells us this: the Lie group–Lie algebra machinery invented to solve differential equations ended up becoming the lingua franca for describing symmetry and robot state estimation — the value of a mathematical tool far outlives its original intent, which is exactly the prototype of "cross-domain activation." See [`references/inspiration.en.md`](references/inspiration.en.md).
@@ -58,9 +64,22 @@ Critic: Mathematically sound? Engineering-feasible?
58
64
  | **Design Translation** | Bridge math to AI modules/losses/operators | `design-patterns/*/*.md` | 22 |
59
65
 
60
66
  Supporting layers:
61
- - `references/books/*.md`: 7 book distillations for deep context
67
+ - `references/books/*.md`: 10 book distillations (7 AI-direction + 3 cryptography-direction) for deep context
62
68
  - `references/gpu-friendly-math.en.md`: GPU 8-dimension acceptance gate
63
- - `agents/math-critic.en.md`: Math-engineering dual critic
69
+ - `agents/math-critic.en.md`: Math-engineering dual critic (19 dimensions, including cryptographic security review)
70
+
71
+ ### Domain Router (new in v3.2.0)
72
+
73
+ AI research and cryptography **share** mathematical foundations (probability/information/algebra/matrix/spectrum/optimization) but each has **exclusive** specialty layers. After intent diagnosis and before lens invocation, Domain Router determines the problem's domain and decides which anchors/books/design patterns to load, avoiding cross-domain pollution and token waste.
74
+
75
+ | Domain | Loaded Content | Signal Keywords |
76
+ |--------|----------------|------------------|
77
+ | **AI Research** | `knowledge-base/` (7 domains, 31 anchors) + `design-patterns/` (5 types, 22 patterns) + 7 AI books | attention/loss/routing/representation/compression/MoE/transformer/KV-cache/LoRA/SSM/diffusion/RL |
78
+ | **Cryptography** | 3 crypto books + shared math anchors (on demand) | encryption/signature/MAC/PRF/PRG/PRP/OWF/CCA/CPA/AE/ZK/reduction/DL/CDH/DDH/RSA/ECC/lattice |
79
+ | **Pure Math** | `lenses/` + corresponding `knowledge-base/` anchors | probability/information/entropy/group/ring/field/matrix/spectrum/optimization/convexity/perturbation/complexity |
80
+ | **AI×Crypto** | dual-domain load + intersection annotation | "PRF for watermarking," "adversarial example reduction," "verifiable inference" |
81
+
82
+ > Rules: domain judgment precedes lens invocation; shared math is not redundantly loaded; no pollution across non-cross domains; gap-protocol temporary cards are domain-tagged.
64
83
 
65
84
  ### 15 Thinking Lenses
66
85
 
@@ -198,11 +217,11 @@ math-skill/
198
217
  │ ├── representation/ # Representation (4 patterns)
199
218
  │ └── compression/ # Compression (4 patterns)
200
219
  ├── references/ # Reference layer
201
- │ ├── books/ # 7 book distillations
220
+ │ ├── books/ # 10 book distillations (7 AI + 3 crypto)
202
221
  │ ├── gpu-friendly-math.en.md # GPU 8-dimension gate
203
222
  │ ├── agentic-workflow.en.md # Collaboration style
204
223
  │ └── inspiration.en.md # Inspiration
205
- ├── agents/math-critic.en.md # Math-engineering dual critic
224
+ ├── agents/math-critic.en.md # Math-engineering dual critic (19 dims, with crypto security review)
206
225
  ├── commands/ask.en.md # /ask manual entry
207
226
  ├── math_book/ # Local PDFs (not published)
208
227
  └── README.md / LICENSE
@@ -212,6 +231,8 @@ math-skill/
212
231
 
213
232
  ## Recommended Books
214
233
 
234
+ ### AI Direction (7 books)
235
+
215
236
  | # | Title | Author(s) | Publisher / Edition | Year | ISBN | Distillation |
216
237
  |---|-------|-----------|-------------------|------|------|-------------|
217
238
  | 1 | *Contemporary Abstract Algebra* | Joseph A. Gallian | Brooks/Cole, Cengage, 8th ed. | 2013 | 978-1-133-59971-5 | `abstract-algebra.en.md` |
@@ -222,12 +243,38 @@ math-skill/
222
243
  | 6 | *An Introduction to Optimization, With Applications to ML* | Chong, Lu, Żak | John Wiley & Sons, 5th ed. | 2024 | 978-1-119-87763-9 | `optimization-ml.en.md` |
223
244
  | 7 | *Introduction to Smooth Manifolds* | John M. Lee | Springer, GTM 218, 2nd ed. | 2013 | 978-1-4419-9981-8 | `smooth-manifolds.en.md` |
224
245
 
246
+ ### Cryptography Direction (3 books, new in v3.2.0)
247
+
248
+ | # | Title | Author(s) | Publisher / Edition | Year | ISBN | Distillation |
249
+ |---|-------|-----------|-------------------|------|------|-------------|
250
+ | 8 | *A Graduate Course in Applied Cryptography* | Dan Boneh & Victor Shoup | v0.4 online | 2017 | — | `applied-cryptography.md` |
251
+ | 9 | *Foundations of Cryptography, Volume 1: Basic Tools* | Oded Goldreich | Cambridge University Press | 2001 | 978-0-521-79235-9 | `foundations-of-cryptography.md` |
252
+ | 10 | *Introduction to Modern Cryptography* | Jonathan Katz & Yehuda Lindell | CRC Press, 2nd ed. | 2015 | 978-1-4665-7026-1 | `introduction-to-modern-cryptography.md` |
253
+
254
+ > Crypto book contents are already in English, so they use the `.md` suffix (no CN/EN split). They are loaded when Domain Router determines the problem is cryptography or AI×crypto intersection.
255
+
225
256
  Distillation files ship with the npm package. For full-fidelity lookups, place PDFs in the `math_book/` folder.
226
257
 
227
258
  ---
228
259
 
229
260
  ## Changelog
230
261
 
262
+ ### v3.2.0 — Cryptography Track + Domain Router
263
+
264
+ **Cryptography track officially landed**: reference layer expanded from 7 to 10 books, with 3 modern cryptography classics distilled into the same activation-index format as AI-direction books (~125-155 lines each, preserving core ideas and key bridging facts).
265
+
266
+ - **3 new crypto books**:
267
+ - `references/books/applied-cryptography.md` (Boneh & Shoup): attack games / reduction proofs / constructions / protocols
268
+ - `references/books/foundations-of-cryptography.md` (Goldreich): computational indistinguishability / OWF-PRG-PRF equivalence chain / simulation paradigm / meta-theorems
269
+ - `references/books/introduction-to-modern-cryptography.md` (Katz & Lindell): formal definitions / CPA-CCA-AE / construction paradigms / implementation pitfalls
270
+ - **Domain Router** (core innovation): after intent diagnosis and before lens invocation, judges problem domain (AI/Crypto/pure-math/intersection), loads domain-specific content, shared math not redundantly loaded, avoids cross-domain pollution and token waste
271
+ - **SKILL.md / SKILL.en.md**: new Domain Router section + routing rules + decision flow diagram; main workflow integrates domain tags and domain-specific routing (AI uses design-patterns + GPU gate; crypto uses reduction templates + assumption/pitfall checks)
272
+ - **math-critic upgraded to 19 dimensions**: new dim 19 "Cryptographic Security Review" (security definitions / reduction tightness / assumption dependency / composition pitfalls / anti-patterns / cross-domain transfer validity / Domain Router consistency)
273
+ - **skill-index / overview**: added Domain Router overview table and crypto book activation-family tags; overview gained Domain Router loading note
274
+ - **Token optimization**: crypto books compressed from 2084 to 404 lines (~80% reduction); Domain Router trims output by domain, avoiding full-load; output format emphasizes "after domain judgment, only expand the domain-specific subsection". Quantified estimate: pure AI problems skip the 3 crypto books entirely (saving ~400 lines/call), pure crypto problems skip all 22 AI design-patterns (saving ~2200-3300 lines/call); the crypto books' own compression saves another ~872 lines/call
275
+ - **File cleanup**: removed duplicate `SKILL.md/SKILL.en.md/original-texts.md/original-texts.en.md` mistakenly placed in repo root by the contributor (canonical versions live in `skills/math-research-activator/`); fixed SKILL relative paths in `agents/math-critic.{en,}.md` and `knowledge-base/overview.en.md`
276
+ - **AI/Cryptography isolation guarantee**: Domain Router rule 4 explicitly states "pure AI problems do not load crypto books; pure crypto problems do not load AI design patterns," preventing conceptual confusion at the loading layer
277
+
231
278
  ### v3.1.1 — Terminology Consistency Cleanup
232
279
 
233
280
  - **skill-index alignment**: title, knowledge base section, and workflow example updated from "knowledge base / knowledge query" to "activation anchors"
package/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
  <a href="README.md">中文</a> | <a href="README.en-US.md">English</a>
3
3
  </p>
4
4
 
5
- # 📐 Math Skill 面向 AI 架构创新的数学研究操作系统
6
-
7
- > **思想系统不负责给定理,知识系统不负责乱启发,设计层不负责装深刻。**
5
+ # 📐 Math Skill: 面向 AI 与密码学创新的数学研究操作系统
8
6
 
9
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
8
  [![npm version](https://img.shields.io/npm/v/math-skill.svg)](https://www.npmjs.com/package/math-skill)
@@ -16,6 +14,14 @@
16
14
 
17
15
  ---
18
16
 
17
+ ## 📢 社区公告
18
+
19
+ > **本 Skill 正在快速迭代中,欢迎各位使用者提出宝贵的使用感受和改进建议!** 你的反馈是我们持续进化的核心动力。欢迎通过 GitHub Issues 或 Discussions 与我们交流。
20
+
21
+ > **v3.2.0 已上线**:密码学方向正式接入——3 本现代密码学经典(Boneh-Shoup / Goldreich / Katz-Lindell)精简蒸馏稿 + Domain Router 路由层,AI 与密码学共享数学根基、独有专业层,互不污染。详见变更日志。
22
+
23
+ ---
24
+
19
25
  ## 灵感来源
20
26
 
21
27
  Sophus Lie 打造"屠龙刀"的故事告诉我们:为解微分方程发明的李群-李代数,最终成为描述对称性、机器人状态估计的通用语言——数学工具的价值远超初衷,这正是「跨领域激活」的原型。详见 [`references/inspiration.md`](references/inspiration.md)。
@@ -58,9 +64,22 @@ Sophus Lie 打造"屠龙刀"的故事告诉我们:为解微分方程发明的
58
64
  | **设计翻译** | 把数学变成 AI 模块/loss/算子 | `design-patterns/*/*.md` | 22 |
59
65
 
60
66
  辅助层:
61
- - `references/books/*.md`:7 本书蒸馏稿,需要深入时的完整上下文
67
+ - `references/books/*.md`:10 本书蒸馏稿(7 本 AI 方向 + 3 本密码学方向),需要深入时的完整上下文
62
68
  - `references/gpu-friendly-math.md`:GPU 八维验收门
63
- - `agents/math-critic.md`:数学-工程双重批判器
69
+ - `agents/math-critic.md`:数学-工程双重批判器(19 维,含密码学安全审视)
70
+
71
+ ### Domain Router(v3.2.0 新增)
72
+
73
+ AI 研究与密码学**共享**数学根基(概率/信息/代数/矩阵/谱/优化),但**独有**各自专业层。Domain Router 在意图诊断后、调用透镜前,先判定问题归属,决定加载哪些锚点/书稿/设计模式,避免跨域污染与 token 浪费。
74
+
75
+ | Domain | 加载内容 | 信号词 |
76
+ |--------|---------|--------|
77
+ | **AI 研究** | `knowledge-base/`(7 领域 31 锚点)+ `design-patterns/`(5 类 22 模式)+ AI 方向 7 本书 | attention/loss/routing/representation/compression/MoE/transformer/KV-cache/LoRA/SSM/扩散/RL |
78
+ | **密码学** | 3 本密码学书稿 + 共用数学锚点(按需) | 加密/签名/MAC/PRF/PRG/PRP/OWF/CCA/CPA/AE/零知识/归约/DL/CDH/DDH/RSA/ECC/格密码 |
79
+ | **纯数学** | `lenses/` + `knowledge-base/` 对应锚点 | 概率/信息/熵/群/环/域/矩阵/谱/优化/凸性/扰动/复杂度 |
80
+ | **AI×密码交叉** | 双 domain 加载 + 交叉点标注 | "PRF 做模型水印""对抗样本归约""可验证推理" |
81
+
82
+ > 规则:domain 判定先于透镜调用;共用数学不重复加载;不跨域时不污染;缺口协议临时卡标注 domain。
64
83
 
65
84
  ### 15 个思想透镜
66
85
 
@@ -198,11 +217,11 @@ math-skill/
198
217
  │ ├── representation/ # 表示(4 模式)
199
218
  │ └── compression/ # 压缩(4 模式)
200
219
  ├── references/ # 参考层
201
- │ ├── books/ # 7 本书蒸馏稿
220
+ │ ├── books/ # 10 本书蒸馏稿(7 AI + 3 密码学)
202
221
  │ ├── gpu-friendly-math.md # GPU 八维验收门
203
222
  │ ├── agentic-workflow.md # 协作方式
204
223
  │ └── inspiration.md # 灵感来源
205
- ├── agents/math-critic.md # 数学-工程双重批判器
224
+ ├── agents/math-critic.md # 数学-工程双重批判器(19 维,含密码学安全审视)
206
225
  ├── commands/ask.md # /ask 手动入口
207
226
  ├── math_book/ # 本地 PDF(不发布)
208
227
  └── README.md / LICENSE
@@ -212,6 +231,8 @@ math-skill/
212
231
 
213
232
  ## 推荐书目
214
233
 
234
+ ### AI 方向(7 本)
235
+
215
236
  | # | 书名 | 作者 | 出版社 / 版次 | 年份 | ISBN | 蒸馏文件 |
216
237
  |---|------|------|-------------|------|------|---------|
217
238
  | 1 | *Contemporary Abstract Algebra* | Joseph A. Gallian | Brooks/Cole, Cengage, 8th ed. | 2013 | 978-1-133-59971-5 | `abstract-algebra.md` |
@@ -222,12 +243,38 @@ math-skill/
222
243
  | 6 | *An Introduction to Optimization, With Applications to ML* | Chong, Lu, Żak | John Wiley & Sons, 5th ed. | 2024 | 978-1-119-87763-9 | `optimization-ml.md` |
223
244
  | 7 | *Introduction to Smooth Manifolds* | John M. Lee | Springer, GTM 218, 2nd ed. | 2013 | 978-1-4419-9981-8 | `smooth-manifolds.md` |
224
245
 
246
+ ### 密码学方向(3 本,v3.2.0 新增)
247
+
248
+ | # | 书名 | 作者 | 出版社 / 版次 | 年份 | ISBN | 蒸馏文件 |
249
+ |---|------|------|-------------|------|------|---------|
250
+ | 8 | *A Graduate Course in Applied Cryptography* | Dan Boneh & Victor Shoup | v0.4 在线版 | 2017 | — | `applied-cryptography.md` |
251
+ | 9 | *Foundations of Cryptography, Volume 1: Basic Tools* | Oded Goldreich | Cambridge University Press | 2001 | 978-0-521-79235-9 | `foundations-of-cryptography.md` |
252
+ | 10 | *Introduction to Modern Cryptography* | Jonathan Katz & Yehuda Lindell | CRC Press, 2nd ed. | 2015 | 978-1-4665-7026-1 | `introduction-to-modern-cryptography.md` |
253
+
254
+ > 密码学书稿正文为英文,沿用 `.md` 后缀(不分中英);Domain Router 判定为密码学或 AI×密码交叉时加载。
255
+
225
256
  蒸馏文件已随 npm 包发布。如需全保真原文,将 PDF 放入 `math_book/` 文件夹即可。
226
257
 
227
258
  ---
228
259
 
229
260
  ## 变更日志
230
261
 
262
+ ### v3.2.0 — 密码学方向接入 + Domain Router
263
+
264
+ **密码学方向正式落地**:参考层从 7 本扩到 10 本,新增 3 本现代密码学经典蒸馏稿,精简为与 AI 方向书稿一致的激活索引格式(约 125-155 行/本,保留核心思想与关键桥接事实)。
265
+
266
+ - **新增 3 本密码学书稿**:
267
+ - `references/books/applied-cryptography.md`(Boneh & Shoup):攻击游戏/归约证明/构造/协议
268
+ - `references/books/foundations-of-cryptography.md`(Goldreich):计算不可区分/OWF-PRG-PRF 等价链/模拟范式/元定理
269
+ - `references/books/introduction-to-modern-cryptography.md`(Katz & Lindell):形式化定义/CPA-CCA-AE/构造范式/实现陷阱
270
+ - **Domain Router 路由层**(核心创新):在意图诊断后、透镜调用前判定问题 domain(AI/密码/纯数学/交叉),按 domain 加载专属内容,共用数学不重复加载,避免跨域污染与 token 浪费
271
+ - **SKILL.md / SKILL.en.md**:新增 Domain Router 小节 + 路由规则 + 判定流程图;主流程整合 domain 标注与 domain-specific 路由(AI 走 design-patterns + GPU 门,密码走归约模板 + 假设/陷阱检查)
272
+ - **math-critic 升级为 19 维**:新增第 19 维「密码学安全审视」(安全定义/归约紧度/假设依赖/合成陷阱/反模式/跨域迁移合理性/Domain Router 一致性)
273
+ - **skill-index / overview**:补 Domain Router 总览表与密码学书稿激活家族标注;overview 增 Domain Router 加载提示
274
+ - **Token 优化**:密码学书稿从 2084 行精简到 404 行(压缩 ~80%);Domain Router 按 domain 裁剪输出,避免全量加载;输出格式强调"domain 判定后只展开该 domain 专属小节"。量化估算:纯 AI 问题完全不加载 3 本密码学书稿(省约 400 行/次),纯密码学问题完全不加载 22 个 AI design-patterns(省约 2200-3300 行/次);密码学书稿本身的精简再省约 872 行/次
275
+ - **文件清理**:删除朋友误放在根目录的重复 `SKILL.md/SKILL.en.md/original-texts.md/original-texts.en.md`(权威版本在 `skills/math-research-activator/`);修正 `agents/math-critic.{en,}.md` 与 `knowledge-base/overview.en.md` 中的 SKILL 相对路径
276
+ - **AI 与密码学隔离保证**:Domain Router 规则 4 明确"纯 AI 问题不加载密码学书稿;纯密码学问题不加载 AI 设计模式",从加载层防止概念混淆
277
+
231
278
  ### v3.1.1 — 术语闭环清洁
232
279
 
233
280
  - **skill-index 口径统一**:标题、知识库小节、工作流范例从"知识库/知识查询"改为"激活锚点"
@@ -26,7 +26,7 @@ You should give equal weight to two categories of responsibility: on one hand, s
26
26
 
27
27
  ## Review Dimensions
28
28
 
29
- The first 15 dimensions cover the core review angles — assumptions, logic, models, computation — most of which correspond to the v3 thinking lenses in `../lenses/`; Dimensions 16–18 are cross-cutting: tool selection, GPU feasibility, and modern math activation. **Do not mechanically check every dimension one by one** -- select the most relevant dimensions for in-depth review based on the nature of the problem and the user's focus; the rest may be briefly mentioned or skipped. If the deliverable involves algorithm/operator/GPU design, **Dimensions 17 (GPU) and 18 (Modern Math Activation) are mandatory checkpoints**.
29
+ The first 15 dimensions cover the core review angles — assumptions, logic, models, computation — most of which correspond to the v3 thinking lenses in `../lenses/`; Dimensions 16–19 are cross-cutting: tool selection, GPU feasibility, modern math activation, and cryptographic security. **Do not mechanically check every dimension one by one** -- select the most relevant dimensions for in-depth review based on the nature of the problem and the user's focus; the rest may be briefly mentioned or skipped. If the deliverable involves algorithm/operator/GPU design, **Dimensions 17 (GPU) and 18 (Modern Math Activation) are mandatory checkpoints**; if the deliverable involves cryptographic constructions / security proofs / protocols, **Dimension 19 (Cryptographic Security) is a mandatory checkpoint**.
30
30
 
31
31
  ### 1. Assumption Review -> axiomatization lens
32
32
 
@@ -151,13 +151,25 @@ The first 15 dimensions cover the core review angles — assumptions, logic, mod
151
151
  - Is the transfer a "cross-domain activation" (the structure already exists; only a cross-domain mapping is missing), or is it a forced transplant (borrowing terminology without borrowing structure)?
152
152
  - Does the deliverable simultaneously pass the **dual-acceptance gate**: mathematically correct **AND** (friendly or retrofittable on the eight dimensions)? Are candidates that fail either criterion eliminated?
153
153
 
154
+ ### 19. Cryptographic Security Review -> `../references/books/` (3 crypto books)
155
+
156
+ > **Mandatory** when the deliverable involves cryptographic constructions / security proofs / protocol design (triggered when Domain Router determines the problem is cryptography or AI×crypto intersection). Corresponds to the cryptographic version of the "dual-acceptance gate": security definitions correct **AND** reduction tightness acceptable.
157
+
158
+ - **Security definitions**: Is the security goal defined via a formal attack game? Does the threat-model tier (CPA/CCA/AE/EUF-CMA) match the requirement? Avoid "intuitively secure" hand-waving.
159
+ - **Reduction tightness**: How large is Q in the reduction loss ε_scheme ≈ Q·ε_assumption? Are parameters compensated? Does the proof claim "loose reduction = secure"?
160
+ - **Assumption dependency**: Which assumption does the scheme rely on (OWF/DL/CDH/DDH/RSA/LWE)? Is it minimized? Are black-box separation results relevant? Does it need upgrading under quantum threats (Shor/Grover)?
161
+ - **Composition & implementation pitfalls**: Is EtM/MtE/EaM chosen correctly? Are keys independent? Are IVs/nonces unique? Is MAC comparison constant-time? Is context (identity/transcript) bound?
162
+ - **Anti-pattern check**: Is ROM treated as an absolute guarantee? Is deterministic encryption treated as CPA-secure? Is Merkle-Damgård treated as ROM? Plain RSA signatures?
163
+ - **Cross-domain transfer validity** (AI×crypto only): When transferring cryptographic concepts to ML (e.g., PRF for watermarking, reductions for robustness certificates), are security semantics preserved, or is only terminology borrowed? Are assumptions still achievable after transfer?
164
+ - **Domain Router consistency**: Does a pure crypto problem avoid loading AI design-patterns? Does a pure AI problem avoid loading crypto books? Does an intersection problem load both and annotate intersection points?
165
+
154
166
  ## Workflow
155
167
 
156
168
  ### Review Phase
157
169
 
158
170
  1. **Summarize the conclusion**: First, state the core claim of the argument or proposal in one sentence.
159
171
  2. **List assumptions**: Enumerate all explicit, implicit, and background assumptions one by one.
160
- 3. **Select dimensions**: Based on the nature of the problem, choose the 3-5 most relevant review dimensions from the eighteen for in-depth inspection; if algorithm/GPU design is involved, **Dimensions 17 and 18 are mandatory**. The remaining dimensions may be briefly mentioned or skipped.
172
+ 3. **Select dimensions**: Based on the nature of the problem, choose the 3-5 most relevant review dimensions from the nineteen for in-depth inspection; if algorithm/GPU design is involved, **Dimensions 17 and 18 are mandatory**; if cryptography is involved, **Dimension 19 is mandatory**. The remaining dimensions may be briefly mentioned or skipped.
161
173
  4. **Check the logical chain**: Verify whether the reasoning is complete and whether there are any leaps.
162
174
  5. **Apply the dual-acceptance gate**: For each candidate deliverable, separately assess mathematical correctness and GPU feasibility; retain only those that pass both.
163
175
  6. **Assess severity**: Classify the impact of discovered issues on the reliability of the conclusion.
@@ -181,7 +193,7 @@ The structure below is the full-report template, not the default response. For s
181
193
  ### Review Section
182
194
 
183
195
  #### Dimensions Focused on in This Review
184
- - [List the 3-5 dimensions selected for in-depth review and the rationale; if algorithm/GPU is involved, note that Dimensions 17/18 are included]
196
+ - [List the 3-5 dimensions selected for in-depth review and the rationale; if algorithm/GPU is involved, note that Dimensions 17/18 are included; if cryptography is involved, note that Dimension 19 is included]
185
197
 
186
198
  #### Dual-Acceptance Gate Results
187
199
  - [Candidate 1]: Math correctness [pass/fail] | GPU eight-dimension [friendly / retrofittable / unfriendly] | Passed [yes/no]
@@ -26,7 +26,7 @@
26
26
 
27
27
  ## 审视维度
28
28
 
29
- 前 15 个维度覆盖假设、逻辑、模型、计算等核心审视角度(多数对应 `../lenses/` 中的 v3 思想透镜),第 16–18 维为横切维度:工具选择、GPU 可行性、现代数学激活。**不需要机械地逐一检查所有维度**——应根据问题性质和用户关注点,选择最相关的维度深入审视,其余可简略提及或跳过。若产出涉及算法/算子/GPU 设计,**第 17(GPU)与第 18(现代数学激活)维为强制检查项**。
29
+ 前 15 个维度覆盖假设、逻辑、模型、计算等核心审视角度(多数对应 `../lenses/` 中的 v3 思想透镜),第 16–19 维为横切维度:工具选择、GPU 可行性、现代数学激活、密码学安全。**不需要机械地逐一检查所有维度**——应根据问题性质和用户关注点,选择最相关的维度深入审视,其余可简略提及或跳过。若产出涉及算法/算子/GPU 设计,**第 17(GPU)与第 18(现代数学激活)维为强制检查项**;若产出涉及密码学构造/安全证明/协议,**第 19(密码学安全)维为强制检查项**。
30
30
 
31
31
  ### 1. 假设审查 / Assumption Review -> axiomatization(公理化透镜)
32
32
 
@@ -151,13 +151,25 @@
151
151
  - 迁移是否是「跨领域激活」(结构本就在那里,只差一次跨域映射),还是生搬硬套(只借名词不借结构)?
152
152
  - 产出是否同时通过**双验收门**:数学正确 **AND**(八维友好或可改造)?未同时通过的候选是否被剔除?
153
153
 
154
+ ### 19. 密码学安全审视 / Cryptographic Security Review -> `../references/books/`(密码学 3 本)
155
+
156
+ > 产出涉及密码学构造/安全证明/协议设计时为**强制项**(Domain Router 判定为密码学或 AI×密码交叉时触发)。对应「双验收门」的密码学版:安全定义正确 **AND** 归约紧度可接受。
157
+
158
+ - **安全定义**:是否用形式化攻击游戏定义了安全目标?威胁模型层级(CPA/CCA/AE/EUF-CMA)是否匹配需求?避免"直觉上安全"的空话。
159
+ - **归约紧度**:归约损失 ε_scheme ≈ Q·ε_assumption 中的 Q 多大?参数是否补偿?是否声称"松归约=安全"?
160
+ - **假设依赖**:方案依赖哪条假设(OWF/DL/CDH/DDH/RSA/LWE)?是否最小化?是否有黑盒分离结果限制?量子威胁下是否需升级(Shor/Grover)?
161
+ - **合成与实现陷阱**:EtM/MtE/EaM 选对了吗?密钥是否独立?IV/nonce 是否唯一?MAC 比较是否常数时间?上下文(身份/转录)是否绑定?
162
+ - **反模式检查**:是否把 ROM 当绝对保证?确定性加密当 CPA 安全?Merkle-Damgård 当 ROM?plain RSA 签名?
163
+ - **跨域迁移合理性**(仅 AI×密码交叉):把密码学概念迁移到 ML(如 PRF 做水印、归约做鲁棒性证书)时,是否保留了安全语义,还是只借名词?迁移后假设是否仍可达成?
164
+ - **Domain Router 一致性**:纯密码问题是否避免加载 AI design-patterns?纯 AI 问题是否避免加载密码学书稿?交叉问题是否双 domain 加载并标注交叉点?
165
+
154
166
  ## 工作流程
155
167
 
156
168
  ### 审视阶段
157
169
 
158
170
  1. **概括结论**:先一句话概述该论点或方案的核心主张。
159
171
  2. **列出假设**:显式、隐式和背景假设一一列出。
160
- 3. **选择维度**:根据问题性质,从十八个审视维度中选择最相关的 3–5 个深入检查;若涉及算法/GPU 设计,**第 17、18 维必选**。其余可简略提及或跳过。
172
+ 3. **选择维度**:根据问题性质,从十九个审视维度中选择最相关的 3–5 个深入检查;若涉算法/GPU,**第 17、18 维必选**;若涉密码学,**第 19 维必选**。其余可简略提及或跳过。
161
173
  4. **检查逻辑链**:验证推理是否完整、是否存在跳跃。
162
174
  5. **过双验收门**:对每个候选产出,分别判数学正确性与 GPU 可行性,只保留同时通过的。
163
175
  6. **评估严重性**:根据发现的问题对结论可靠性的影响分级。
@@ -181,7 +193,7 @@
181
193
  ### 审视部分
182
194
 
183
195
  #### 本次重点审视维度
184
- - [列出本次选择深入审视的 3–5 个维度及原因;若涉算法/GPU,标注 17/18 已纳入]
196
+ - [列出本次选择深入审视的 3–5 个维度及原因;若涉算法/GPU,标注 17/18 已纳入;若涉密码学,标注 19 已纳入]
185
197
 
186
198
  #### 双验收门结果
187
199
  - [候选1]: 数学正确[v/x] | GPU 八维[友好/可改造/不友好] | 通过[是/否]
@@ -36,6 +36,8 @@ The current 31 anchors cover the most commonly used mathematical structures in A
36
36
  2. Enter the **Knowledge Gap Protocol** defined in `../skills/math-research-activator/SKILL.en.md` to generate a temporary knowledge card
37
37
  3. Never respond with "knowledge base does not cover this" or force-fit the closest card
38
38
 
39
+ > **Domain Router note** (v3.2.0): This knowledge base primarily serves the **AI Research Layer** and **Shared Math Layer**. If Domain Router determines the problem belongs to the **Cryptography Layer**, first consult the three crypto books listed in `../references/skill-index.en.md`; shared math anchors (e.g., `probability/entropy`, `matrix-analysis/spectral-decomposition`) are loaded on demand without redundancy. Crypto-specific concepts (OWF/PRF/CCA/reduction proofs etc.) are not among these 31 anchors; activate them via temporary knowledge cards or the crypto books.
40
+
39
41
  ## Domain Extension Index
40
42
 
41
43
  Each domain has an `*/index.en.md` that lists: domain trigger signals, core anchors, extended concepts, reference book directions, and temporary activation rules.
@@ -33,9 +33,11 @@
33
33
  现有 31 个锚点覆盖 AI 研究中最常用的数学结构。当问题需要的数学工具不在其中时:
34
34
 
35
35
  1. 查看对应领域的 `*/index.md`(如 `topology/index.md`),获取扩展概念和参考书方向
36
- 2. 进入 SKILL.md 中定义的**知识缺口协议**,生成临时知识卡
36
+ 2. 进入 `../skills/math-research-activator/SKILL.md` 中定义的**知识缺口协议**,生成临时知识卡
37
37
  3. 不得回答"知识库未覆盖"或强行套用最相近卡片
38
38
 
39
+ > **Domain Router 提示**(v3.2.0):本知识库主要服务 **AI 研究层** 与 **共用数学层**。若 Domain Router 判定问题属**密码学层**,优先查阅 `../references/skill-index.md` 列出的 3 本密码学书稿;共用数学锚点(如 `probability/entropy`、`matrix-analysis/spectral-decomposition`)按需加载,不重复。密码学专属概念(OWF/PRF/CCA/归约证明等)不在此 31 锚点内,通过临时知识卡或密码学书稿激活。
40
+
39
41
  ## 领域扩展索引
40
42
 
41
43
  每个领域有一个 `*/index.md`,列出:领域触发信号、核心锚点、扩展概念、参考书方向、临时激活规则。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-skill",
3
- "version": "3.1.1",
4
- "description": "面向 AI 架构创新的数学研究操作系统 v3.1:思想透镜 / 激活锚点 / 设计翻译原型,支持知识缺口协议与临时知识卡。Math Research OS for AI architecture design: thinking lenses + activation anchors + design translation prototypes with Knowledge Gap Protocol.",
3
+ "version": "3.2.0",
4
+ "description": "面向 AI 架构创新与密码学研究的数学研究操作系统 v3.2:思想透镜 / 激活锚点 / 设计翻译原型 + Domain Router(AI/密码/纯数学/交叉),支持知识缺口协议与临时知识卡。Math Research OS for AI architecture & cryptography research: thinking lenses + activation anchors + design translation prototypes + Domain Router with Knowledge Gap Protocol.",
5
5
  "keywords": [
6
6
  "math",
7
7
  "mathematics",
@@ -46,7 +46,13 @@
46
46
  "lenses",
47
47
  "knowledge-base",
48
48
  "design-patterns",
49
- "math-research-os"
49
+ "math-research-os",
50
+ "cryptography",
51
+ "crypto",
52
+ "security",
53
+ "reduction-proof",
54
+ "attack-game",
55
+ "domain-router"
50
56
  ],
51
57
  "license": "MIT",
52
58
  "author": "the-thinker0",
@@ -0,0 +1,128 @@
1
+ # 应用密码学 / Applied Cryptography
2
+
3
+ > Dan Boneh & Victor Shoup, *A Graduate Course in Applied Cryptography* (v0.4, 2017)。以**攻击游戏 + 归约证明**为统一范式的研究生级应用密码学参考——构造、归约、协议分析的实战手册。
4
+
5
+ ## 概要
6
+
7
+ 本书把密码学定义为"对抗性系统的数学研究":不是统计可靠性,而是**博弈论式安全证明**。统一组织原则:用形式化**攻击游戏**(challenger vs adversary)定义"安全",方案安全 ⇔ 不存在高效敌手能以非忽略概率赢游戏。全书定理都是**归约**:破方案 Y ⇒ 解困难假设 X。
8
+
9
+ **激活边界**:本书是**构造与证明优先**——讲攻击游戏、归约模板、序列游戏、具体安全界,**不是工程实现手册**。落地实现(侧信道、常数时间、协议状态机)需配实现密码学教材(如 Katz-Lindell 的工程章节)。这里给的是"安全定义怎么写、归约怎么构造、哪里会翻车"的**激活索引**。
10
+
11
+ ## 可迁移到 AI/安全分析的核心结构
12
+
13
+ | 密码学结构(章节) | 迁移到 AI/ML/系统设计 |
14
+ |---|---|
15
+ | **攻击游戏框架(§2)** | 一切"对抗性建模"的模板:定义敌手能力→定义胜利→证不可赢;ML 鲁棒性、机制设计、对抗样本都可用 |
16
+ | **归约证明模板(§3)** | "破我方案 ⇒ 解困难问题"的通用科学推理;安全性相对化、假设最小化 |
17
+ | **序列游戏 + Difference Lemma(§3.4-3.5)** | 把复杂证明拆成可分析的小步;hybrid argument 的概率版 |
18
+ | **CPA/CCA/AE 层级(§4)** | 能力递增的威胁模型,对应 ML 中"白盒/黑盒/自适应对抗"的层级化建模 |
19
+ | **PRG/PRF/PRP 层级链(§5, §14)** | "弱假设→强原语"的构造链;AI 中类似"弱学习器→强学习器"的 boost 思路 |
20
+ | **DDH/CDH/DL 假设族(§6)** | 离散对数族的严格强弱关系;假设最小化原则的实例 |
21
+ | **Encrypt-then-MAC 合成(§7.9, §9.2)** | "合成不保安全"的典型反例;独立密钥、上下文绑定的工程铁律 |
22
+ | **Sigma 协议 + Fiat-Shamir(§11)** | 三步承诺-挑战-响应;NIZK、Schnorr 签名的源头;可迁移到可验证计算 |
23
+ | **AKE 模型 + PFS(§12)** | 会话密钥安全、前向保密;TLS 1.3 的形式化根 |
24
+ | **归约紧度分析(§10.3)** | 安全损失 ε_scheme ≈ Q·ε_assumption;参数选择必须补偿 |
25
+
26
+ **激活家族**(便于路由检索):
27
+
28
+ - **定义系(§2, §4)**:攻击游戏、语义/CPA/CCA 安全、AE——回答"安全到底指什么"。
29
+ - **归约系(§3, §16)**:黑盒 wrapper、序列游戏、hybrid、模拟范式——回答"怎么证明安全"。
30
+ - **原语系(§5, §14)**:OWF/PRG/PRF/PRP/CRHF/TDF——回答"基础工具是什么、怎么叠加"。
31
+ - **协议系(§9, §11, §12)**:PKE、签名、Sigma、AKE——回答"上层协议如何组装"。
32
+
33
+ ## 关键桥接事实(激活速记)
34
+
35
+ - **Adv[A,S] := |Pr[W₀] − Pr[W₁]|,等价 bit-guessing:Adv\* = 2·Adv**(§2.2):两实验优势 = 2×单实验猜中优势。
36
+ - **PPT + 忽略函数 = "高效敌手 + 实际不可能"**(§2.3):neg·poly = neg,poly·poly = poly,这是 hybrid 闭合性的基石。
37
+ - **PRP Switching Lemma:Q 次查询区分 n-bit PRP 与随机函数优势 ≤ Q²/2^{n+1}**(§5.4):AES 当 PRF 用只要查询数有界。
38
+ - **Shannon 完美保密 ⇒ |K| ≥ |M|**(§4.1):信息论安全的代价——密钥不得短于消息(OTP 的根源)。
39
+ - **CPA 安全 ⇏ 多重加密安全(对称);公钥 CPA ⇒ 多重安全**(§4.3):公钥场景敌手本就能任意加密。
40
+ - **EtM 安全;MtE/EaM 不安全**(§7.9):合成顺序决定生死;padding oracle 攻 MtE。
41
+ - **CCA ⇒ 不可延展;AE ⇒ CCA**(§4.4-4.5):AE = CCA + 密文完整性,是 CCA 的标准路径。
42
+ - **DL 随机自归约**(§6.6):DL 在随机实例上可解 ⇒ 任意实例可解,"全难或全易"。
43
+ - **归约紧度 ε_RSA ≈ ε_sig / q_H**(§10.3):ROM 归约常松,需参数补偿。
44
+ - **量子威胁:Shor 破 RSA/DL;Grover 对称安全减半**(§14.3):AES-128 量子下仅 64-bit。
45
+
46
+ ## 适合激活的问题类型
47
+
48
+ - **安全定义书写**:怎么把"敌手能做什么、赢是什么"形式化?哪个层级(CPA/CCA/AE)贴现需求?避免"直觉上安全"的空话。
49
+ - **归约证明设计**:如何构造 B(攻击假设 X)把 A(攻击方案 Y)当黑盒?模拟是否完美?紧度损失多少?
50
+ - **协议合成审查**:EtM/MtE/EaM 哪个能过?密钥是否独立?上下文(身份/转录)是否绑进 MAC?
51
+ - **参数选择**:归约紧度 ε_scheme ≈ Q·ε_assumption,Q 多大?需多少额外 bit 补偿?量子下要多少?
52
+ - **协议级失败诊断**:身份缺失、反射、降级、nonce 重用——根因在"上下文未绑定"还是"密钥复用"?
53
+ - **迁移到 AI 鲁棒性**:把"攻击游戏"模板套到对抗样本、模型窃取、后门——敌手能力、胜利条件、归约目标是什么?
54
+
55
+ ## 可能的算法启发
56
+
57
+ > 密码学本身不直接产 GPU kernel,但其**设计思想**可迁移到 AI 安全/可验证计算:
58
+
59
+ 1. **对抗性建模迁移**:攻击游戏框架用于 ML 鲁棒性证明——定义敌手能力预算 → 定义"破" → 证不可破。*落点:方法论,不直接落 GPU。*
60
+ 2. **PRF 作为可验证伪随机**:用 PRF 生成训练数据划分/路由 seed,保证可复现且敌手不可预测。*落点:D1/D2——GEMM 友好。*
61
+ 3. **Sigma 协议 → 可验证计算**:让 AI 推理产出 SNARK 式证明,验证者低成本核对。*落点:D3——验证端廉价、证明端昂贵。*
62
+ 4. **归约范式迁移到 ML 安全**:破模型鲁棒性 ⇒ 解某困难问题,给"相对安全"证书。*落点:方法论。*
63
+ 5. **承诺方案做水印**:用承诺方案做模型水印与可追踪分发。*落点:D1——哈希链廉价。*
64
+
65
+ ## GPU 友好性警告
66
+
67
+ > 密码学结构与 GPU 八维(`../gpu-friendly-math.md`)的关系,与 AI 方向书稿相反——多数密码学原语**不在 GPU 友好维度**,而是 CPU/专用硬件域:
68
+
69
+ **天然不友好但可专用硬件加速:**
70
+ - **AES/SHA via SIMD/ASIC**:块密码/哈希走专用指令(AES-NI、SHA-NI),不走 GEMM。*违反 D1/D2。*
71
+ - **大数模乘/RSA**:bigint 运算,非张量化。*违反 D1/D2/D3。*
72
+ - **椭圆曲线标量乘**:点加非 GEMM 化。*违反 D2。*
73
+
74
+ **方法论层面友好:**
75
+ - **攻击游戏/归约模板**:纯逻辑推理,不涉及 GPU。
76
+ - **PRF 作为 seed 生成**:一次性小开销,不构成瓶颈。
77
+ - **可验证计算(SNARK)**:证明端重、验证端轻;验证可批量 GEMM 化。
78
+
79
+ **反模式警告:**
80
+ - 把 AES/SHA 当 GEMM 算子去优化——南辕北辙。
81
+ - 在训练循环里频繁调用密码学原语——非张量化、拖垮 SM 占用。
82
+ - 用密码学哈希做 ML loss——哈希不可导,无法反传。
83
+
84
+ ## 该调用哪个思想透镜
85
+
86
+ 配合 `../../lenses/` 下的思想透镜:
87
+
88
+ - **`game`(博弈)**:攻击游戏、多方策略互动、机制设计——本书的灵魂。
89
+ - **`axiomatization`(公理化)**:安全定义即公理——假设的相容性、独立性、完备性。
90
+ - **`algorithmic`(算法)**:归约即算法变换;复杂度可行性、并行性。
91
+ - **`probabilistic`(概率统计)**:忽略函数、优势、birthday 攻击、hybrid argument。
92
+ - **`duality`(对偶)**:信息论 vs 计算安全;模拟范式(敌手视角 ↔ 模拟器视角)。
93
+ - **`causal`(因果)**:归约的"如果破 Y 则破 X"是因果链;相关≠因果在安全分析中至关重要。
94
+ - **`categorical`(范畴化)**:原语间的蕴含关系形成偏序(OWF⇒PRG⇒PRF⇒...)。
95
+
96
+ ## 反模式
97
+
98
+ - **把 ROM 证明当绝对保证**:ROM 是启发式,存在反例;instantiation 可能不安全。
99
+ - **混淆必要与充分条件**:大密钥空间必要非充分(代换密码 26!≈2^88 但可破)。
100
+ - **假设"密钥难恢复=方案安全"**:Enc_k(m)=m 密钥无法恢复但零安全。
101
+ - **加密与 MAC 共用密钥**:EtM 要求独立密钥,否则跨原语交互致破。
102
+ - **确定性加密当 CPA 安全**:公钥场景下确定性必破(加密-比对攻击)。
103
+ - **IV/nonce 重用**:stream cipher/CTR/GCM 中重用即灾难(两时间本 XOR 泄露)。
104
+ - **非常数时间比较 MAC**:`memcmp` 短路泄露前缀,时序攻击可伪造。
105
+ - **归约松仍称安全**:ε_scheme ≈ Q·ε_assumption 时 Q 大则实际安全远低于声称。
106
+ - **协议签名只签临时密钥不绑身份**:身份误绑攻击。
107
+ - **堆定理而不诊断瓶颈**:先问"安全目标是 CPA/CCA/AE 哪层、归约目标是什么假设",再选工具。
108
+
109
+ ## 深挖入口
110
+
111
+ > **书目信息**:Dan Boneh & Victor Shoup, *A Graduate Course in Applied Cryptography*, v0.4, Sep 2017. 在线:https://toc.cryptobook.us/
112
+ >
113
+ > **启用方式**:将 `Applied Cryptography.pdf` 放入 `math_book/`,Agent 自动 `pdftotext` + grep 定位原文页。
114
+
115
+ 值得深读的真实章节:
116
+
117
+ > 以下章节号对应原书 Boneh-Shoup v0.4 实际目录(非精简版自编),用于 `math_book/` PDF 回查定位。
118
+
119
+ - **§2 Attack Game Framework**——所有安全定义的统一模板。
120
+ - **§3 Reduction Proof Pattern + Sequence-of-Games**——归约与游戏跳跃的实战。
121
+ - **§4 Security Hierarchy**(perfect→semantic→CPA→CCA→AE)——威胁模型层级。
122
+ - **§5 PRG/PRF/PRP + Switching Lemma**——对称原语与替换界。
123
+ - **§6 DL/CDH/DDH + Random Self-Reducibility**——数论假设族。
124
+ - **§7 Symmetric Constructions**(stream/CTR/CBC/MAC/Merkle-Damgård/sponge/EtM)——构造工具箱。
125
+ - **§11 Sigma Protocols + Fiat-Shamir**——零知识与签名转换。
126
+ - **§12 AKE + PFS + PAKE**——协议安全的形式化。
127
+ - **§13 Attack Patterns**(两时间本/延展性/padding oracle/extension/related-key/nonce 误用/协议级失败)——反模式总集。
128
+ - **§16 Reasoning Patterns**(归约心态/模拟范式/理想替换/游戏跳跃/hybrid/必要条件/合成/"无暗门"原则)——可迁移思维模式。
@@ -0,0 +1,127 @@
1
+ # 密码学基础 / Foundations of Cryptography
2
+
3
+ > Oded Goldreich, *Foundations of Cryptography, Volume 1: Basic Tools*, Cambridge University Press, 2001。以**定义方法论 + 归约可构造性**为统一主题的理论密码学基础——把密码学从艺术变成科学的哲学根基。
4
+
5
+ ## 概要
6
+
7
+ 本书最深的贡献不是任何具体构造,而是**定义方法论**:使严格安全分析成为可能的哲学转变——从信息论安全(Shannon:敌手信息不足)到**计算安全**(敌手有信息但无法高效提取)。这一转变建立在"PPT = 可行计算"的工作假设之上,整座现代密码学大厦都依赖它。
8
+
9
+ **核心论点**:密码学是定义即创造的领域。好的定义同时形式化直觉、开放构造、允许归约证明、排除平凡构造。全书建立原语间的偏序蕴含链(OWF⇒PRG⇒PRF⇒...),每条箭头都是构造性归约。
10
+
11
+ **激活边界**:本书是**理论与元定理优先**——讲定义、归约、可构造性、不可能性,**不是实用方案手册**。很多构造效率太低不可直接落地。这里给的是"密码学的概念骨架与假设依赖图"的**激活索引**,实用构造回查 Boneh-Shoup / Katz-Lindell。
12
+
13
+ ## 可迁移到 AI/理论分析的核心结构
14
+
15
+ | 理论结构(章节) | 迁移到 AI/ML/系统设计 |
16
+ |---|---|
17
+ | **计算不可区分(§2.2)** | "伪随机"的形式化定义;分布距离 vs 可识别性的区分;ML 中"生成分布逼近真实"的严格语言 |
18
+ | **PPT + 忽略函数框架(§2.1, §2.3)** | "高效算法 + 实际不可能事件"的形式化;ML 中"多项式时间敌手 + 概率可忽略"威胁模型 |
19
+ | **OWF ⇔ PRG ⇔ PRF 等价链(§III, §V)** | "最小假设 ↔ 最大功能"的等价定理模板;AI 中"弱学习器↔强学习器"PAC 提升的类比 |
20
+ | **归约论证 vs 经典归约(§4.1)** | 分布保持的归约;不能喂敌手任意输入,必须匹配其成功分布——迁移到 ML 安全证明要小心分布漂移 |
21
+ | **Hybrid 技术(§4.2)** | 把多步不可区分性拆成单步;hybrid 数须 poly(n),相邻差异须可界——ML 分布漂移分析的通用工具 |
22
+ | **弱→强放大(§4.3)** | "弱假设 → 强结论"的非平凡放大;证明不能假设独立性——AI 中 boosting/集成 的理论镜像 |
23
+ | **模拟范式(§4.4, §VI)** | "零知识"= 可被模拟则未学到的认识论定义;迁移到隐私 ML:模型可被模拟则未泄露训练数据 |
24
+ | **不可预测性 ⇔ 伪随机性(§4.5)** | "下一 bit 不可预测 ⇒ 整体伪随机"的深刻等价;迁移到序列模型评估:不可预测即伪随机 |
25
+ | **Goldreich-Levin hardcore bit(§5.1)** | 从 OWF 提取一个"完美隐藏 bit"——伪随机性的种子;列表解码 + 配对独立采样 |
26
+ | **黑盒 vs 非黑盒(§7.3)** | 构造与分离的技术分类;黑盒更鲁棒但可能本质受限 |
27
+
28
+ **激活家族**:
29
+
30
+ - **定义系(§III)**:OWF/PRG/PRF/ZK/Commitment 的定义——回答"密码学原语的本质是什么"。
31
+ - **证明系(§IV)**:归约论证、hybrid、放大、模拟、不可预测⇔伪随机——回答"怎么证明原语安全"。
32
+ - **构造系(§V, §VI)**:OWF→hardcore→PRG→PRF→Commitment→ZK for NP——回答"原语如何层层构造"。
33
+ - **元理系(§VII, §IX)**:定义驱动、归约为进步单位、黑盒分离、假设偏序——回答"密码学的认识论"。
34
+
35
+ ## 关键桥接事实(激活速记)
36
+
37
+ - **信息论安全 ⇔ 计算安全的鸿沟**:信息论上破但计算上安全是现代密码学的本质;敌手"有信息但提不出来"。
38
+ - **计算不可区分 ⇏ 统计接近**:存在伪随机但统计上远离均匀的总体(支持集 2^{n/2} vs 2^n)。
39
+ - **多抽样不可区分需要可高效构造**:无此条件,单抽样不可区分 ⇏ 多抽样——纯计算现象,无信息论对应。
40
+ - **OWF ⇔ PRG(HILL 定理)**:最小密码假设 ⇔ 最基本原语,深刻等价。
41
+ - **弱 OWF ⇒ 强 OWF(放大定理)**:构造 g(x₁..x_t)=(f(x₁)..f(x_t)),但证明不可假设块独立性。
42
+ - **不可预测 ⇔ 伪随机(Yao 定理)**:hybrid H^i = i-bit 前缀 + (n-i) 均匀 bit;区分器 ⇒ 预测器,优势 ≥ ε/n。
43
+ - **Goldreich-Levin:任何 OWF 可加 hardcore bit**:g(x,r)=(f(x),r),b(x,r)=⟨x,r⟩ mod 2;列表解码 + 配对独立。
44
+ - **GGM 树:PRG ⇒ PRF**:二叉树深度 poly(n),叶节点 = 伪随机函数表;指数域大小来自多项式 key。
45
+ - **ZK = 可模拟性**:存在 PPT 模拟器生成 V\* 视图 ⇒ 交互未带来新知识;三档:完美/统计/计算 ZK。
46
+ - **BPP ⊆ PZK ⊆ SZK ⊆ CZK ⊆ IP=PSPACE**;假设 OWF 存在则 CZK=IP。
47
+
48
+ ## 适合激活的问题类型
49
+
50
+ - **定义书写**:怎么把"安全/隐私/不可学习"形式化?定义是否捕获直觉、可达成、可证明、最小?
51
+ - **归约与分离**:原语 A 是否蕴含 B?黑盒归约是否可能?分离结果是否适用?
52
+ - **假设最小化**:方案依赖哪些假设?能否弱化到 OWF?是否依赖非一致硬假设?
53
+ - **放大证明**:弱性质如何放大到强性质?能否避免独立性假设?放大常数多大?
54
+ - **模拟范式应用**:能否构造模拟器证明"未泄露"?模拟器是严格还是期望多项式时间?
55
+ - **不可预测性分析**:序列模型的下一 token 不可预测 ⇒ 整体伪随机?hybrid 链有多长?
56
+ - **迁移到隐私 ML**:差分隐私的可合成性、模型反演攻击的"信息论 vs 计算"边界、合成安全分析。
57
+
58
+ ## 可能的算法启发
59
+
60
+ > 本书方法论产出远多于具体算法,但其思想可迁移:
61
+
62
+ 1. **Goldreich-Levin hardcore bit 迁移**:从任何"难逆"映射提取一个不可预测 bit——可用作 ML 中的"难特征"提取。*落点:方法论。*
63
+ 2. **GGM 树式构造迁移**:用短 seed 生成指数级"伪随机"结构——可启发参数共享与伪随机路由表。*落点:D4——小 key 大表。*
64
+ 3. **Hybrid argument 迁移到分布漂移分析**:把多步训练的分布漂移拆成单步可界——理论分析工具。*落点:方法论。*
65
+ 4. **模拟范式迁移到可验证隐私**:构造模拟器证明"模型输出可被独立生成"——隐私证书。*落点:方法论。*
66
+ 5. **弱→强放大迁移到集成学习**:弱学习器放大为强学习器是 PAC-boosting 的镜像,但证明不能假设基学习器独立。*落点:方法论。*
67
+
68
+ ## GPU 友好性警告
69
+
70
+ > 本书几乎不涉及 GPU——它的产物是定义、定理、归约,不是可算的 kernel:
71
+
72
+ **天然不友好但理论友好:**
73
+ - **OWF/PRG/PRF 的通用构造**:HILL/GGM 构造常数巨大,实际不可用;理论存在性证明。
74
+ - **ZK for NP 通用构造**:G3C 模板 round 复杂度高、常数大;实际用 Sigma/Fiat-Shamir 专用构造。
75
+ - **Leftover Hash Lemma**:提取随机性的信息论工具,构造可用但效率依赖熵参数。
76
+
77
+ **方法论层面友好:**
78
+ - **归约论证、hybrid、模拟范式**:纯逻辑推理,不涉及 GPU。
79
+ - **Goldreich-Levin hardcore bit**:列表解码可张量化(Hadamard 变换),但实际用于密码学而非 ML。
80
+ - **计算不可区分框架**:用于 ML 分布评估的理论语言,不直接落 GPU。
81
+
82
+ **反模式警告:**
83
+ - 把 HILL/GGM 通用构造当实用方案——常数灾难性,只证存在性。
84
+ - 用计算不可 distinguishability 直接做 ML loss——不可导,只能做评估指标。
85
+ - 假设"PPT = 可行"在量子/专用硬件下仍成立——需扩展到 BQP 敌手。
86
+
87
+ ## 该调用哪个思想透镜
88
+
89
+ 配合 `../../lenses/` 下的思想透镜:
90
+
91
+ - **`axiomatization`(公理化)**:定义即公理;假设相容性/独立性/完备性——本书的核心方法论。
92
+ - **`categorical`(范畴化)**:原语间的蕴含关系形成偏序;泛性质(OWF 是最小密码原语)。
93
+ - **`algorithmic`(算法)**:归约即算法变换;黑盒 vs 非黑盒;多项式时间可行性。
94
+ - **`probabilistic`(概率统计)**:忽略函数、不可区分、hybrid argument、birthday 攻击。
95
+ - **`duality`(对偶)**:信息论 vs 计算安全;敌手视角 ↔ 模拟器视角;定义中"易 ↔ 难"的对偶。
96
+ - **`perturbation`(扰动)**:弱→强放大是非平凡扰动分析;不可假设独立性。
97
+ - **`local-to-global`(局部到整体)**:单抽样不可区分 → 多抽样(需高效构造);单步 hybrid → 全链。
98
+
99
+ ## 反模式
100
+
101
+ - **把定义当构造**:定义只说"该是什么",构造才说"怎么做";只有定义没有构造等于空话。
102
+ - **假设独立性强放大**:弱→强放大证明不能假设块独立,否则证明错;计算设置中独立性是奢侈品。
103
+ - **混淆黑盒与非黑盒**:黑盒分离结果只对黑盒构造有效;非黑盒可能突破分离。
104
+ - **把 asymptotic 当 concrete**:渐近安全 ⇒ 具体安全需要多项式常数小;不查常数就部署是赌博。
105
+ - **把 ZK 的 HVZK 当通用 ZK**:诚实验证者 ZK 弱于恶意验证者 ZK;并行合成 ZK 不闭,WI 才闭。
106
+ - **把 PPT 假设当永恒**:量子计算(BQP)与侧信道不在 PPT 模型内;部署前要扩展敌手模型。
107
+ - **堆元定理而不诊断假设**:先问"方案依赖哪条假设、能否弱化、是否有黑盒分离",再选工具。
108
+
109
+ ## 深挖入口
110
+
111
+ > **书目信息**:Oded Goldreich, *Foundations of Cryptography, Volume 1: Basic Tools*, Cambridge University Press, 2001. ISBN 978-0-521-79235-9.
112
+ >
113
+ > **启用方式**:将 `Foundations of Cryptography.pdf` 放入 `math_book/`,Agent 自动 `pdftotext` + grep 定位原文页。
114
+
115
+ 值得深读的真实章节:
116
+
117
+ > 以下章节号对应原书 Goldreich Vol.1 实际目录(罗马数字为原书 part 编号,阿拉伯数字为章号;非精简版自编),用于 `math_book/` PDF 回查定位。
118
+
119
+ - **§2.1-2.4 概率论与计算不可区分**——现代密码学的概率语言基石。
120
+ - **§2.5-2.6 OWF 定义与弱/强区分**——密码学最小假设的形式化。
121
+ - **§3 PRG 与 hardcore bit**——OWF→PRG 的构造链与 Goldreich-Levin。
122
+ - **§4 归约论证 + hybrid + 放大 + 模拟 + 不可预测⇔伪随机**——证明技术工具箱。
123
+ - **§5 PRF(GGM 树)**——指数域来自多项式 key 的"魔法"。
124
+ - **§6 ZK 的模拟范式与 ZK for NP**——零知识的认识论。
125
+ - **§7 元定理:定义驱动、黑盒 vs 非黑盒、假设偏序**——密码学的认识论层级。
126
+ - **§9 假设清单与局限**——显式假设(PPT、OWF、非一致)与隐含假设(归约有意义、渐近⇒具体、敌手模型完备、随机可得)。
127
+ - **§X 问题求解清单**——分析密码学问题的 8 步法(两方不对称、安全性质精确化、假设识别、归约检查、合成验证、量词顺序、黑盒判定、平凡反例)。
@@ -0,0 +1,155 @@
1
+ # 现代密码学导论 / Introduction to Modern Cryptography
2
+
3
+ > Jonathan Katz & Yehuda Lindell, *Introduction to Modern Cryptography*, 2nd Edition, CRC Press, 2015。以**形式化定义 + 工程落地**为统一主题的现代密码学教科书——定义、假设、证明三原则的实战入门。
4
+
5
+ ## 概要
6
+
7
+ 本书把现代密码学(1980s 后)与古典密码学区分开来的三大原则:**(1) 形式化定义、(2) 精确假设、(3) 安全证明**。定义先于设计:先说清"破是什么、敌手能做什么",再构造。证明是归约——破方案 ⇒ 违反假设。Kerckhoffs 原则:安全完全在密钥,算法公开。
8
+
9
+ **激活边界**:本书是**定义与工程并重**——讲形式化安全定义(EAV/CPA/CCA/AE)、构造范式(SPN/Feistel/Merkle-Damgård/KEM-DEM/Fiat-Shamir)、攻击模型、实现陷阱,比 Boneh-Shoup 更入门、比 Goldreich 更工程。这里给的是"安全定义怎么写、构造怎么选、实现哪里翻车"的**激活索引**。
10
+
11
+ ## 可迁移到 AI/系统设计的核心结构
12
+
13
+ | 定义/构造(章节) | 迁移到 AI/ML/系统设计 |
14
+ |---|---|
15
+ | **三原则(定义/假设/证明,§1)** | 任何安全系统的科学方法论:先形式化威胁,再声明假设,再归约证明 |
16
+ | **Kerckhocks 原则(§1.3)** | 安全不依赖算法保密;可审计、可标准化、可替换——ML 模型安全的同构原则 |
17
+ | **概率论即安全语言(§2.1)** | Bayes 定理分析信息泄露;K 与 M 独立;随机化加密的必要性 |
18
+ | **渐近 vs 具体安全(§2.3)** | asymptotic 给理论,concrete 给部署;ML 安全分析需要具体 bit 级界 |
19
+ | **熵与最小熵(§2.4)** | 最小熵 = 一次猜测成功率;ML 中的"可猜性"量化 |
20
+ | **完美保密层级(§3.1-3.2)** | 信息论安全(|K|≥|M|)⇒ 计算安全(PPT + negl)的放松链 |
21
+ | **CPA/CCA/AE 定义族(§3.2-3.5)** | 威胁模型层级化;AE = CCA + 密文完整性,是工程标准 |
22
+ | **MAC 不可伪造性(§3.4)** | 强不可伪造(不允许新 tag on 已签消息);常数时间验证;重放需上层处理 |
23
+ | **Hash 与 birthday(§3.6)** | 碰撞抗性⇒第二原像⇒原像(单向);n-bit 输出给 n/2-bit 碰撞抗性 |
24
+ | **归约证明范式(§5)** | 假设矛盾→构造 B 用 A→B 成功概率非忽略;模拟须完美 |
25
+ | **Hybrid argument(§5.3)** | 相邻 hybrid 差异 ≤ ε,poly·ε 仍忽略;渐近安全的基石 |
26
+ | **Game-hopping(§5.4)** | 现代版 hybrid:G₀→G₁→...→G_k,相邻用假设,末态敌手优势=1/2 |
27
+ | **OWF ⇔ PRG ⇔ PRF ⇔ 对称密码(§6)** | 对称密码的统一归约链;通用构造低效,实际用 AES/SHA |
28
+ | **数论假设族(§7)** | DL/CDH/DDH 严格强弱;RSA ≤ factoring;群选择影响 DDH |
29
+ | **SPN/Feistel 构造(§8.1-8.2)** | confusion-diffusion 范式;Feistel 不要求 f 可逆;Luby-Rackoff 3/4 轮 |
30
+ | **Merkle-Damgård(§8.3)** | 抗碰撞压缩函数 ⇒ 抗碰撞哈希;但 length-extension 攻击,非 ROM |
31
+ | **KEM/DEM 混合加密(§8.4)** | 公钥建密钥、对称加密消息;~700x 加速;DEM 只需 EAV |
32
+ | **Hash-and-Sign + Fiat-Shamir(§8.5-8.6)** | 签名先哈再签;FS 把交互识别转非交互签名(ROM) |
33
+ | **ROM 方法论与争议(§9)** | extractability + programmability;Canetti 反例;比无证明强 |
34
+
35
+ **激活家族**:
36
+
37
+ - **定义系(§3)**:EAV/CPA/CCA/AE、MAC 不可伪造、Hash 抗碰撞——回答"安全到底指什么"。
38
+ - **证明系(§5)**:归约模板、distinguisher-to-adversary、hybrid、game-hopping——回答"怎么证明"。
39
+ - **原语系(§6)**:OWF/PRG/PRF/PRP/hardcore bit——回答"基础工具与蕴含链"。
40
+ - **假设系(§7)**:factoring/RSA/DL/CDH/DDH/GDH——回答"公钥密码的依赖图"。
41
+ - **构造系(§8)**:SPN/Feistel/Merkle-Damgård/KEM-DEM/Hash-and-Sign/Fiat-Shamir——回答"工程构造怎么选"。
42
+
43
+ ## 关键桥接事实(激活速记)
44
+
45
+ - **三原则:定义先、假设明、证明归约**(§1.1):缺一定义则"是否安全"无从谈起。
46
+ - **Shannon:完美保密 ⇒ |K|≥|M|**(§3.1):信息论安全的代价,OTP 是唯一最优。
47
+ - **EAV ⇔ 语义安全**(§3.2):敌手对 c 能算的,无 c 也能算——计算不可区分的具象化。
48
+ - **确定性加密 ⇏ CPA 安全**(§3.2):公钥/对称下都破,LR-oracle 一查即破。
49
+ - **CPA ⇒ 多重加密(公钥);对称下不自动**(§3.3):公钥敌手本可任意加密。
50
+ - **CCA ⇒ 不可延展**(§3.2):变换密文成相关明文不可行;拍卖/投票/金融必需。
51
+ - **AE = CCA + 密文完整性;EtM 是 AE 的推荐路径**(§3.5):MtE 用于 SSL 有 padding oracle。
52
+ - **生日攻击:n-bit hash 抗碰撞仅 n/2-bit**(§3.6): Floyd 循环查找 O(2^{n/2}) 时间常量空间。
53
+ - **OWF ⇔ PRG ⇔ PRF ⇔ 对称密码**(§6.5):统一归约链,通用构造低效,实际用 AES/SHA。
54
+ - **Goldreich-Levin:任何 OWF 可加 hardcore bit**(§6.2):⟨x,r⟩ mod 2 是 hardcore;列表解码。
55
+ - **PRP Switching Lemma:Q 查询区分 PRP/随机函数 ≤ Q²/2^{n+1}**(§6.4):AES 当 PRF。
56
+ - **DDH ≤ CDH ≤ DL;factoring ≥ RSA**(§7):假设严格强弱,群选择影响 DDH(Z_p\* 全群 DDH 易,用 QR 子群)。
57
+ - **CRT:Z_N ≅ Z_p × Z_q**(§7.4):结构分解,加速 RSA 解密,Hastad 广播攻击根因。
58
+ - **Luby-Rackoff:3 轮 Feistel + PRF = PRP;4 轮 = 强 PRP**(§8.2):Feistel 不要求 f 可逆。
59
+ - **Merkle-Damgård:抗碰撞压缩函数 ⇒ 抗碰撞哈希;但 length-extension 攻击**(§8.3):非 ROM。
60
+ - **KEM/DEM:CPA-secure KEM + EAV-secure DEM ⇒ CPA-secure 混合**(§8.4):~700x 加速。
61
+ - **ROM:extractability + programmability;存在反例但实用**(§9):比无证明强,比标准模型弱。
62
+
63
+ ## 适合激活的问题类型
64
+
65
+ - **威胁模型分层**:CPA/CCA/AE 哪层贴需求?敌手能力边界在哪?是否需要不可延展?
66
+ - **构造选择**:对称选 AES-CTR/GCM 还是 ChaCha20?公钥选 RSA-OAEP/ElGamal/ECC?哈希选 SHA-2/SHA-3/BLAKE3?
67
+ - **归约证明书写**:假设→构造 B 用 A→B 成功非忽略;模拟完美否?紧度多少?
68
+ - **参数计算**:n-bit 安全需多大 key/输出?生日/量子下打几折?归约紧度补偿?
69
+ - **实现陷阱诊断**:常数时间比较?IV/nonce 唯一?密钥独立?padding oracle?length-extension?
70
+ - **协议合成审查**:EtM/MtE/EaM?独立密钥?上下文绑定?降级防护(transcript hash)?
71
+ - **迁移到 ML 安全**:对抗样本的 CPA 类比?模型水印的 commitment 类比?差分隐私的归约风格?
72
+
73
+ ## 可能的算法启发
74
+
75
+ > 本书工程导向,可迁移的算法启发比 Goldreich 更具体:
76
+
77
+ 1. **AES-CTR + EtM 作为可验证流水线**:加密 + 认证用独立密钥,PRF 提供两路——可迁移到 ML 数据流水线的完整性保护。*落点:D1/D2——AES-NI 加速。*
78
+ 2. **KEM/DEM 混合范式迁移**:用"重计算建 key + 轻计算处理数据"的模式——ML 中可迁移到"昂贵的初始化 + 廉价的批处理"。*落点:D2/D3——批处理友好。*
79
+ 3. **Hash-and-Sign 迁移到内容寻址**:先哈希再处理,任意长输入压到固定长——ML 数据指纹、模型版本管理。*落点:D1——哈希廉价。*
80
+ 4. **Fiat-Shamir 迁移到可验证推理**:交互证明转非交互,让 AI 推理产出可独立验证的证明。*落点:D3——验证端廉价。*
81
+ 5. **ROM 可编程性迁移到"随机预言机测试"**:设计 ML 评估时把"模型当黑盒预言机",测试其可编程性——对抗鲁棒性评估方法。*落点:方法论。*
82
+
83
+ ## GPU 友好性警告
84
+
85
+ > 本书涉及的多数密码学原语不在 GPU 友好维度,与 AI 方向书稿相反:
86
+
87
+ **天然不友好但可专用硬件加速:**
88
+ - **AES(SPN)/SHA-3(sponge)**:走 AES-NI/SHA-NI 专用指令,不走 GEMM。*违反 D1/D2。*
89
+ - **RSA/ElGamal 大数模乘**:bigint,非张量化。*违反 D1/D2/D3。*
90
+ - **EC 标量乘**:点加非 GEMM 化。*违反 D2。*
91
+
92
+ **方法论层面友好:**
93
+ - **归约/hybrid/game-hopping**:纯逻辑推理,不涉及 GPU。
94
+ - **KEM/DEM 分离**:DEM 部分可 GEMM 化(对称加密批量)。
95
+ - **Hash-and-Sign**:哈希部分可批量 SIMD(SHA-NI)。
96
+
97
+ **反模式警告:**
98
+ - 把 AES/SHA 当 GEMM 算子优化——南辕北辙,走专用指令。
99
+ - 在训练循环里频繁调用密码学原语——非张量化、拖垮 SM。
100
+ - 用密码学哈希做 ML loss——不可导,无法反传。
101
+ - 用 Merkle-Damgård 哈希做 MAC 又当 ROM——length-extension 攻击。
102
+
103
+ ## 该调用哪个思想透镜
104
+
105
+ 配合 `../../lenses/` 下的思想透镜:
106
+
107
+ - **`axiomatization`(公理化)**:三原则中的"定义先于设计";假设的相容性、独立性。
108
+ - **`algorithmic`(算法)**:归约即算法变换;复杂度可行性;SPN/Feistel 的迭代结构。
109
+ - **`probabilistic`(概率统计)**:忽略函数、优势、生日悖论、Bayes 分析信息泄露。
110
+ - **`duality`(对偶)**:信息论 vs 计算安全;敌手 ↔ 模拟器;定义中"易 ↔ 难"对偶。
111
+ - **`symmetry`(对称)**:Feistel 的左右对称;SPN 的混淆-扩散对称;群作用的对称性。
112
+ - **`categorical`(范畴化)**:原语蕴含偏序(OWF⇒PRG⇒PRF⇒...);标准型即等价类代表。
113
+ - **`game`(博弈)**:攻击游戏、威胁模型、敌手能力层级(CPA/CCA/AE)。
114
+ - **`perturbation`(扰动)**:归约紧度分析、参数补偿、量子威胁下的安全降级。
115
+
116
+ ## 反模式
117
+
118
+ - **无定义就谈安全**:"直觉上安全"是空话;先写攻击游戏再谈构造。
119
+ - **混淆必要与充分**:大密钥必要非充分;碰撞抗性⇒第二原像⇒原像,反方向不成立。
120
+ - **假设"密钥难恢复=安全"**:Enc_k(m)=m 密钥不可恢复但零安全。
121
+ - **加密与 MAC 共用密钥**:EtM 要独立密钥,否则跨原语交互致破。
122
+ - **确定性公钥加密**:公钥场景下确定性必破(加密-比对)。
123
+ - **IV/nonce 重用**:CTR/GCM 重用即灾难;GCM 重用甚至泄露 GHASH key。
124
+ - **非常数时间 MAC 比较**:`memcmp` 短路泄露前缀,时序攻击可伪造。
125
+ - **Merkle-Damgård 当 ROM**:length-extension 攻击;需 HMAC 或 sponge。
126
+ - **RSA 明文签名**:plain RSA 签名可伪造;需 PSS/FDH padding。
127
+ - **DSA/ECDSA nonce 重用**:重复 nonce 直接泄露私钥。
128
+ - **堆定理而不诊断瓶颈**:先问"威胁模型哪层、归约假设什么、实现陷阱在哪",再选工具。
129
+
130
+ ## 深挖入口
131
+
132
+ > **书目信息**:Jonathan Katz & Yehuda Lindell, *Introduction to Modern Cryptography*, 2nd Edition, CRC Press, 2015. ISBN 978-1-4665-7026-1.
133
+ >
134
+ > **启用方式**:将 `Introduction to Modern Cryptography.pdf` 放入 `math_book/`,Agent 自动 `pdftotext` + grep 定位原文页。
135
+
136
+ 值得深读的真实章节:
137
+
138
+ > 以下章节号对应原书 Katz-Lindell 2nd ed. 实际目录(非精简版自编),用于 `math_book/` PDF 回查定位。
139
+
140
+ - **§1 现代密码学范式**:三原则、Kerckhoffs、安全证明的相对性。
141
+ - **§2 数学基础**:概率、渐近安全、具体 vs 渐近、熵。
142
+ - **§3 安全定义层级**:完美保密、EAV/CPA/CCA、多重加密、MAC、AE、Hash。
143
+ - **§4 不可区分性框架**:计算不可区分、实验模板、1/2+negl 的意义。
144
+ - **§5 归约证明方法论**:归约模板、distinguisher-to-adversary、hybrid、game-hopping。
145
+ - **§6 原语与归约**:OWF、hardcore、PRG、PRF/PRP、Switching Lemma、假设层级链。
146
+ - **§7 数论假设**:factoring/RSA、DL/CDH/DDH、CRT、群选择。
147
+ - **§8 构造范式**:SPN、Feistel、Luby-Rackoff、Merkle-Damgård、KEM/DEM、Hash-and-Sign、Fiat-Shamir。
148
+ - **§9 ROM**:定义、extractability/programmability、争议、Canetti 反例。
149
+ - **§10 攻击模型**:攻击层级、延展性、侧信道与实现攻击、敌手建模。
150
+ - **§11 关键定理与不可能性**:Shannon 界、确定性公钥不可 CPA、CPA⇔多重(公钥)、DDH⇒ElGamal CPA、EtM⇒CCA、Merkle-Damgård 抗碰撞提升。
151
+ - **§12 证明工具箱**:直接模拟、嵌入挑战、随机猜测放大、ROM oracle 检查;并/差/switching lemma。
152
+ - **§13 信息论 vs 计算**:哲学分野、三重放松、何时用何框架。
153
+ - **§14 领域设计原则**:对称/公钥/Hash/签名各自的工程铁律。
154
+ - **§15 数学工具参考**:数论、群论、概率、渐近速查。
155
+ - **§16 跨域迁移**:威胁建模方法论、可迁移概念(优势量化、合成不保安全、必要 vs 充分、假设最小化、可证明安全的局限)。
@@ -2,6 +2,19 @@
2
2
 
3
3
  > This file is extracted from `../skills/math-research-activator/SKILL.en.md` for reference when the full catalogs are needed. SKILL.en.md retains condensed summaries with links to this file.
4
4
 
5
+ ## Domain Router Overview (v3.2.0)
6
+
7
+ > Full definition: see the Domain Router section in `../skills/math-research-activator/SKILL.en.md`. Only a summary table here:
8
+
9
+ | Domain | Loaded Content | Signal Keywords |
10
+ |--------|----------------|------------------|
11
+ | **AI Research** | `../knowledge-base/` (7 domains, 31 anchors) + `../design-patterns/` (5 types, 22 patterns) + 7 AI books | attention/loss/routing/representation/compression/MoE/transformer/KV-cache/LoRA/SSM/diffusion/RL |
12
+ | **Cryptography** | 3 crypto books + shared math anchors (on demand) | encryption/signature/MAC/PRF/PRG/PRP/OWF/CCA/CPA/AE/ZK/reduction/DL/CDH/DDH/RSA/ECC/lattice |
13
+ | **Pure Math** | `../lenses/` + corresponding `../knowledge-base/` anchors | probability/information/entropy/group/ring/field/matrix/spectrum/optimization/convexity/perturbation/complexity |
14
+ | **AI×Crypto** | dual-domain load + intersection annotation | "PRF for watermarking," "adversarial example reduction," "verifiable inference" |
15
+
16
+ > Core rules: domain judgment precedes lens invocation; shared math loads on demand by problem structure (not by domain tag); no pollution across non-cross domains; gap-protocol temporary cards are domain-tagged.
17
+
5
18
  ## Language Routing & Mixed-Input Rules (Full Version)
6
19
 
7
20
  Language routing only determines "which language version to read" and "what language to respond in." It does NOT affect whether the math system triggers or the A/B/C/D/E scenario classification.
@@ -75,6 +88,18 @@ Each design pattern answers: Mathematical origin, AI module form, implementable
75
88
  | Representation | `../design-patterns/representation/` | shared-private-decomposition, manifold-representation, equivariant-split, subspace-alignment |
76
89
  | Compression | `../design-patterns/compression/` | low-rank-kv-cache, spectral-token-pruning, topology-preserving-compression, leverage-score-selection |
77
90
 
91
+ ## Cryptography Book Distillations (3 New Books)
92
+
93
+ The reference layer now covers 10 books. The following three support cryptographic security definitions, constructions, reduction proofs, and protocol analysis. Their contents are already in English, so they intentionally use the ordinary .md suffix without a CN/EN split (unlike the AI-direction books which are paired CN/EN; crypto books are English-only, hence no .en.md version).
94
+
95
+ | Book | File | Primary Use | Activation Family |
96
+ |------|------|-------------|--------------------|
97
+ | Boneh & Shoup, *A Graduate Course in Applied Cryptography* | `books/applied-cryptography.md` | Attack games, reduction proofs, symmetric/public-key constructions, zero knowledge, and protocols | Definitions/Reductions/Primitives/Protocols |
98
+ | Goldreich, *Foundations of Cryptography, Volume 1: Basic Tools* | `books/foundations-of-cryptography.md` | Computational indistinguishability, OWF/PRG/PRF, zero knowledge, and commitments | Definitions/Proofs/Constructions/Meta-theorems |
99
+ | Katz & Lindell, *Introduction to Modern Cryptography*, 2nd ed. | `books/introduction-to-modern-cryptography.md` | Formal security definitions, IND/CCA, MACs, hashing, and digital signatures | Definitions/Proofs/Primitives/Assumptions/Constructions |
100
+
101
+ > **Domain Router note**: These three books belong to the **Cryptography Layer** and are loaded only when Domain Router determines the problem is cryptography or AI×crypto intersection. Pure AI problems do not load them. Shared math anchors (probability/information/algebra) are loaded on demand without redundancy.
102
+
78
103
  ## Workflow Example
79
104
 
80
105
  **User**: "Design a new KV Cache compression method that preserves long-range dependencies — I don't want to just do top-k."
@@ -2,6 +2,19 @@
2
2
 
3
3
  > 本文件从 `../skills/math-research-activator/SKILL.md` 提取,供需要查阅完整目录时使用。SKILL.md 保留精简摘要和指向本文件的链接。
4
4
 
5
+ ## Domain Router 总览(v3.2.0)
6
+
7
+ > 完整定义见 `../skills/math-research-activator/SKILL.md` 的 Domain Router 小节。此处仅列摘要表:
8
+
9
+ | Domain | 加载内容 | 信号词 |
10
+ |--------|---------|--------|
11
+ | **AI 研究** | `../knowledge-base/`(7 领域 31 锚点)+ `../design-patterns/`(5 类 22 模式)+ AI 方向 7 本书 | attention/loss/routing/representation/compression/MoE/transformer/KV-cache/LoRA/SSM/扩散/RL |
12
+ | **密码学** | 3 本密码学书稿 + 共用数学锚点(按需) | 加密/签名/MAC/PRF/PRG/PRP/OWF/CCA/CPA/AE/零知识/归约/DL/CDH/DDH/RSA/ECC/格密码 |
13
+ | **纯数学** | `../lenses/` + `../knowledge-base/` 对应锚点 | 概率/信息/熵/群/环/域/矩阵/谱/优化/凸性/扰动/复杂度 |
14
+ | **AI×密码交叉** | 双 domain 加载 + 交叉点标注 | "PRF 做模型水印""对抗样本归约""可验证推理" |
15
+
16
+ > 核心规则:domain 判定先于透镜调用;共用数学按问题结构(非 domain 标签)按需加载;不跨域时不污染;缺口协议临时卡标注 domain。
17
+
5
18
  ## 语言路由与混合输入规则(完整版)
6
19
 
7
20
  语言路由只决定"读取哪个语言版本的说明"和"最终用什么语言回答",不参与数学系统是否触发、也不参与 A/B/C/D/E 场景判断。
@@ -75,6 +88,18 @@
75
88
  | 表示 | `../design-patterns/representation/` | shared-private-decomposition, manifold-representation, equivariant-split, subspace-alignment |
76
89
  | 压缩 | `../design-patterns/compression/` | low-rank-kv-cache, spectral-token-pruning, topology-preserving-compression, leverage-score-selection |
77
90
 
91
+ ## 密码学参考书蒸馏稿(新增 3 本)
92
+
93
+ 参考层现共 10 本书。以下 3 本用于密码学安全定义、构造、归约证明与协议分析;正文为英文蒸馏稿,不分中英(与 AI 方向书稿的中英成对并列不同;密码学书稿正文已是英文,故无 .en.md 版本)。
94
+
95
+ | 书目 | 文件 | 主要用途 | 激活家族 |
96
+ |------|------|---------|---------|
97
+ | Boneh & Shoup, *A Graduate Course in Applied Cryptography* | `books/applied-cryptography.md` | 攻击游戏、归约证明、对称/公钥构造、零知识与协议 | 定义系/归约系/原语系/协议系 |
98
+ | Goldreich, *Foundations of Cryptography, Volume 1: Basic Tools* | `books/foundations-of-cryptography.md` | 计算不可区分、OWF/PRG/PRF、零知识与承诺、元定理 | 定义系/证明系/构造系/元理系 |
99
+ | Katz & Lindell, *Introduction to Modern Cryptography*, 2nd ed. | `books/introduction-to-modern-cryptography.md` | 形式化安全定义、IND/CCA、MAC、哈希与数字签名、构造范式 | 定义系/证明系/原语系/假设系/构造系 |
100
+
101
+ > **Domain Router 提示**:这三本书属**密码学层**,仅当 Domain Router 判定问题属密码学或 AI×密码交叉时加载。纯 AI 问题不加载。共用数学锚点(概率/信息/代数)按需加载,不重复。
102
+
78
103
  ## 工作流范例
79
104
 
80
105
  **用户**:"设计新的 KV Cache 压缩方法,保留长期依赖,不想只做 top-k"
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: math-research-activator
3
3
  description: |
4
- Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, activation anchors, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer. Does NOT trigger for pure engineering tasks (debug, refactoring, hyperparameter tuning).
4
+ Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, activation anchors, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer, and cryptographic definitions, constructions, reductions, or protocol analysis. Does NOT trigger for pure engineering tasks (debug, refactoring, hyperparameter tuning).
5
5
  ---
6
6
 
7
7
 
@@ -11,7 +11,7 @@ description: |
11
11
 
12
12
  > "The thinking system does not hand out theorems, the knowledge system does not indulge in loose inspiration, and the design layer does not fake profundity."
13
13
 
14
- This system is a mathematical staff office for AI architecture innovation — not an arsenal, but one that tells you: **what kind of battle this is, which arms to deploy, how to deploy them, and where things could go wrong.**
14
+ This system is a mathematical staff office for AI architecture innovation and cryptographic research — not an arsenal, but one that tells you: **what kind of battle this is, which arms to deploy, how to deploy them, and where things could go wrong.**
15
15
 
16
16
  ## Core Principle
17
17
 
@@ -31,31 +31,10 @@ This system is a mathematical staff office for AI architecture innovation — no
31
31
 
32
32
  Auxiliary layers:
33
33
  - `../../references/books/*.en.md`: Distilled notes from 7 textbooks; full context when deeper understanding is needed
34
+ - `../../references/books/applied-cryptography.md`, `../../references/books/foundations-of-cryptography.md`, `../../references/books/introduction-to-modern-cryptography.md`: 3 English-language cryptography distillations; see `../../references/skill-index.en.md`
34
35
  - `../../references/gpu-friendly-math.en.md`: GPU Eight-Dimension Acceptance Gate (single source of truth)
35
36
  - `../../agents/math-critic.en.md`: Math-engineering dual critic
36
37
 
37
- ## Intent Diagnosis (5 Scenarios)
38
-
39
- | Scenario | Diagnostic Signal | Invocation Path |
40
- |----------|------------------|-----------------|
41
- | **A. Problem Analysis** | "Is this design sound?" "Are there gaps in the reasoning chain?" | Lenses → critic |
42
- | **B. Mechanism Design** | "Design a new attention mechanism" "Transfer X to Y" | Lenses → Anchors → Design → critic |
43
- | **C. Knowledge Query** | "What is a tangent space on a manifold?" "How is the projection theorem applied?" | Anchors |
44
- | **D. Verification & Review** | "Does this formula hold?" "What guarantees does this loss provide?" | Anchors → relevant design patterns (if a concrete AI construct is cited) → critic |
45
- | **E. Pure Engineering** | Debugging, refactoring, hyperparameter tuning, code review | **Do not invoke the math system** |
46
-
47
- ## Lens Library (15 Mathematical Perspectives)
48
-
49
- 15 lenses covering: Axiomatization, Duality, Symmetry, Spectral Decomposition, Geometric, Projection & Decomposition, Variational, Local-to-Global, Topological, Categorical, Perturbation, Causal, Game-Theoretic, Probabilistic & Statistical, Algorithmic. Directory: `../../lenses/*.en.md`. Full catalog table: `../../references/skill-index.en.md`.
50
-
51
- ## Activation Anchors (Organized by Mathematical Domain)
52
-
53
- 7 domains: Matrix Analysis, Optimization, Differential Geometry, Lie Theory, Topology, Probability & Information, Information Geometry. Directory: `../../knowledge-base/*/*.en.md`. Full catalog table: `../../references/skill-index.en.md`.
54
-
55
- ## Design Pattern Library (Organized by AI Component)
56
-
57
- 5 component types: Attention, Loss Functions, Routing, Representation, Compression. Directory: `../../design-patterns/*/*.en.md`. Full catalog table: `../../references/skill-index.en.md`.
58
-
59
38
  ## Automatic Trigger Conditions
60
39
 
61
40
  **All of Gate 1 + Gate 2 + Gate 3 must be satisfied simultaneously for intervention:**
@@ -64,36 +43,85 @@ Auxiliary layers:
64
43
  The following tasks **never** trigger the system regardless of workspace contents: code review, debugging, refactoring, hyperparameter tuning, build/deployment, purely factual queries, general software engineering.
65
44
 
66
45
  ### Gate 1 · Environment Signal
67
- The workspace contains architecture-level core code (attention/transformer/MoE, `*.cu`/kernel) or research notes. Routine files like `model.py` or `trainer.py` alone **do not** constitute an environment signal.
46
+ The workspace contains architecture-level core code (attention/transformer/MoE, `*.cu`/kernel) or research notes, **or** cryptography-related code / protocol descriptions / security proof drafts. Routine files like `model.py` or `trainer.py` alone **do not** constitute an environment signal.
68
47
 
69
48
  ### Gate 2 · Task Signal
70
- The user's task involves **designing/improving** a new architecture/operator, **analyzing** theoretical properties, **transferring** mathematical structures into AI design, or **querying math knowledge relevant to AI research** (e.g., "how is tangent space used in optimization?"). Pure encyclopedic math queries (e.g., "what is a group?" with no AI context) do not auto-trigger, but can be accessed via `/ask`.
49
+ The user's task involves **designing/improving** a new architecture/operator, **analyzing** theoretical properties, **transferring** mathematical structures into AI design, **analyzing cryptographic constructions/security definitions/reduction proofs/protocols**, or **querying math knowledge relevant to AI research** (e.g., "how is tangent space used in optimization?"). Pure encyclopedic math or cryptography fact queries do not auto-trigger, but can be accessed via `/ask`.
71
50
 
72
51
  ### Gate 3 · Intent Match
73
52
  The user's intent matches one of scenarios A/B/C/D. Pure engineering tasks matching scenario E → no intervention.
74
53
 
75
54
  > **`/ask` entry**: Manual invocation skips Gate 1 and Gate 2, executing only Gate 0 (exclusion) + Gate 3 (intent match), allowing direct access to any scenario including knowledge queries.
76
55
 
56
+ ## Domain Router (new in v3.2.0)
57
+
58
+ > AI research and cryptography **share** mathematical foundations but each has **exclusive** specialty layers. After intent diagnosis and before lens invocation, Domain Router determines the problem's domain and decides which anchors/books/design patterns to load, avoiding cross-domain pollution and token waste.
59
+
60
+ ### Three-Layer Domain Classification
61
+
62
+ | Layer | Signal Keyword Examples | Loaded Content | Exclusive/Shared |
63
+ |-------|------------------------|----------------|-------------------|
64
+ | **AI Research Layer** | attention, loss, routing, representation, compression, MoE, transformer, KV-cache, LoRA, SSM, diffusion, RL | `../../knowledge-base/` (7 domains, 31 anchors) + `../../design-patterns/` (5 types, 22 patterns) + 7 AI books | AI-exclusive |
65
+ | **Cryptography Layer** | encryption, signature, MAC, PRF/PRG/PRP, OWF, CCA, CPA, AE, zero-knowledge, reduction proof, attack game, DL/CDH/DDH, RSA, ECC, lattice crypto | 3 crypto books + shared math anchors (on demand) + temporary knowledge cards | Crypto-exclusive |
66
+ | **Shared Math Layer** | probability, information theory, entropy, group, ring, field, matrix, spectrum, optimization, convexity, perturbation, complexity | Corresponding anchors in `../../knowledge-base/` + `../../lenses/` lenses | Shared |
67
+
68
+ ### Routing Rules
69
+
70
+ 1. **Judge domain first**: Determine primary domain (AI / Crypto / pure math query) from user keywords.
71
+ 2. **No redundant loading of shared math**: If the domain is cryptography, load shared math anchors (e.g., `../../knowledge-base/probability/entropy.md`, `../../knowledge-base/matrix-analysis/spectral-decomposition.md`) on demand; do **NOT** load AI-exclusive `../../design-patterns/`.
72
+ - **"On demand" criterion**: Load if and only if the problem's mathematical structure maps to that shared anchor's core definition/formulas — i.e., the problem statement explicitly mentions the anchor's core concept (e.g., "spectrum," "entropy," "convex," "perturbation"), or a lens/critic explicitly routes to it. **The domain tag does not decide whether shared anchors load; the problem structure does.**
73
+ 3. **Explicit annotation on cross-domain**: If the problem is genuinely AI×crypto intersection (e.g., "use PRF for model watermarking," "reduction proof for adversarial examples"), Domain Router explicitly lists both domains' loaded items and annotates intersection points.
74
+ - **Intersection annotation template** (4-tuple, feeds critic dim 19 checkpoint 6):
75
+ 1. **Crypto primitive + security property** (e.g., "PRF + pseudorandomness")
76
+ 2. **AI module + functional requirement** (e.g., "watermark + unique traceability")
77
+ 3. **Transfer direction** (crypto→AI / AI→crypto)
78
+ 4. **Assumption achievability after transfer** (Is the original assumption still achievable in the AI scenario? E.g., "Is the PRF assumption satisfiable in ML deployment?")
79
+ 4. **No pollution when not cross-domain**: Pure AI problems do not load cryptography books; pure crypto problems do not load AI design patterns. Avoids token waste and conceptual confusion.
80
+ 5. **Domain-tagged gap protocol**: Temporary knowledge cards generated by Knowledge Gap Protocol are tagged with domain (AI/Crypto/Shared) for subsequent upgrade to corresponding formal cards.
81
+
82
+ ### Domain Router Decision Flow
83
+
84
+ ```
85
+ User question
86
+
87
+ [Gate 0-3 triggered?]
88
+ ↓ yes
89
+ Domain Router: keyword-based primary domain judgment
90
+ ├─ AI research → load knowledge-base + design-patterns + AI books
91
+ ├─ Cryptography → load crypto books + shared math anchors (on demand)
92
+ ├─ Pure math → only load lenses + corresponding knowledge-base anchors
93
+ └─ AI×Crypto → dual-domain load + intersection annotation
94
+
95
+ [Scenario A/B/C/D routing]
96
+
97
+ [Lenses → anchors/books → design translation (AI only) / reduction template (crypto only) → critic]
98
+ ```
99
+
77
100
  ## Main Workflow
78
101
 
79
102
  ### Step 1: Diagnose Intent
80
103
  1. Determine which scenario (A/B/C/D/E) the user's intent belongs to
81
- 2. Extract the core tension of the problem: what to preserve? what to suppress? what are the constraints? what is the engineering bottleneck?
82
- 3. Output a problem-type classification
104
+ 2. **Domain Router judgment**: problem domain (AI / Crypto / pure math / intersection)
105
+ 3. Extract the core tension of the problem: what to preserve? what to suppress? what are the constraints? what is the engineering bottleneck?
106
+ 4. Output a problem-type classification + domain tag
83
107
 
84
108
  ### Step 2: Route Invocation
85
109
 
86
110
  ```
87
111
  Scenario A (Analysis): Select 1–3 lenses → output perspective diagnosis → critic review
88
112
  Scenario B (Design): Select 1–3 lenses → invoke relevant activation anchors; if no coverage, enter Knowledge Gap Protocol → generate formal/temporary design patterns → critic review
89
- Scenario C (Query): Prefer loading relevant activation anchors; if no coverage, generate temporary knowledge card → output per knowledge activation protocol
113
+ · AI domain: design patterns from design-patterns/; output attention/loss/routing/representation/compression
114
+ · Crypto domain: design patterns from cryptography books' construction paradigms (SPN/Feistel/Merkle-Damgård/KEM-DEM/Fiat-Shamir); output encryption/MAC/signature/protocols
115
+ Scenario C (Query): Prefer loading relevant activation anchors or crypto books; if no coverage, generate temporary knowledge card → output per knowledge activation protocol
90
116
  Scenario D (Verification): Load relevant anchors or temporary knowledge cards → critic reviews conditions and boundaries
117
+ · AI domain: pass GPU Eight-Dimension Acceptance Gate
118
+ · Crypto domain: pass reduction tightness + assumption dependency + implementation pitfall checks (GPU gate not required)
91
119
  Scenario E (Engineering): No intervention
92
120
  ```
93
121
 
94
122
  ### Step 3: Output Format
95
123
 
96
- **Token-economy rule**: The following is the maximum structure, not the default full template. Trim to the user's question; for simple knowledge queries, provide only the needed definition / formula / risk. Expand design and GPU sections only when relevant, and do not restate loaded cards verbatim.
124
+ **Token-economy rule**: The following is the maximum structure, not the default full template. Trim to the user's question; for simple knowledge queries, provide only the needed definition / formula / risk. Expand design and GPU/reduction sections only when relevant, and do not restate loaded cards verbatim. **After Domain Router determines the domain, only expand the domain-specific subsection.**
97
125
 
98
126
  **Scenario A/B Output**:
99
127
  1. **[Diagnosis]** Problem type + core tension
@@ -137,7 +165,7 @@ See the quantitative checklist in `../../references/gpu-friendly-math.en.md`.
137
165
  ## Depth-of-Consultation Protocol
138
166
 
139
167
  - **Light**: Read knowledge cards (`../../knowledge-base/*/*.en.md`); self-contained and immediately usable
140
- - **Medium**: Read distilled book notes (`../../references/books/*.en.md`) for more complete context
168
+ - **Medium**: Read distilled book notes (`../../references/books/*.en.md`) for more complete context; for cryptography, also consult the 3 English-language `.md` files listed in `../../references/skill-index.en.md`
141
169
  - **Deep**: When `math_book/<PDF>` is available locally, the agent automatically runs `pdftotext` + grep to locate the original page
142
170
 
143
171
  ## Knowledge Gap Protocol
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: math-research-activator
3
3
  description: |
4
- 数学研究操作系统:自动诊断用户意图,路由到思想透镜、激活锚点或设计翻译层。触发于设计/改进模型架构/算子/注意力、分析理论性质、迁移数学结构到 AI 设计。不触发于纯工程任务(debug、重构、调参)。
5
- English: Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, activation anchors, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer. Does NOT trigger for pure engineering tasks.
4
+ 数学研究操作系统:自动诊断用户意图,路由到思想透镜、激活锚点或设计翻译层。触发于设计/改进模型架构/算子/注意力、分析理论性质、迁移数学结构到 AI 设计,以及密码学安全定义、构造、归约证明与协议分析。不触发于纯工程任务(debug、重构、调参)。
5
+ English: Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, activation anchors, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer, and cryptographic definitions, constructions, reductions, or protocol analysis. Does NOT trigger for pure engineering tasks.
6
6
  ---
7
7
 
8
8
  > **语言路由与混合输入规则**:看句式/动词/语气词主框架判定主语言。AI/数学/工程术语不计入。代码/路径/公式不计入。中英接近时沿用上一轮,无上下文默认中文。显式要求优先。中文→本文件,英文→`SKILL.en.md`。完整规则见 `../../references/skill-index.md`。
@@ -11,7 +11,7 @@ description: |
11
11
 
12
12
  > "思想系统不负责给定理,知识系统不负责乱启发,设计层不负责装深刻。"
13
13
 
14
- 本系统是面向 AI 架构创新的数学参谋部——不是武器库,而是告诉你:**这场仗是什么仗、该用什么兵种、怎么部署、哪里会翻车。**
14
+ 本系统是面向 AI 架构创新与密码学研究的数学参谋部——不是武器库,而是告诉你:**这场仗是什么仗、该用什么兵种、怎么部署、哪里会翻车。**
15
15
 
16
16
  ## 核心原则
17
17
 
@@ -30,7 +30,7 @@ description: |
30
30
  | **设计翻译** | 把数学变成 AI 模块/loss/算子 | `../../design-patterns/*/*.md` | 这些数学怎么变成模型结构? |
31
31
 
32
32
  辅助层:
33
- - `../../references/books/*.md`:7 本书的蒸馏稿,需要深入时的完整上下文
33
+ - `../../references/books/*.md`:10 本书的蒸馏稿,需要深入时的完整上下文;其中 3 本密码学书稿见 `../../references/skill-index.md`
34
34
  - `../../references/gpu-friendly-math.md`:GPU 八维验收门(唯一权威)
35
35
  - `../../agents/math-critic.md`:数学-工程双重批判器
36
36
 
@@ -64,36 +64,85 @@ description: |
64
64
  以下任务**无论工作区含什么**都不触发:代码审查、debug、重构、调参、构建部署、纯事实查询、通用软件工程。
65
65
 
66
66
  ### Gate 1 · 环境信号
67
- 工作区含架构核心代码(attention/transformer/MoE、`*.cu`/kernel)或研究笔记。仅 `model.py`、`trainer.py` 等常规文件**不构成**环境信号。
67
+ 工作区含架构核心代码(attention/transformer/MoE、`*.cu`/kernel)或研究笔记,**或**密码学相关代码/协议描述/安全证明草稿。仅 `model.py`、`trainer.py` 等常规文件**不构成**环境信号。
68
68
 
69
69
  ### Gate 2 · 任务信号
70
- 用户任务涉及**设计/改进**新架构/算子、**分析**理论性质、**迁移**数学结构到 AI 设计,或**查询与 AI 研究相关的数学知识**(如"切空间在优化中怎么用")。纯百科式数学查询(如"什么是群"且无 AI 上下文)不自动触发,但可通过 `/ask` 手动进入。
70
+ 用户任务涉及**设计/改进**新架构/算子、**分析**理论性质、**迁移**数学结构到 AI 设计、**分析密码学构造/安全定义/归约证明/协议**,或**查询与 AI 研究相关的数学知识**(如"切空间在优化中怎么用")。纯百科式数学或密码学事实查询不自动触发,但可通过 `/ask` 手动进入。
71
71
 
72
72
  ### Gate 3 · 意图匹配
73
73
  用户意图匹配场景 A/B/C/D 之一。纯工程任务匹配场景 E → 不介入。
74
74
 
75
75
  > **`/ask` 入口**:手动调用时跳过 Gate 1 和 Gate 2,仅执行 Gate 0(排除门)+ Gate 3(意图匹配),可直接进入任意场景包括知识查询。
76
76
 
77
+ ## Domain Router(v3.2.0 新增)
78
+
79
+ > AI 研究与密码学**共享**数学根基,但**独有**各自的专业层。Domain Router 在意图诊断后、调用透镜前,先判定问题归属,决定加载哪些锚点/书稿/设计模式,避免跨域污染与 token 浪费。
80
+
81
+ ### 三层归属判定
82
+
83
+ | 层 | 信号词示例 | 加载内容 | 独有/共用 |
84
+ |----|-----------|---------|----------|
85
+ | **AI 研究层** | attention、loss、routing、representation、compression、MoE、transformer、KV-cache、LoRA、SSM、扩散、RL | `../../knowledge-base/`(7 领域 31 锚点)+ `../../design-patterns/`(5 类 22 模式)+ AI 方向 7 本书 | AI 独有 |
86
+ | **密码学层** | 加密、签名、MAC、PRF/PRG/PRP、OWF、CCA、CPA、AE、零知识、归约证明、攻击游戏、DL/CDH/DDH、RSA、ECC、格密码 | 3 本密码学书稿 + 共用数学锚点(按需)+ 临时知识卡 | 密码独有 |
87
+ | **共用数学层** | 概率、信息论、熵、群、环、域、矩阵、谱、优化、凸性、扰动、复杂度 | `../../knowledge-base/` 中的对应锚点 + `../../lenses/` 透镜 | 共用 |
88
+
89
+ ### 路由规则
90
+
91
+ 1. **先判 domain**:从用户关键词判定主 domain(AI / 密码 / 纯数学查询)。
92
+ 2. **共用数学不重复加载**:若 domain 是密码学,共用数学锚点(如 `../../knowledge-base/probability/entropy.md`、`../../knowledge-base/matrix-analysis/spectral-decomposition.md`)按需加载,**不**加载 AI 专属的 `../../design-patterns/`。
93
+ - **"按需"判定条件**:当且仅当问题的数学结构映射到该共用锚点的核心定义/公式时加载。即问题陈述中显式出现该锚点对应的核心概念(如"谱""熵""凸""扰动"),或透镜路由/critic 明确指向该锚点。**domain 标签不决定共用锚点加载与否,问题结构决定。**
94
+ 3. **跨域时显式标注**:若问题确实是 AI×密码交叉(如"用 PRF 做模型水印""对抗样本的归约证明"),Domain Router 显式列出两个 domain 的加载项,并标注交叉点。
95
+ - **交叉点标注模板**(四元组,供 critic 第 19 维第 6 检查点审查):
96
+ 1. **密码学原语 + 安全性质**(如"PRF + 伪随机性")
97
+ 2. **AI 模块 + 功能需求**(如"水印 + 唯一可追踪性")
98
+ 3. **迁移方向**(密码→AI / AI→密码)
99
+ 4. **迁移后假设可达性**(原假设在 AI 场景是否仍可达成?如"PRF 的 PRF 假设在 ML 部署中是否可满足")
100
+ 4. **不跨域时不污染**:纯 AI 问题不加载密码学书稿;纯密码学问题不加载 AI 设计模式。避免 token 浪费与概念混淆。
101
+ 5. **缺口协议分 domain**:Knowledge Gap Protocol 生成的临时知识卡标注 domain(AI/密码/共用),便于后续升级到对应正式卡片。
102
+
103
+ ### Domain Router 判定流程图
104
+
105
+ ```
106
+ 用户问题
107
+
108
+ [Gate 0-3 触发?]
109
+ ↓ 是
110
+ Domain Router: 关键词判定主 domain
111
+ ├─ AI 研究 → 加载 knowledge-base + design-patterns + AI 书稿
112
+ ├─ 密码学 → 加载密码学书稿 + 共用数学锚点(按需)
113
+ ├─ 纯数学 → 只加载 lenses + 对应 knowledge-base 锚点
114
+ └─ AI×密码 → 双 domain 加载 + 交叉点标注
115
+
116
+ [场景 A/B/C/D 路由]
117
+
118
+ [透镜 → 锚点/书稿 → 设计翻译(仅 AI)/ 归约模板(仅密码)→ critic]
119
+ ```
120
+
77
121
  ## 主流程
78
122
 
79
123
  ### 第一步:诊断意图
80
124
  1. 判断用户意图属于场景 A/B/C/D/E 哪个
81
- 2. 提取问题核心张力:想保留什么?想抑制什么?约束是什么?工程瓶颈是什么?
82
- 3. 输出问题类型分类
125
+ 2. **Domain Router 判定**:问题归属(AI / 密码 / 纯数学 / 交叉)
126
+ 3. 提取问题核心张力:想保留什么?想抑制什么?约束是什么?工程瓶颈是什么?
127
+ 4. 输出问题类型分类 + domain 标注
83
128
 
84
129
  ### 第二步:路由调用
85
130
 
86
131
  ```
87
132
  场景 A(分析):选 1-3 个透镜 → 输出视角诊断 → critic 审查
88
133
  场景 B(设计):选 1-3 个透镜 → 调用相关激活锚点;若无覆盖则进入 Knowledge Gap Protocol → 生成正式/临时设计模式 → critic 审查
89
- 场景 C(查询):优先加载相关激活锚点;若无覆盖则生成临时知识卡 按知识激活协议输出
134
+ · AI domain:设计模式来自 design-patterns/,产出 attention/loss/routing/representation/compression
135
+ · 密码 domain:设计模式来自密码学书稿的构造范式(SPN/Feistel/Merkle-Damgård/KEM-DEM/Fiat-Shamir),产出加密/MAC/签名/协议
136
+ 场景 C(查询):优先加载相关激活锚点或密码学书稿;若无覆盖则生成临时知识卡 → 按知识激活协议输出
90
137
  场景 D(验证):加载相关锚点或临时知识卡 → critic 审查条件与边界
138
+ · AI domain:过 GPU 八维验收门
139
+ · 密码 domain:过归约紧度 + 假设依赖 + 实现陷阱检查(不必过 GPU 门)
91
140
  场景 E(工程):不介入
92
141
  ```
93
142
 
94
143
  ### 第三步:输出格式
95
144
 
96
- **Token 经济原则**:以下是最长结构,不是默认全文模板。按用户问题裁剪;简单知识查询只给必要定义/公式/风险,设计与 GPU 内容只在与问题有关时展开;避免复述已加载卡片全文。
145
+ **Token 经济原则**:以下是最长结构,不是默认全文模板。按用户问题裁剪;简单知识查询只给必要定义/公式/风险,设计与 GPU/归约内容只在与问题有关时展开;避免复述已加载卡片全文;**Domain Router 已判定 domain 后,只展开该 domain 的专属小节**。
97
146
 
98
147
  **场景 A/B 输出**:
99
148
  1. **[诊断]** 问题类型 + 核心张力
@@ -137,7 +186,7 @@ description: |
137
186
  ## 深度查阅协议
138
187
 
139
188
  - **轻度**:读知识卡片(`../../knowledge-base/*/*.md`),自足可用
140
- - **中度**:读书蒸馏稿(`../../references/books/*.md`),获取更完整上下文
189
+ - **中度**:读书蒸馏稿(`../../references/books/*.md`),获取更完整上下文;密码学问题优先查阅 `../../references/skill-index.md` 列出的 3 本专门书稿
141
190
  - **深度**:本机有 `math_book/<PDF>` 时,Agent 自动 `pdftotext` + grep 定位原文页
142
191
 
143
192
  ## 知识缺口协议 / Knowledge Gap Protocol