Skip to content

Commit e4d7d34

Browse files
authored
elliptic-curve: remove bits feature (#2417)
I was not able to find any users of it searching GitHub. This feature is backed by `bitvec` which both has a high number of transitive dependencies which have been minorly problematic (#2414), but also my understanding based on Zulip discussions on #t-opsem is that `bitvec` is not sound under either stacked or tree borrows, which makes it a bit worrisome for use in cryptographic applications. We can always add the feature back if it turns out there are users, but if not it seems like it's not worth the maintenance burden.
1 parent d2cf1f9 commit e4d7d34

5 files changed

Lines changed: 5 additions & 134 deletions

File tree

.github/workflows/elliptic-curve.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
4747
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc
4848
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic
49-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features bits
5049
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features critical-section
5150
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features dev
5251
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features digest
@@ -104,6 +103,6 @@ jobs:
104103
- uses: actions/checkout@v6
105104
- uses: dtolnay/rust-toolchain@stable
106105
with:
107-
toolchain: nightly-2026-02-11 # pinned due to rust-lang/miri#4855
106+
toolchain: nightly-2026-05-01 # pinned due to ensure determinism
108107
- run: rustup component add miri && cargo miri setup
109108
- run: cargo miri test --all-features

Cargo.lock

Lines changed: 4 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

elliptic-curve/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pem-rfc7468 = { version = "1", optional = true, features = ["alloc"] }
3636
pkcs8 = { version = "0.11", optional = true, default-features = false }
3737
sec1 = { version = "0.8", optional = true, features = ["ctutils", "subtle", "zeroize"] }
3838
serdect = { version = "0.4", optional = true, default-features = false, features = ["alloc"] }
39-
tap = { version = "1.0.1", optional = true, default-features = false } # make `bitvec`'s `wyz` work with `minimal-versions`
4039

4140
[dev-dependencies]
4241
hex-literal = "1"
@@ -62,7 +61,6 @@ std = [
6261
arithmetic = ["group"]
6362
basepoint-table = ["arithmetic"]
6463
critical-section = ["basepoint-table", "once_cell/critical-section"]
65-
bits = ["dep:tap", "arithmetic", "ff/bits"]
6664
dev = ["arithmetic", "dep:hex-literal", "pem", "pkcs8"]
6765
ecdh = ["arithmetic", "digest", "dep:hkdf"]
6866
getrandom = ["arithmetic", "bigint/getrandom", "common/getrandom"]

elliptic-curve/src/dev/mock_curve.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ use pkcs8::AssociatedOid;
3131

3232
#[cfg(feature = "alloc")]
3333
use alloc::vec::Vec;
34-
#[cfg(feature = "bits")]
35-
use ff::PrimeFieldBits;
3634

3735
/// Pseudo-coordinate for fixed-based scalar mult output
3836
pub const PSEUDO_COORDINATE_FIXED_BASE_MUL: [u8; 32] =
@@ -56,10 +54,6 @@ pub type SecretKey = crate::SecretKey<MockCurve>;
5654
/// Scalar value type.
5755
pub type ScalarValue = crate::ScalarValue<MockCurve>;
5856

59-
/// Scalar bits.
60-
#[cfg(feature = "bits")]
61-
pub type ScalarBits = crate::scalar::ScalarBits<MockCurve>;
62-
6357
/// Mock elliptic curve type useful for writing tests which require a concrete
6458
/// curve type.
6559
///
@@ -161,23 +155,6 @@ impl PrimeField for Scalar {
161155
}
162156
}
163157

164-
#[cfg(feature = "bits")]
165-
impl PrimeFieldBits for Scalar {
166-
#[cfg(target_pointer_width = "32")]
167-
type ReprBits = [u32; 8];
168-
169-
#[cfg(target_pointer_width = "64")]
170-
type ReprBits = [u64; 4];
171-
172-
fn to_le_bits(&self) -> ScalarBits {
173-
self.0.as_uint().to_words().into()
174-
}
175-
176-
fn char_le_bits() -> ScalarBits {
177-
MockCurve::ORDER.to_words().into()
178-
}
179-
}
180-
181158
impl Generate for Scalar {
182159
fn try_generate_from_rng<R: TryCryptoRng + ?Sized>(
183160
rng: &mut R,

elliptic-curve/src/scalar.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ use crate::CurveArithmetic;
2121
#[cfg(feature = "arithmetic")]
2222
pub type Scalar<C> = <C as CurveArithmetic>::Scalar;
2323

24-
/// Bit representation of a scalar field element of a given curve.
25-
#[cfg(feature = "bits")]
26-
pub type ScalarBits<C> = ff::FieldBits<<Scalar<C> as ff::PrimeFieldBits>::ReprBits>;
27-
2824
/// Instantiate a scalar from an unsigned integer without checking for overflow.
2925
pub trait FromUintUnchecked {
3026
/// Unsigned integer type (i.e. `Curve::Uint`)

0 commit comments

Comments
 (0)