Skip to content

deps: disable default features on x25519-dalek (consistency; drops ~40 KB of basepoint tables from downstreams)#369

Open
punarinta wants to merge 1 commit into
matrix-org:mainfrom
punarinta:deps/x25519-no-default-features
Open

deps: disable default features on x25519-dalek (consistency; drops ~40 KB of basepoint tables from downstreams)#369
punarinta wants to merge 1 commit into
matrix-org:mainfrom
punarinta:deps/x25519-no-default-features

Conversation

@punarinta

Copy link
Copy Markdown

Summary

vodozemac already declares default-features = false on ed25519-dalek and curve25519-dalek, signaling it does not intend to require curve25519-dalek's precomputed-tables feature. But x25519-dalek is declared with its defaults, and x25519-dalek's default set includes precomputed-tables (default = ["alloc", "precomputed-tables", "zeroize"]).

Because Cargo unifies features across the whole dependency graph, this single declaration silently re-enables curve25519-dalek/precomputed-tables for the entire build — negating the default-features = false on the other two dalek crates, and forcing the large precomputed basepoint lookup tables into every downstream binary, with no way for a downstream to opt out (Cargo has no mechanism to disable a transitively-requested feature).

Change

-x25519-dalek = { version = "2.0.1", features = ["serde", "reusable_secrets", "static_secrets", "zeroize"] }
+x25519-dalek = { version = "2.0.1", default-features = false, features = ["alloc", "serde", "reusable_secrets", "static_secrets", "zeroize"] }

alloc is re-added explicitly so the only net change to the resolved feature set is the removal of precomputed-tables.

Affected symbols

Symbol Size
curve25519_dalek::…::ED25519_BASEPOINT_TABLE_INNER_DOC_HIDDEN ~30 KB
curve25519_dalek::backend::vector::avx2::…::BASEPOINT_ODD_LOOKUP_TABLE ~10 KB

Measured impact

Measured on a downstream cdylib that links vodozemac (release: lto = true, opt-level = 3, codegen-units = 1, stripped):

before: 1,002,496 bytes
after:    965,240 bytes   (−37,256 bytes, −3.7%)

The downstream test suite (Olm session round-trips, pickling, KATs) passes unchanged — precomputed-tables is a pure size/speed trade with no behavioral effect.

Tradeoff

Disabling precomputed-tables removes the fixed-base scalar-multiplication speedup, which affects key generation (PublicKey::from(&StaticSecret)) and Ed25519 signing. It does not affect x25519 ECDH (variable-base — the hot Double Ratchet operation is unchanged). These fixed-base operations are not hot paths for typical messaging workloads, and this aligns vodozemac's actual behavior with what its ed25519-dalek/curve25519-dalek declarations already intend.

If you'd prefer to keep the speedup as the default, an alternative is to expose it as an opt-in feature (e.g. precomputed-tables = ["curve25519-dalek/precomputed-tables"]) so size-sensitive downstreams can leave it off. Happy to adjust the PR in whichever direction you prefer.

ed25519-dalek and curve25519-dalek are already declared with
default-features = false, but x25519-dalek pulls its defaults, which
include `precomputed-tables`. Cargo unifies features across the whole
dependency graph, so this single declaration silently re-enables
curve25519-dalek/precomputed-tables for the entire build and forces the
large precomputed basepoint lookup tables (~40 KB) into every downstream
binary, with no way for a downstream to opt out.

Set default-features = false on x25519-dalek for consistency with the
other two dalek crates. `alloc` is re-added explicitly so the only net
change to the resolved feature set is the removal of precomputed-tables.

x25519 ECDH (variable-base) is unaffected; only fixed-base operations
(key generation, Ed25519 signing) lose the precomputed-table speedup.
@punarinta punarinta requested review from dkasak and poljar as code owners June 27, 2026 07:24
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