Number Theory
For generating keys, we need strong prime number, they are the basis. CryptoTools provides functions for generating these numbers.
prime numbers
are_coprime(p1, p2)
This function check if p1 and p2 are coprime
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
getPrimeNumber(n, safe=True)
This function generate a large prime number based on "A method for Obtaining Digital Signatures and Public-Key Cryptosystems" Section B. How to Find Large Prime Numbers https://dl.acm.org/doi/pdf/10.1145/359340.359342
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
getSmallPrimeNumber(n)
This function is deprecated
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
get_n_prime_numbers(n)
This function return a list of n prime numbers
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
get_prime_numbers(n)
This function get all prime number of the n
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
isPrimeNumber(p)
Check if the number p is a prime number or not. The function iterate until p is achieve. It's a smallest function identifying if p is a prime number To identify if p is prime or not, the function check the result of the Euclidean Division has a remainder. If yes, it's means it's not a prime number
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
isSafePrime(n)
This function has not been implemented yet, but check if the number n is a safe prime number. This function will test different properties of the possible prime number n
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
sieveOfEratosthenes(n)
This function build a list of prime number based on the Sieve of Erastosthenes
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
sophieGermainPrime(p)
Check if the number p is a safe prime number: 2p + 1 is also a prime
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/primeNumber.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
Fibonacci sequence
fibonacci(n)
This function generate the list of Fibonacci
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in Cryptotools/Numbers/numbers.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |