Skip to content

Convert ed25519 public keys to their curve25519 form only when needed - #16

Open
lnjX wants to merge 1 commit into
dino:mainfrom
lnjX:lazy-curve-conversion
Open

lnjX wants to merge 1 commit into
dino:mainfrom
lnjX:lazy-curve-conversion

Conversation

@lnjX

@lnjX lnjX commented Nov 21, 2026 •

Copy link
Copy Markdown

Decoding a public key from its ed25519 form converted it to its curve25519 form and that needs a field inversion and is rather slow.

  • OMEMO 2 sessions store the identity keys in their ed25519 form. Each loaded session record converted two keys per session state, also for archived states.
  • Encrypting or decrypting a message never uses these keys in their curve25519 form.
  • The curve25519 form is computed on first use now. Like the reference counting, this assumes a key is not used from several threads at once.

Loading and storing a session record took 22.5 us without archived states and 695 us with 40. Now it takes 0.7 us and 34 us.

Decoding a public key from its ed25519 form converted it to its
curve25519 form right away, which needs a field inversion. For OMEMO 2
sessions, the identity keys are stored in their ed25519 form, so each
loaded session record converted two keys per session state, also the
archived ones. Encrypting or decrypting a message never uses them in
their curve25519 form, though.

The curve25519 form is computed on first use now. Loading and storing
a session record without archived states takes 0.7 us instead of
22.5 us, and with 40 archived states 34 us instead of 695 us.
@lnjX
lnjX marked this pull request as ready for review November 21, 2026 17:33
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant