Week 2
Week 2
Week 2
2 Factoring
The security of many cryptosystems is based on the integer factorization problem; given a compos-
ite integer N , find any factor (p or q) such that N = pq.
For example we know that 33, 24, and 1309 can all be factored because 33 = 3 × 11, 24 = 2 × 12,
and 1309 = 7 × 187. The integers 13, 101, and 1049 cannot be factored because they are all primes.
So the integer factorization problem consists of determining if a given integer is in the following
set:
F ACT OR = {N |N = pq, for integers p, q > 1}
We have that 33, 24, and 1309 ∈ F ACT OR.
√ √
This algorithm takes a maximum of N steps to complete the for loop, so it’s O( N ). Al-
though this might seem fast it’s actually horrible when we evaluate the number of steps in terms
of the size of N in binary. For example, the input N = 221 is an 8-bit number. So the maximum
√
number of steps to complete the for loop is about 28 = 28/2 = 24 .
In general, if the√input N is an n-bit number, the maximum number of steps to complete the
for loop is about 2n = 2n/2 . So trial division is actually a O(2n ) (or exponential time) algorithm
where n is the size of the input in binary.
joshua.schneider@sheridancollege.ca page 1
MATH36206 Advanced Cryptology Week 2
Let B ∈ Z+ such that B! = B(B − 1)(B − 2)...(si )...(s2 )...(s1 )...(3)(2)(1) contains all factors
of p − 1 or q − 1 (but not both!).
Then (p − 1)|B!.
a = 2B! mod N
B!
a≡2 mod p
B!
(p−1) p−1
=2 mod p
B!
= (1) p−1 mod p
=1 mod p
Then a − 1 ≡ 0 mod p, and we have that p|(a − 1) and that p|N , so therefore p = GCD(N, a − 1).
a = 2B! mod N
= 25! mod 407
120
=2 mod 407
= 264 232 216 28 mod 407
= (49)(81)(9)(256) mod 407
= 100
407 mod 99 = 11
99 mod 11 = 0
Note: using B = 6 would not work as 6! = 720 contains the factors of both 11 − 1 and 37 − 1:
a = 2B! mod N
6!
=2 mod 407
720
=2 mod 407
512 128 64 16
=2 2 2 2 mod 407
= (367)(366)(49)(9) mod 407
=1
joshua.schneider@sheridancollege.ca page 2
MATH36206 Advanced Cryptology Week 2
Exercises
2.1 Factor N = 77 using the Pollard p − 1 method with:
a) B = 3
b) B = 4
c) B = 5
2.2 Factor N = 299 using the Pollard p − 1 method with B = 4, and determine the largest value
of B that can be used.
2.3 Factor N = 517 using the Pollard p − 1 method with B = 5, and determine the largest value
of B that can be used.
2.4 Determine the range for B that can be used when factoring N using the Pollard p−1 method.
a) N = 899 = 29 × 31
b) N = 11413 = 101 × 113
c) N = 8881 = 83 × 107
B
where pn is the nth prime number.
Q
2.5 Let #B be the primorial of B. #B = pn
n=1
3
Q
For example #3 = pn = 2 × 3 × 5 = 30.
n=1
joshua.schneider@sheridancollege.ca page 3
MATH36206 Advanced Cryptology Week 2
y 2 = x3 + ax + b mod N
−1 mod N
(y2 − y1 )(x2 − x1 )
P ̸= Q
λ=
(3x1 + a)(2y1 )−1 mod N
2
P =Q
2
x3 = λ − x2 − x1 mod N
y3 = −λ(x3 − x1 ) − y1 mod N
2. Compute b = y02 − x30 − ax0 mod N . This establishes a random starting point P = (x0 , y0 ) ∈
E, a random elliptic curve described by y 2 = x3 + ax + b mod N .
3. Compute (B!)P . If at any point during this computation the slope, λ, requires an inverse
that does not exist, then return the factor GCD(N, 2y1 ) = p or GCD(N, x2 − x1 ) = p.
4. If the computation of (B!)P is completed without finding a factor, return to step 1 and search
for the factor on another random elliptic curve.
We can also modify Step 3. in Lenstra’s method by making substitutions for B! such as the
primorial #B for further efficiencies.
Lenstra’s EC method is currently one of the top three integer factorization algorithms (the other
two being the quadratic sieve and the number field sieve).
joshua.schneider@sheridancollege.ca page 4
MATH36206 Advanced Cryptology Week 2
Exercises
2.6 Factor N = 15 using the Lenstra EC method by computing 2P on the curve
y 2 = x3 + 2x + 9 mod N where P = (5, 12).
2.8 Factor N = 517 using the Lenstra EC method by computing 3P = 2P + P on the curve
y 2 = x3 + 281x + 166 mod N where P = (383, 489). Include the manual calculation of the
EEA for any inverses required.
2.9 Factor N = 221 using the Lenstra EC method by computing 5P = 2P + 2P + P on the curve
y 2 = x3 + 191x + 218 mod N where P = (87, 144). Include the manual calculation of the
EEA for any inverses required.
2.10 Determine the minimum number of additions required to compute the following for a point
P on an elliptic curve described by y 2 = x3 + ax + b mod p.
a) (7)P
b) (5!)P
c) (#4)P
d) (257)P
joshua.schneider@sheridancollege.ca page 5
MATH36206 Advanced Cryptology Week 2
Answers
2.1 a = 64, GCD(77, 63) = 7
a = 71, GCD(77, 70) = 7
a = 1, B is too large.
2.4 5 ≤ B ≤ 6
7≤B≤9
41 ≤ B ≤ 52
2.10 4
9
10
9
joshua.schneider@sheridancollege.ca page 6