the official imp™ lib!!
| celeste | ||
| ctf-solutions | ||
| examples | ||
| research/aparith | ||
| sandbox | ||
| src | ||
| .gitignore | ||
| celeste.nimble | ||
| config.nims | ||
| default.nix | ||
| poetry.lock | ||
| primegen.nim | ||
| pyproject.toml | ||
| README | ||
| README-primefac | ||
The "imbaud python library" (imp lib), or just imp for short!
TODO:
- define a getPrime function like PyCryptodome's
- rewrite nim-lang/bigints to implement features like Karatsuba multiplication, or even Toom-3 multiplication
PyCryptodome defines getPrime as follows:
```py
def getPrime(N, randfunc=None):
"""Return a random N-bit prime number.
N must be an integer larger than 1.
If randfunc is omitted, then :meth:`Random.get_random_bytes` is used.
"""
if randfunc is None:
randfunc = Random.get_random_bytes
if N < 2:
raise ValueError("N must be larger than 1")
while True:
number = getRandomNBitInteger(N, randfunc) | 1
if isPrime(number, randfunc=randfunc):
break
return number
```
in essence infinite random generation until a prime is found