Skip to content

Commit

Permalink
bigint: Remove Nonnegative.
Browse files Browse the repository at this point in the history
Inline and simplify the logic into the one test-only function that
uses it.
  • Loading branch information
briansmith committed Nov 25, 2023
1 parent fbb8cf6 commit 6c29bf6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 57 deletions.
3 changes: 0 additions & 3 deletions src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ pub mod bigint;
pub mod montgomery;
mod n0;

#[cfg(all(test, feature = "alloc"))]
mod nonnegative;

#[allow(dead_code)]
const BIGINT_MODULUS_MAX_LIMBS: usize = 8192 / crate::limb::LIMB_BITS;

Expand Down
14 changes: 4 additions & 10 deletions src/arithmetic/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ prefixed_extern! {

#[cfg(test)]
mod tests {
use super::{super::nonnegative::Nonnegative, *};
use super::*;
use crate::test;

// Type-level representation of an arbitrary modulus.
Expand Down Expand Up @@ -923,9 +923,10 @@ mod tests {
name: &str,
num_limbs: usize,
) -> Elem<M, Unencoded> {
let value = consume_nonnegative(test_case, name);
let bytes = test_case.consume_bytes(name);
let mut limbs = BoxedLimbs::zero(num_limbs);
limbs[0..value.limbs().len()].copy_from_slice(value.limbs());
limb::parse_big_endian_and_pad_consttime(untrusted::Input::from(&bytes), &mut limbs)
.unwrap();
Elem {
limbs,
encoding: PhantomData,
Expand All @@ -941,13 +942,6 @@ mod tests {
OwnedModulus::from_be_bytes(untrusted::Input::from(&value), cpu_features).unwrap()
}

fn consume_nonnegative(test_case: &mut test::TestCase, name: &str) -> Nonnegative {
let bytes = test_case.consume_bytes(name);
let (r, _r_bits) =
Nonnegative::from_be_bytes_with_bit_length(untrusted::Input::from(&bytes)).unwrap();
r
}

fn assert_elem_eq<M, E>(a: &Elem<M, E>, b: &Elem<M, E>) {
if elem_verify_equal_consttime(a, b).is_err() {
panic!("{:x?} != {:x?}", &*a.limbs, &*b.limbs);
Expand Down
44 changes: 0 additions & 44 deletions src/arithmetic/nonnegative.rs

This file was deleted.

0 comments on commit 6c29bf6

Please sign in to comment.