跳转至

ADR-007:面向安全感知的后量子密码学

状态

已提议

日期

2026-02-28

背景

威胁模型

WiFi-DensePose 处理的数据可能揭示: - 人员在场/缺席(私人空间中的监控风险) - 健康指标(通过呼吸/心跳检测,涉及医疗隐私) - 移动模式(行为画像) - 建筑占用情况(物理安全情报)

在灾难场景(wifi-densepose-mat)中,风险更高: - 分诊分类影响救援优先级(生死攸关的决策) - 幸存者位置具有行动敏感性 - 检测审计轨迹可能用于法律程序(责任认定) - 假阴性(漏检幸存者)可能接受取证调查

当前安全状况:系统使用标准 JWT(HS256)进行 API 认证,并且对静态数据、模型完整性或检测审计轨迹没有密码学保护。

量子威胁时间线

NIST 估计,具有密码学相关能力的量子计算机可能在 2030-2035 年出现。今天使用经典加密捕获的数据可能随后被追溯解密(“现在收集,以后解密”)。对于可能在基础设施中部署数十年的系统而言,提前具备后量子能力是审慎的。

RuVector 的密码学栈

RuVector 提供分层密码学系统:

算法 用途 标准 抗量子
ML-DSA-65 数字签名 FIPS 204 是(基于格)
Ed25519 数字签名 RFC 8032 否(经典回退)
SLH-DSA-128s 数字签名 FIPS 205 是(基于哈希)
SHAKE-256 哈希 FIPS 202 是
AES-256-GCM 对称加密 FIPS 197 是(Grover 算法使安全强度减半,仍为 128 位)

决策

我们将集成 RuVector 的密码学层,为 WiFi-DensePose 数据提供纵深防御,采用 混合经典+PQ 方法,同时应用 Ed25519 和 ML-DSA-65 签名(在 PQ 算法成熟之前采取双重保障)。

密码学范围

┌──────────────────────────────────────────────────────────────────┐
│              Cryptographic Protection Layers                      │
├──────────────────────────────────────────────────────────────────┤
│                                                                   │
│  1. MODEL INTEGRITY                                              │
│     ┌─────────────────────────────────────────────────────┐      │
│     │ Model weights signed with ML-DSA-65 + Ed25519       │      │
│     │ Signature verified at load time → reject tampered   │      │
│     │ SONA adaptations co-signed with device key          │      │
│     └─────────────────────────────────────────────────────┘      │
│                                                                   │
│  2. DATA AT REST (RVF containers)                                │
│     ┌─────────────────────────────────────────────────────┐      │
│     │ CSI vectors encrypted with AES-256-GCM              │      │
│     │ Container integrity via SHAKE-256 Merkle tree       │      │
│     │ Key management: per-container keys, sealed to device │      │
│     └─────────────────────────────────────────────────────┘      │
│                                                                   │
│  3. DATA IN TRANSIT                                              │
│     ┌─────────────────────────────────────────────────────┐      │
│     │ API: TLS 1.3 with PQ key exchange (ML-KEM-768)      │      │
│     │ WebSocket: Same TLS channel                         │      │
│     │ Multi-AP sync: mTLS with device certificates        │      │
│     └─────────────────────────────────────────────────────┘      │
│                                                                   │
│  4. AUDIT TRAIL (witness chains - see ADR-010)                   │
│     ┌─────────────────────────────────────────────────────┐      │
│     │ Every detection event hash-chained with SHAKE-256   │      │
│     │ Chain anchors signed with ML-DSA-65                 │      │
│     │ Cross-device attestation via SLH-DSA-128s           │      │
│     └─────────────────────────────────────────────────────┘      │
│                                                                   │
│  5. DEVICE IDENTITY                                              │
│     ┌─────────────────────────────────────────────────────┐      │
│     │ Each sensing device has a key pair (ML-DSA-65)      │      │
│     │ Device attestation proves hardware integrity        │      │
│     │ Key rotation schedule: 90 days (or on compromise)   │      │
│     └─────────────────────────────────────────────────────┘      │
└──────────────────────────────────────────────────────────────────┘

混合签名方案

/// Hybrid signature combining classical Ed25519 with PQ ML-DSA-65
pub struct HybridSignature {
    /// Classical Ed25519 signature (64 bytes)
    ed25519_sig: [u8; 64],

