Skip to content

Commit 9a62386

Browse files
committed
Revert #219.
See discussion at #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.
1 parent d41026e commit 9a62386

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ristretto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ impl RistrettoPoint {
638638
/// discrete log of the output point with respect to any other
639639
/// point should be unknown. The map is applied twice and the
640640
/// results are added, to ensure a uniform distribution.
641-
pub fn random<T: RngCore + CryptoRng>(mut rng: T) -> Self {
641+
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
642642
let mut uniform_bytes = [0u8; 64];
643643
rng.fill_bytes(&mut uniform_bytes);
644644

src/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl Scalar {
527527
/// let mut csprng: OsRng = OsRng::new().unwrap();
528528
/// let a: Scalar = Scalar::random(&mut csprng);
529529
/// # }
530-
pub fn random<T: RngCore + CryptoRng>(mut rng: T) -> Self {
530+
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
531531
let mut scalar_bytes = [0u8; 64];
532532
rng.fill_bytes(&mut scalar_bytes);
533533
Scalar::from_bytes_mod_order_wide(&scalar_bytes)

0 commit comments

Comments
 (0)