Skip to content

Fix Identity encryption to derive keys from the transmitted ephemeral key #34

@doubleailes

Description

@doubleailes

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:
    1. Generate ephemeral X25519 secret
    2. Derive shared secret with target public key
    3. HKDF with recipient identity hash as salt
    4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions