mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-07 20:30:39 +00:00
Relax Rng trait bounds to allow ?Sized Rngs (#394)
This allows the code to compile if you pass it `&mut dyn RngType`, since trait objects are unsized. See here for an example of caller code that is simplified by this change: https://github.com/mobilecoinfoundation/mobilecoin/pull/1977#discussion_r872906913
This commit is contained in:
parent
45d6adba73
commit
840a9dc866
2 changed files with 2 additions and 2 deletions
|
|
@ -677,7 +677,7 @@ impl RistrettoPoint {
|
||||||
/// discrete log of the output point with respect to any other
|
/// discrete log of the output point with respect to any other
|
||||||
/// point should be unknown. The map is applied twice and the
|
/// point should be unknown. The map is applied twice and the
|
||||||
/// results are added, to ensure a uniform distribution.
|
/// results are added, to ensure a uniform distribution.
|
||||||
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
|
pub fn random<R: RngCore + CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||||
let mut uniform_bytes = [0u8; 64];
|
let mut uniform_bytes = [0u8; 64];
|
||||||
rng.fill_bytes(&mut uniform_bytes);
|
rng.fill_bytes(&mut uniform_bytes);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -573,7 +573,7 @@ impl Scalar {
|
||||||
/// let mut csprng = OsRng;
|
/// let mut csprng = OsRng;
|
||||||
/// let a: Scalar = Scalar::random(&mut csprng);
|
/// let a: Scalar = Scalar::random(&mut csprng);
|
||||||
/// # }
|
/// # }
|
||||||
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
|
pub fn random<R: RngCore + CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||||
let mut scalar_bytes = [0u8; 64];
|
let mut scalar_bytes = [0u8; 64];
|
||||||
rng.fill_bytes(&mut scalar_bytes);
|
rng.fill_bytes(&mut scalar_bytes);
|
||||||
Scalar::from_bytes_mod_order_wide(&scalar_bytes)
|
Scalar::from_bytes_mod_order_wide(&scalar_bytes)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue