Conversation
|
Now all tests pass. |
| let d = Option::from((n >> s).checked_add(&Uint::<L>::ONE)).expect("Integer overflow"); | ||
| // TODO: shr(s-1).shr(1) is a hack around the fact that a full right shift will panic | ||
| // see https://github.com/RustCrypto/crypto-bigint/commit/55312b6aa71#r134960147 | ||
| let d = Option::from((n.clone().shr(s - 1).shr(1)).checked_add(&T::one())) |
There was a problem hiding this comment.
This whole thing can be vartime, so you can just use shr_vartime(s).unwrap_or(T::zero())
|
|
||
| /// Returns a random prime of size `bit_length` using [`OsRng`] as the RNG. | ||
| /// If `bit_length` is `None`, the full size of `Uint<L>` is used. | ||
| /// TODO: bits_precision? |
There was a problem hiding this comment.
I think bit_length is more appropriate in this context.
There was a problem hiding this comment.
Sorry for the confusion. I put to TODO here to remind myself to add documentation for the parameter bits_length. Previously the precision is implied with the generics <const L: usize>, but now since we need to accommodate both Uint and BoxedUint, the size of the big integer will have to be passed in at runtime as an extra parameter.
…lementation in crypto-bigint
|
Related: RustCrypto/crypto-bigint#425 |
|
I made an attempt to implement
|
…enerate_prime and generate_safe_prime works with BoxedUint
|
There seems to be a bug with At least for now, it is possible to run |
|
@fjarri @tarcieri There are a two awkward API's. Also, the main public API Thank you! |
See also: #436 and entropyxyz/crypto-primes#37
|
Closing this PR to consolidate work on #36 |
See also: #436 and entropyxyz/crypto-primes#37
See also: #436 and entropyxyz/crypto-primes#37
See also: #436 and entropyxyz/crypto-primes#37
See also: #436 and entropyxyz/crypto-primes#37
This PR is a continuation of #36 (and thus is a halfway point to #34), though it is still WIP.
#36 in its current state will not compile. There are many
unimplemented!(). Some of the API's fromcrypto-biginthas also changed.This PR improves on #36 by:
jacobi_smallandgcd_small, which includes transitioninghazmat::jacobiandhazmat::gcdto be implemented using<T: UintLike>instead ofUint<L>UintLikeforBoxedUintBoxedUintAs of
ba9d3c5633020e7b50e5569e6ddb8e831fbd3d2cthe crate will compile, but not all tests will pass: