mirror of
https://github.com/saymrwulf/anza-cryptography-source.git
synced 2026-09-04 20:24:04 +00:00
[ed25519] improve rng bounds for random function (#54)
This commit is contained in:
parent
34e36a7c32
commit
ff4e6654d1
1 changed files with 3 additions and 3 deletions
|
|
@ -118,7 +118,7 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "rand_core")]
|
#[cfg(feature = "rand_core")]
|
||||||
use rand_core::RngCore;
|
use rand_core::{CryptoRng, RngCore};
|
||||||
|
|
||||||
use subtle::Choice;
|
use subtle::Choice;
|
||||||
use subtle::ConditionallyNegatable;
|
use subtle::ConditionallyNegatable;
|
||||||
|
|
@ -741,7 +741,7 @@ impl EdwardsPoint {
|
||||||
///
|
///
|
||||||
/// # Inputs
|
/// # Inputs
|
||||||
///
|
///
|
||||||
/// * `rng`: any RNG which implements `RngCore`
|
/// * `rng`: any RNG which implements `CryptoRng` and `RngCore`
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
|
|
@ -752,7 +752,7 @@ impl EdwardsPoint {
|
||||||
/// Uses rejection sampling, generating a random `CompressedEdwardsY` and then attempting point
|
/// Uses rejection sampling, generating a random `CompressedEdwardsY` and then attempting point
|
||||||
/// decompression, rejecting invalid points.
|
/// decompression, rejecting invalid points.
|
||||||
#[cfg(feature = "rand_core")]
|
#[cfg(feature = "rand_core")]
|
||||||
pub fn random<R: RngCore + ?Sized>(rng: &mut R) -> Self {
|
pub fn random<R: CryptoRng + RngCore + ?Sized>(rng: &mut R) -> Self {
|
||||||
let mut repr = CompressedEdwardsY([0u8; 32]);
|
let mut repr = CompressedEdwardsY([0u8; 32]);
|
||||||
loop {
|
loop {
|
||||||
rng.fill_bytes(&mut repr.0);
|
rng.fill_bytes(&mut repr.0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue