From 96d86b38568f21236eb4bc8a93114768c418e1bb Mon Sep 17 00:00:00 2001 From: Jacob Zhong Date: Sat, 8 Jan 2022 21:22:18 -0500 Subject: [PATCH] Update license --- Cargo.toml | 2 +- LICENSE | 2 +- src/buffer.rs | 6 ++---- src/traits.rs | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a99adc7..2e59629 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "num-prime" -version = "0.0.1" +version = "0.0.2" edition = "2018" repository = "https://github.com/cmpute/num-prime" diff --git a/LICENSE b/LICENSE index f8e5e5e..a5f021d 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work. same "printed page" as the copyright notice for easier identification within third-party archives. -Copyright [yyyy] [name of copyright owner] +Copyright [2021] [Jacob Zhong] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/buffer.rs b/src/buffer.rs index c536e10..f395f54 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap}; use bitvec::prelude::bitvec; use num_traits::{ToPrimitive, One, Pow}; -use num_bigint::BigUint; +use num_bigint::BigUint; // TODO: make the dependency for this optional use num_integer::Integer; use rand::{random, seq::IteratorRandom}; use crate::traits::Arithmetic; @@ -225,9 +225,7 @@ impl PrimeBuffer { // TODO: support indexing and iterating pub fn bdivisor(&mut self, target: &BigUint, trials: Option) -> Option { // if the target is in u64 range if let Some(x) = target.to_u64() { - return match self.divisor(x) { - Some(d) => Some(BigUint::from(d)), None => None - }; + return self.divisor(x).map(BigUint::from); } let primality = self.is_bprime(target, None); diff --git a/src/traits.rs b/src/traits.rs index d3dece8..14ce447 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -29,9 +29,8 @@ pub trait Arithmetic : Integer + NumOps { fn pollard_rho(&self, offset: Self, trials: u32) -> Option; } -impl Arithmetic for T -where T: Integer + ArithmeticHelpers + FromPrimitive + NumRef + SampleUniform + Clone, -for<'r> &'r T: RefNum + std::ops::Shr + ModInt<&'r T, &'r T, Output = T> +impl Arithmetic for T +where for<'r> &'r T: RefNum + std::ops::Shr + ModInt<&'r T, &'r T, Output = T> { fn is_sprp(&self, witness: T) -> bool { // find 2^shift*u + 1 = n