pub struct DeviceId(/* private fields */);Expand description
Public types of device identity.
Device identity lives in qualia_dik — an independent, reusable crate that any
project needing “a pair of P-256 identity keys in platform hardware” can use
without accepting this crate’s vault format or sync protocol. They are re-exported
here so that downstream code does not have to depend on both crates.
DevicePublicKey and DeviceSignature are not secret — they are meant to be
printed on QR codes, written to logs, and propagated between devices — so they are
exported separately from the secret types, which makes it visible in an import
list which types may be printed freely.
一台设备的身份标识:设备身份公钥的 SHA-256 指纹。
§为什么是公钥的哈希,而不是随机数或自增计数
设备身份是密码学身份:两台设备没有任何共享状态就可以各自动算出同一个
DeviceId。如果改用随机数,设备就需要一个注册表来记住「哪个 ID 对应哪把公钥」;
而在一个没有中心服务器的系统里,那份注册表本身就是需要同步、需要认证、也最难
保证一致的东西。
用哈希则把「ID 与公钥必须一致」变成结构性事实:拿到 ID 就能从公钥重算出来 并比对,无法伪造,也不需要维护。
SHA-256 在这里只用于标识,不承担抗碰撞以外的密码学职责——设备身份的真实性 由签名保证,指纹只是一个便于比较的短名字。