Skip to content

Commit 445fd7d

Browse files
authored
curve,x: Clear deprecated functions (#778)
1 parent d159f47 commit 445fd7d

File tree

10 files changed

+9
-168
lines changed

10 files changed

+9
-168
lines changed

curve25519-dalek/src/backend/serial/fiat_u32/field.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,6 @@ impl FieldElement2625 {
239239
FieldElement2625(output)
240240
}
241241

242-
/// Renamed to `to_bytes`.
243-
#[deprecated(since = "4.1.4", note = "use `to_bytes` instead")]
244-
pub fn as_bytes(&self) -> [u8; 32] {
245-
self.to_bytes()
246-
}
247-
248242
/// Serialize this `FieldElement51` to a 32-byte array. The
249243
/// encoding is canonical.
250244
pub fn to_bytes(self) -> [u8; 32] {

curve25519-dalek/src/backend/serial/fiat_u64/field.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,6 @@ impl FieldElement51 {
216216
FieldElement51(output)
217217
}
218218

219-
/// Renamed to `to_bytes`.
220-
#[deprecated(since = "4.1.4", note = "use `to_bytes` instead")]
221-
pub fn as_bytes(&self) -> [u8; 32] {
222-
self.to_bytes()
223-
}
224-
225219
/// Serialize this `FieldElement51` to a 32-byte array. The
226220
/// encoding is canonical.
227221
pub fn to_bytes(self) -> [u8; 32] {

curve25519-dalek/src/backend/serial/u32/field.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,6 @@ impl FieldElement2625 {
431431
FieldElement2625::reduce(h)
432432
}
433433

434-
/// Renamed to `to_bytes`.
435-
#[deprecated(since = "4.1.4", note = "use `to_bytes` instead")]
436-
pub fn as_bytes(&self) -> [u8; 32] {
437-
self.to_bytes()
438-
}
439-
440434
/// Serialize this `FieldElement51` to a 32-byte array. The
441435
/// encoding is canonical.
442436
#[allow(clippy::identity_op)]

curve25519-dalek/src/backend/serial/u64/field.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,6 @@ impl FieldElement51 {
362362
])
363363
}
364364

365-
/// Renamed to `to_bytes`.
366-
#[deprecated(since = "4.1.4", note = "use `to_bytes` instead")]
367-
pub fn as_bytes(&self) -> [u8; 32] {
368-
self.to_bytes()
369-
}
370-
371365
/// Serialize this `FieldElement51` to a 32-byte array. The
372366
/// encoding is canonical.
373367
#[rustfmt::skip] // keep alignment of s[*] calculations

curve25519-dalek/src/backend/vector/avx2/edwards.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ mod test {
360360

361361
macro_rules! print_var {
362362
($x:ident) => {
363-
println!("{} = {:?}", stringify!($x), $x.as_bytes());
363+
println!("{} = {:?}", stringify!($x), $x.to_bytes());
364364
};
365365
}
366366

@@ -472,7 +472,7 @@ mod test {
472472

473473
macro_rules! print_var {
474474
($x:ident) => {
475-
println!("{} = {:?}", stringify!($x), $x.as_bytes());
475+
println!("{} = {:?}", stringify!($x), $x.to_bytes());
476476
};
477477
}
478478

curve25519-dalek/src/constants.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ pub const RISTRETTO_BASEPOINT_POINT: RistrettoPoint = RistrettoPoint(ED25519_BAS
6969
/// $$
7070
/// \ell = 2^\{252\} + 27742317777372353535851937790883648493.
7171
/// $$
72-
#[deprecated(since = "4.1.1", note = "Should not have been in public API")]
73-
pub const BASEPOINT_ORDER: Scalar = BASEPOINT_ORDER_PRIVATE;
74-
75-
pub(crate) const BASEPOINT_ORDER_PRIVATE: Scalar = Scalar {
72+
pub(crate) const BASEPOINT_ORDER: Scalar = Scalar {
7673
bytes: [
7774
0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde,
7875
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

curve25519-dalek/src/edwards.rs

Lines changed: 5 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ use core::ops::{Mul, MulAssign};
106106

107107
#[cfg(feature = "digest")]
108108
use digest::{
109-
Digest, FixedOutput, HashMarker, array::typenum::U64, consts::True,
110-
crypto_common::BlockSizeUser, typenum::IsGreater,
109+
FixedOutput, HashMarker, array::typenum::U64, consts::True, crypto_common::BlockSizeUser,
110+
typenum::IsGreater,
111111
};
112112

113113
#[cfg(feature = "group")]
@@ -673,41 +673,6 @@ impl EdwardsPoint {
673673
E1_opt.mul_by_cofactor()
674674
}
675675

676-
#[cfg(feature = "digest")]
677-
/// Maps the digest of the input bytes to the curve. This is NOT a hash-to-curve function, as
678-
/// it produces points with a non-uniform distribution. Rather, it performs something that
679-
/// resembles (but is not) half of the
680-
/// [`hash_to_curve`](https://www.rfc-editor.org/rfc/rfc9380.html#section-3-4.2.1)
681-
/// function from the Elligator2 spec.
682-
///
683-
/// For a hash to curve with uniform distribution and compatible with the spec, see
684-
/// [`Self::hash_to_curve`].
685-
#[deprecated(
686-
since = "4.0.0",
687-
note = "previously named `hash_from_bytes`, this is not a secure hash function"
688-
)]
689-
pub fn nonspec_map_to_curve<D>(bytes: &[u8]) -> EdwardsPoint
690-
where
691-
D: Digest<OutputSize = U64> + Default,
692-
{
693-
let mut hash = D::new();
694-
hash.update(bytes);
695-
let h = hash.finalize();
696-
let mut res = [0u8; 32];
697-
res.copy_from_slice(&h[..32]);
698-
699-
let sign_bit = (res[31] & 0x80) >> 7;
700-
701-
let fe = FieldElement::from_bytes(&res);
702-
703-
let (M1, _) = crate::montgomery::elligator_encode(&fe);
704-
let E1_opt = M1.to_edwards(sign_bit);
705-
706-
E1_opt
707-
.expect("Montgomery conversion to Edwards point in Elligator failed")
708-
.mul_by_cofactor()
709-
}
710-
711676
/// Return an `EdwardsPoint` chosen uniformly at random using a user-provided RNG.
712677
///
713678
/// # Inputs
@@ -1392,7 +1357,7 @@ impl EdwardsPoint {
13921357
/// assert_eq!((P+Q).is_torsion_free(), false);
13931358
/// ```
13941359
pub fn is_torsion_free(&self) -> bool {
1395-
(self * constants::BASEPOINT_ORDER_PRIVATE).is_identity()
1360+
(self * constants::BASEPOINT_ORDER).is_identity()
13961361
}
13971362
}
13981363

@@ -1739,7 +1704,7 @@ impl CofactorGroup for EdwardsPoint {
17391704
}
17401705

17411706
fn is_torsion_free(&self) -> Choice {
1742-
(self * constants::BASEPOINT_ORDER_PRIVATE).ct_eq(&Self::identity())
1707+
(self * constants::BASEPOINT_ORDER).ct_eq(&Self::identity())
17431708
}
17441709
}
17451710

@@ -1926,7 +1891,7 @@ mod test {
19261891
/// Test that multiplication by the basepoint order kills the basepoint
19271892
#[test]
19281893
fn basepoint_mult_by_basepoint_order() {
1929-
let should_be_id = EdwardsPoint::mul_base(&constants::BASEPOINT_ORDER_PRIVATE);
1894+
let should_be_id = EdwardsPoint::mul_base(&constants::BASEPOINT_ORDER);
19301895
assert!(should_be_id.is_identity());
19311896
}
19321897

@@ -2414,70 +2379,6 @@ mod test {
24142379
assert_eq!(bp, constants::ED25519_BASEPOINT_POINT);
24152380
}
24162381

2417-
////////////////////////////////////////////////////////////
2418-
// Signal tests from //
2419-
// https://github.com/signalapp/libsignal-protocol-c/ //
2420-
////////////////////////////////////////////////////////////
2421-
2422-
#[cfg(all(feature = "alloc", feature = "digest"))]
2423-
fn signal_test_vectors() -> Vec<Vec<&'static str>> {
2424-
vec![
2425-
vec![
2426-
"214f306e1576f5a7577636fe303ca2c625b533319f52442b22a9fa3b7ede809f",
2427-
"c95becf0f93595174633b9d4d6bbbeb88e16fa257176f877ce426e1424626052",
2428-
],
2429-
vec![
2430-
"2eb10d432702ea7f79207da95d206f82d5a3b374f5f89f17a199531f78d3bea6",
2431-
"d8f8b508edffbb8b6dab0f602f86a9dd759f800fe18f782fdcac47c234883e7f",
2432-
],
2433-
vec![
2434-
"84cbe9accdd32b46f4a8ef51c85fd39d028711f77fb00e204a613fc235fd68b9",
2435-
"93c73e0289afd1d1fc9e4e78a505d5d1b2642fbdf91a1eff7d281930654b1453",
2436-
],
2437-
vec![
2438-
"c85165952490dc1839cb69012a3d9f2cc4b02343613263ab93a26dc89fd58267",
2439-
"43cbe8685fd3c90665b91835debb89ff1477f906f5170f38a192f6a199556537",
2440-
],
2441-
vec![
2442-
"26e7fc4a78d863b1a4ccb2ce0951fbcd021e106350730ee4157bacb4502e1b76",
2443-
"b6fc3d738c2c40719479b2f23818180cdafa72a14254d4016bbed8f0b788a835",
2444-
],
2445-
vec![
2446-
"1618c08ef0233f94f0f163f9435ec7457cd7a8cd4bb6b160315d15818c30f7a2",
2447-
"da0b703593b29dbcd28ebd6e7baea17b6f61971f3641cae774f6a5137a12294c",
2448-
],
2449-
vec![
2450-
"48b73039db6fcdcb6030c4a38e8be80b6390d8ae46890e77e623f87254ef149c",
2451-
"ca11b25acbc80566603eabeb9364ebd50e0306424c61049e1ce9385d9f349966",
2452-
],
2453-
vec![
2454-
"a744d582b3a34d14d311b7629da06d003045ae77cebceeb4e0e72734d63bd07d",
2455-
"fad25a5ea15d4541258af8785acaf697a886c1b872c793790e60a6837b1adbc0",
2456-
],
2457-
vec![
2458-
"80a6ff33494c471c5eff7efb9febfbcf30a946fe6535b3451cda79f2154a7095",
2459-
"57ac03913309b3f8cd3c3d4c49d878bb21f4d97dc74a1eaccbe5c601f7f06f47",
2460-
],
2461-
vec![
2462-
"f06fc939bc10551a0fd415aebf107ef0b9c4ee1ef9a164157bdd089127782617",
2463-
"785b2a6a00a5579cc9da1ff997ce8339b6f9fb46c6f10cf7a12ff2986341a6e0",
2464-
],
2465-
]
2466-
}
2467-
2468-
#[test]
2469-
#[allow(deprecated)]
2470-
#[cfg(all(feature = "alloc", feature = "digest"))]
2471-
fn elligator_signal_test_vectors() {
2472-
for vector in signal_test_vectors().iter() {
2473-
let input = hex::decode(vector[0]).unwrap();
2474-
let output = hex::decode(vector[1]).unwrap();
2475-
2476-
let point = EdwardsPoint::nonspec_map_to_curve::<sha2::Sha512>(&input);
2477-
assert_eq!(point.compress().to_bytes(), output[..]);
2478-
}
2479-
}
2480-
24812382
// Hash-to-curve test vectors from
24822383
// https://www.rfc-editor.org/rfc/rfc9380.html#name-edwards25519_xmdsha-512_ell2
24832384
// These are of the form (input_msg, output_x, output_y)

curve25519-dalek/src/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ impl PrimeFieldBits for Scalar {
13311331
}
13321332

13331333
fn char_le_bits() -> FieldBits<Self::ReprBits> {
1334-
constants::BASEPOINT_ORDER_PRIVATE.to_bytes().into()
1334+
constants::BASEPOINT_ORDER.to_bytes().into()
13351335
}
13361336
}
13371337

x25519-dalek/src/x25519.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,6 @@ impl EphemeralSecret {
8686
SharedSecret(their_public.0.mul_clamped(self.0))
8787
}
8888

89-
/// Generate a new [`EphemeralSecret`] with the supplied RNG.
90-
#[deprecated(
91-
since = "2.0.0",
92-
note = "Renamed to `random_from_rng`. This will be removed in 2.1.0"
93-
)]
94-
pub fn new<R: CryptoRng + ?Sized>(csprng: &mut R) -> Self {
95-
Self::random_from_rng(csprng)
96-
}
97-
9889
/// Generate a new [`EphemeralSecret`] with the supplied RNG.
9990
pub fn random_from_rng<R: CryptoRng + ?Sized>(csprng: &mut R) -> Self {
10091
// The secret key is random bytes. Clamping is done later.
@@ -164,15 +155,6 @@ impl ReusableSecret {
164155
SharedSecret(their_public.0.mul_clamped(self.0))
165156
}
166157

167-
/// Generate a new [`ReusableSecret`] with the supplied RNG.
168-
#[deprecated(
169-
since = "2.0.0",
170-
note = "Renamed to `random_from_rng`. This will be removed in 2.1.0."
171-
)]
172-
pub fn new<R: CryptoRng + ?Sized>(csprng: &mut R) -> Self {
173-
Self::random_from_rng(csprng)
174-
}
175-
176158
/// Generate a new [`ReusableSecret`] with the supplied RNG.
177159
pub fn random_from_rng<R: CryptoRng + ?Sized>(csprng: &mut R) -> Self {
178160
// The secret key is random bytes. Clamping is done later.
@@ -241,15 +223,6 @@ impl StaticSecret {
241223
SharedSecret(their_public.0.mul_clamped(self.0))
242224
}
243225

244-
/// Generate a new [`StaticSecret`] with the supplied RNG.
245-
#[deprecated(
246-
since = "2.0.0",
247-
note = "Renamed to `random_from_rng`. This will be removed in 2.1.0"
248-
)]
249-
pub fn new<R: CryptoRng + ?Sized>(csprng: &mut R) -> Self {
250-
Self::random_from_rng(csprng)
251-
}
252-
253226
/// Generate a new [`StaticSecret`] with the supplied RNG.
254227
pub fn random_from_rng<R: CryptoRng + ?Sized>(csprng: &mut R) -> Self {
255228
// The secret key is random bytes. Clamping is done later.

x25519-dalek/tests/x25519_tests.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,18 @@ mod rand_core {
185185

186186
#[test]
187187
fn ephemeral_from_rng() {
188-
#[allow(deprecated)]
189-
EphemeralSecret::new(&mut OsRng.unwrap_err());
190188
EphemeralSecret::random_from_rng(&mut OsRng.unwrap_err());
191189
}
192190

193191
#[test]
194192
#[cfg(feature = "reusable_secrets")]
195193
fn reusable_from_rng() {
196-
#[allow(deprecated)]
197-
ReusableSecret::new(&mut OsRng.unwrap_err());
198194
ReusableSecret::random_from_rng(&mut OsRng.unwrap_err());
199195
}
200196

201197
#[test]
202198
#[cfg(feature = "static_secrets")]
203199
fn static_from_rng() {
204-
#[allow(deprecated)]
205-
StaticSecret::new(&mut OsRng.unwrap_err());
206200
StaticSecret::random_from_rng(&mut OsRng.unwrap_err());
207201
}
208202
}

0 commit comments

Comments
 (0)