crypto-sm/AI.md

14 lines
650 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AI Coding Context: @go/crypto-sm
本索引供 AI 模型理解 `@go/crypto-sm` 的逻辑,以确保代码与 `@go/crypto` 行为一致。
## 🤖 AI 行为准则
1. **接口对齐**SM2/SM4 必须实现 `@go/crypto` 定义的非对称与对称加密接口。
2. **内存闭环**:所有算法构造必须默认支持 `AndEraseKey` 范式。
3. **静默原则**:解密函数推荐使用 `DecryptBytesN`(静默模式)。
## 🛠 关键算法约定
- SM2 签名强制使用 `sm2` 特有的签名接口。
- SM4 CBC/GCM 使用 `gmsm` 底层包,但 API 必须完全遵循 `Symmetric` 的设计。
- 所有输出不得包含调试日志。