Skip to content

Commit

Permalink
[SQUASH] more nits
Browse files Browse the repository at this point in the history
  • Loading branch information
cjpatton committed Mar 31, 2021
1 parent fb56bf5 commit 94fd600
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

//! Finite field arithmetic for any field GF(p) for which p < 2^126.
// TODO(cjpatton) Pre-compute the principal roots of unity instead of generating them on the fly.

use rand::prelude::*;
use rand::Rng;
#[cfg(test)]
use rand::{prelude::*, Rng};

/// This structure represents the parameters of a finite field GF(p) for which p < 2^126.
#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -221,6 +219,7 @@ impl FieldParameters {
}

/// Returns a random field element mapped.
#[cfg(test)]
pub fn rand_elem<R: Rng + ?Sized>(&self, rng: &mut R) -> u128 {
let uniform = rand::distributions::Uniform::from(0..self.p);
self.elem(uniform.sample(rng))
Expand All @@ -237,6 +236,7 @@ impl FieldParameters {
}

/// Returns the number of bytes required to encode field elements.
#[cfg(test)] // This code is only used by tests for now.
pub fn size(&self) -> usize {
(16 - (self.p.leading_zeros() / 8)) as usize
}
Expand Down

0 comments on commit 94fd600

Please sign in to comment.