| License | BSD-style |
|---|---|
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Stability | experimental |
| Portability | Good |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.Number.Basic
Description
Documentation
sqrti :: Integer -> (Integer, Integer) Source #
sqrti returns two integers (l,b) so that l <= sqrt i <= b.
The implementation is quite naive, use an approximation for the first number
and use a dichotomy algorithm to compute the bound relatively efficiently.
gcde :: Integer -> Integer -> (Integer, Integer, Integer) Source #
Get the extended GCD of two integer using integer divMod
gcde a b find (x,y,gcd(a,b)) where ax + by = d
numBytes :: Integer -> Int Source #
Compute the number of bytes for an integer
Out of numBits rather than out of GMP's own count in base 256. GHC's
bignum sizes a number in base two by looking at its highest limb, and in
any other base -- 256 included -- by dividing the number down to nothing:
on a 2048-bit modulus that is 1.65 us against 0.01, and every serialization
here asks for the size before it allocates. Eight bits to the byte does
the rest.