Skip to content

Commit

Permalink
Merge pull request #128 from dusk-network/mocello/127
Browse files Browse the repository at this point in the history
Remove Dusk's implementation of `Fr::random`
  • Loading branch information
moCello authored Nov 30, 2023
2 parents d04a333 + 6cd2463 commit 1f832dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- Remove dusk's implementation of `Fr::random` [#127]

### Added

- Add `from_var_bytes` to scalar [#126]
Expand Down Expand Up @@ -202,6 +206,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Initial fork from [`zkcrypto/jubjub`]

<!-- ISSUES -->
[#127]: https://github.com/dusk-network/jubjub/issues/127
[#126]: https://github.com/dusk-network/jubjub/issues/126
[#115]: https://github.com/dusk-network/jubjub/issues/115
[#109]: https://github.com/dusk-network/jubjub/issues/109
Expand All @@ -220,6 +226,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#31]: https://github.com/dusk-network/jubjub/issues/31
[#25]: https://github.com/dusk-network/jubjub/issues/25

<!-- VERSIONS -->
[Unreleased]: https://github.com/dusk-network/jubjub/compare/v0.13.1...HEAD
[0.13.1]: https://github.com/dusk-network/jubjub/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/dusk-network/jubjub/compare/v0.12.1...v0.13.0
Expand Down
24 changes: 3 additions & 21 deletions src/fr/dusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,17 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use core::convert::TryInto;

use rand_core::RngCore;

use crate::util::sbb;

use core::cmp::{Ord, Ordering, PartialOrd};
use core::convert::TryInto;
use core::ops::{Index, IndexMut};
use dusk_bls12_381::BlsScalar;

use dusk_bls12_381::BlsScalar;
use dusk_bytes::{Error as BytesError, Serializable};

use super::{Fr, MODULUS, R2};
use crate::util::sbb;

impl Fr {
/// Generate a valid Scalar choosen uniformly using user-
/// provided rng.
///
/// By `rng` we mean any Rng that implements: `Rng` + `CryptoRng`.
pub fn random<T>(rand: &mut T) -> Fr
where
T: RngCore,
{
let mut bytes = [0u8; 64];
rand.fill_bytes(&mut bytes);

Fr::from_bytes_wide(&bytes)
}

/// SHR impl: shifts bits n times, equivalent to division by 2^n.
#[inline]
pub fn divn(&mut self, mut n: u32) {
Expand Down

0 comments on commit 1f832dc

Please sign in to comment.