Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Dusk's implementation of Fr::random #128

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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