From 9a623868c5c6ba553b7019b0ea92cb80c55df5d4 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Fri, 15 Feb 2019 13:30:05 -0800 Subject: [PATCH 1/2] Revert #219. See discussion at https://github.com/dalek-cryptography/curve25519-dalek/issues/232 , copied below: `1.1` changed the trait bounds for `RistrettoPoint::random` and `Scalar::random`, see #222 and #219. These changes have two benefits: * they unlink us from the `rand` crate and make us depend only on `rand_core`; * they allow passing both owned and borrowed RNGs. The change was not supposed to be a breaking change, since the new bounds are strictly more general than the old ones (as every `RngCore` is an `Rng` and every `&mut RngCore` is an `RngCore`), so the new bound is satisfied in every situation where the old bound applied. The `1.1.0-pre.0` version didn't cause problems on the crates I tested it on, but there was an unexpected problem: https://github.com/interstellar/slingshot/blob/ce71c93a9a29ac3b4f69ce71feb987bd64d6c4ec/spacesuit/src/value.rs#L160-L161 broke, since it took a borrow as input and used it twice. So there was slight breakage. One option is to revert the changes (probably just the ones from #219) and release 1.1.3; another would be to fix up `slingshot` and leave the new bound. --- src/ristretto.rs | 2 +- src/scalar.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ristretto.rs b/src/ristretto.rs index a7b0a27..3774c99 100644 --- a/src/ristretto.rs +++ b/src/ristretto.rs @@ -638,7 +638,7 @@ impl RistrettoPoint { /// discrete log of the output point with respect to any other /// point should be unknown. The map is applied twice and the /// results are added, to ensure a uniform distribution. - pub fn random(mut rng: T) -> Self { + pub fn random(rng: &mut R) -> Self { let mut uniform_bytes = [0u8; 64]; rng.fill_bytes(&mut uniform_bytes); diff --git a/src/scalar.rs b/src/scalar.rs index 81a78ee..fcdc196 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -527,7 +527,7 @@ impl Scalar { /// let mut csprng: OsRng = OsRng::new().unwrap(); /// let a: Scalar = Scalar::random(&mut csprng); /// # } - pub fn random(mut rng: T) -> Self { + pub fn random(rng: &mut R) -> Self { let mut scalar_bytes = [0u8; 64]; rng.fill_bytes(&mut scalar_bytes); Scalar::from_bytes_mod_order_wide(&scalar_bytes) From bd96f25baa76d0d08376e832fa13bd81af57f5e3 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Fri, 15 Feb 2019 13:47:16 -0800 Subject: [PATCH 2/2] Bump patch version --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3363b93..d1f637c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Entries are listed in reverse chronological order. +## 1.1.3 + +* Reverts the change in 1.1.0 to allow owned and borrowed RNGs, which caused a breakage due to a subtle interaction with ownership rules. (The `RngCore` change is retained). + ## 1.1.2 * Disabled KaTeX on `docs.rs` pending proper [support upstream](https://github.com/rust-lang/docs.rs/issues/302). diff --git a/Cargo.toml b/Cargo.toml index 8d33d2d..bab9c09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "curve25519-dalek" -version = "1.1.2" +version = "1.1.3" authors = ["Isis Lovecruft ", "Henry de Valence "] readme = "README.md"