Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,31 @@
# silicon) is a fifth opt-in mode — see § 7.1 of
# .claude/knowledge/simd-dispatch-architecture.md. Reserved for the
# release-binary distribution path; never the dev / CI default.
# curve25519-dalek backend: SERIAL, deliberately.
#
# `ed25519-dalek` pulls in `curve25519-dalek`, whose build.rs AUTO-SELECTS its
# own AVX2 backend whenever the target is x86_64 + 64-bit — which the
# `-Ctarget-cpu=x86-64-v3` line below guarantees. That backend carries its own
# raw intrinsics and its own `unsafe`: 57 `_mm*` intrinsic calls (35 in
# `backend/vector/avx2/field.rs`, 22 in `backend/vector/packed_simd.rs`) under
# 52 `unsafe` occurrences in the same two files — a SECOND unaudited SIMD
# surface beside `ndarray::simd`, which is exactly what the matryoshka pattern
# exists to prevent (cf. `vendor/chacha20`: "no raw intrinsics and no `unsafe`
# here — all of that lives once, audited, inside `ndarray::simd`").
#
# Note this is a REACHABILITY question, not a porting one. Neutralizing that
# surface does not require porting 57 call sites onto `ndarray::simd`; the whole
# `vector` module is gated behind one cfg — `backend/mod.rs:42`,
# `#[cfg(curve25519_dalek_backend = "simd")] pub mod vector;` — so the one line
# below compiles the whole surface out.
#
# `serial` costs nothing we use: X25519's Montgomery ladder
# (`montgomery.rs`) never references the vector backend at all, and Ed25519
# signing is not on a hot path here. The vector backend serves ONLY Edwards
# multi-scalar / variable-base multiplication (batch signature verification,
# Ristretto protocols) — neither of which this crate performs.
#
# Read by curve25519-dalek's build.rs via CARGO_CFG_CURVE25519_DALEK_BACKEND.
# Verify: cargo build -p encryption -v 2>&1 | grep curve25519_dalek_backend
[target.'cfg(target_arch = "x86_64")']
rustflags = ["-Ctarget-cpu=x86-64-v3"]
rustflags = ["-Ctarget-cpu=x86-64-v3", "--cfg", "curve25519_dalek_backend=\"serial\""]
Loading
Loading