    /// Post-quantum ML-DSA-65 signature (3309 bytes)
    ml_dsa_sig: Vec<u8>,

    /// Signer's public key fingerprint (SHAKE-256, 32 bytes)
    signer_fingerprint: [u8; 32],

    /// Timestamp of signing
    timestamp: u64,
}

impl HybridSignature {
    /// Verify requires BOTH signatures to be valid
    pub fn verify(&self, message: &[u8], ed25519_pk: &Ed25519PublicKey,
                  ml_dsa_pk: &MlDsaPublicKey) -> Result<bool, CryptoError> {
        let ed25519_valid = ed25519_pk.verify(message, &self.ed25519_sig)?;
        let ml_dsa_valid = ml_dsa_pk.verify(message, &self.ml_dsa_sig)?;

        // Both must pass (defense in depth)
        Ok(ed25519_valid && ml_dsa_valid)
    }
}

模型完整性验证

/// Verify model weights have not been tampered with
pub fn verify_model_integrity(model_container: &ModelContainer) -> Result<(), SecurityError> {
    // 1. Extract embedded signature from container
    let signature = model_container.crypto_segment().signature()?;

    // 2. Compute SHAKE-256 hash of weight data
    let weight_hash = shake256(model_container.weights_segment().data());

    // 3. Verify hybrid signature
    let publisher_keys = load_publisher_keys()?;
    if !signature.verify(&weight_hash, &publisher_keys.ed25519, &publisher_keys.ml_dsa)? {
        return Err(SecurityError::ModelTampered {
            expected_signer: publisher_keys.fingerprint(),
            container_path: model_container.path().to_owned(),
        });
    }

    Ok(())
}

CSI 数据加密

对于隐私敏感型部署,CSI 向量可以在静态时加密:

/// Encrypt CSI vectors for storage in RVF container
pub struct CsiEncryptor {
    /// AES-256-GCM key (derived from device key + container salt)
    key: Aes256GcmKey,
}

impl CsiEncryptor {
    /// Encrypt a CSI feature vector
    /// Note: HNSW search operates on encrypted vectors using
    /// distance-preserving encryption (approximate, configurable trade-off)
    pub fn encrypt_vector(&self, vector: &[f32]) -> EncryptedVector {
        let nonce = generate_nonce();
        let plaintext = bytemuck::cast_slice::<f32, u8>(vector);
        let ciphertext = aes_256_gcm_encrypt(&self.key, &nonce, plaintext);
        EncryptedVector { ciphertext, nonce }
    }
}

性能影响

操作 无加密 有加密 开销
模型加载 50 ms 52 ms +2 ms(签名验证)
向量插入 0.1 ms 0.15 ms +0.05 ms(加密)
HNSW 搜索 0.3 ms 0.35 ms +0.05 ms(解密 top-K)
容器打开 10 ms 12 ms +2 ms(完整性检查)
检测事件日志记录 0.01 ms 0.5 ms +0.49 ms(哈希链)

功能标志

[features]
default = []
crypto-classical = ["ed25519-dalek"]  # Ed25519 only
crypto-pq = ["pqcrypto-dilithium", "pqcrypto-sphincsplus"]  # ML-DSA + SLH-DSA
crypto-hybrid = ["crypto-classical", "crypto-pq"]  # Both (recommended)
crypto-encrypt = ["aes-gcm"]  # Data-at-rest encryption
crypto-full = ["crypto-hybrid", "crypto-encrypt"]

影响

积极影响

  • 面向未来:基于格的签名可抵御量子攻击
  • 篡改检测:模型投毒和数据篡改可被检测
  • 隐私合规:加密的 CSI 数据满足 GDPR/HIPAA 要求
  • 取证完整性:带签名的审计轨迹可作为证据被采信
  • 低开销:大多数加密操作每次操作 <1ms

消极影响

  • 签名大小:ML-DSA-65 签名为 3.3 KB,而 Ed25519 为 64 字节
  • 密钥管理复杂度:设备密钥的预配、轮换和吊销
  • 加密数据上的 HNSW:距离保持加密是近似的;搜索召回率可能下降
  • 依赖体积:PQ 加密库会使二进制文件增加约 2 MB
  • 标准成熟度:FIPS 204/205 已定稿,但实现仍在演进

参考资料

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView