Summary
For Python compatibility, the same ephemeral X25519 key that appears in the ciphertext header must be used to derive the shared secret and encryption key.
Current Rust code risks deriving keys from a different ephemeral instance, breaking interoperability.
Affected code
- src/identity.rs
- Identity::encrypt
- DerivedKey / ephemeral helpers
Required changes
- Ensure encryption flow is:
- Generate ephemeral X25519 secret
- Derive shared secret with target public key
- HKDF with recipient identity hash as salt
- Emit ephemeral_pub || token
- Remove or restrict APIs that generate independent ephemerals implicitly.
Acceptance criteria
- Deterministic test vectors match Python output.
- Rust → Python decryption works reliably.