Skip to content

Commit 3ca5068

Browse files
authored
Fix random Odd generation (#498)
1 parent 25ec62a commit 3ca5068

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/odd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@ impl PartialOrd<Odd<BoxedUint>> for BoxedUint {
126126

127127
#[cfg(feature = "rand_core")]
128128
impl<const LIMBS: usize> Random for Odd<Uint<LIMBS>> {
129-
/// Generate a random `NonZero<Uint<T>>`.
129+
/// Generate a random `Odd<Uint<T>>`.
130130
fn random(rng: &mut impl CryptoRngCore) -> Self {
131131
let mut ret = Uint::random(rng);
132-
ret.limbs[0] &= Limb::ONE;
132+
ret.limbs[0] |= Limb::ONE;
133133
Odd(ret)
134134
}
135135
}
136136

137137
#[cfg(all(feature = "alloc", feature = "rand_core"))]
138138
impl Odd<BoxedUint> {
139-
/// Generate a random `NonZero<Uint<T>>`.
139+
/// Generate a random `Odd<Uint<T>>`.
140140
pub fn random(rng: &mut impl CryptoRngCore, bits_precision: u32) -> Self {
141141
let mut ret = BoxedUint::random(rng, bits_precision);
142-
ret.limbs[0] &= Limb::ONE;
142+
ret.limbs[0] |= Limb::ONE;
143143
Odd(ret)
144144
}
145145
}

0 commit comments

Comments
 (0)