mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
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: ce71c93a9a/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.
This commit is contained in:
parent
d41026e7d9
commit
9a623868c5
2 changed files with 2 additions and 2 deletions
|
|
@ -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<T: RngCore + CryptoRng>(mut rng: T) -> Self {
|
||||
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
|
||||
let mut uniform_bytes = [0u8; 64];
|
||||
rng.fill_bytes(&mut uniform_bytes);
|
||||
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ impl Scalar {
|
|||
/// let mut csprng: OsRng = OsRng::new().unwrap();
|
||||
/// let a: Scalar = Scalar::random(&mut csprng);
|
||||
/// # }
|
||||
pub fn random<T: RngCore + CryptoRng>(mut rng: T) -> Self {
|
||||
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
|
||||
let mut scalar_bytes = [0u8; 64];
|
||||
rng.fill_bytes(&mut scalar_bytes);
|
||||
Scalar::from_bytes_mod_order_wide(&scalar_bytes)
|
||||
|
|
|
|||
Loading…
Reference in a new issue