Merkle Hellman Knapsack
Merkle Hellman Knapsack
Merkle Hellman Knapsack
Knapsack cryptosystem
Crypto analysis by Shamir
By: Kanmogne Pekam Linda
Introduction
In 1976 the idea of public key
cryptosystem was introduced by Diffie
and Hellman
In 1978 Merkle-Hellman Knapsack public
key Cryptosystem is published
in 1982 Adi Shamir's broke the basic
Merkle-Hellman Knapsack Cryptosystem
NP-Complete
A problem Z is said to be NP-Complete if:
Z is NP: Meaning there is a
nondeterministic turing machine that can
solve the problem in polynomial time
And Z is NP-Hard: every NP problem R
can be reduced to Z.
knapsack problem
Which coins should we put in the bag such
that the total value of the bag is a big as
possible but the total weight at most 15 kg?
Subset-sum problem
It is a particular case of Knapsack problem
Giving n items with weight vector
w = (w1, w2,, wn) , wi Z+ , for i : 1,...,n
and S Z+ the sum.
find subset wj of wi such that
S = wj for j: 1,,p (p n)
=> finding vector x = (x1,...,xn ), xi {0, 1} st:
S = wixi = w1x1+ w2x2+...+ wnxn for i: 1,...,n
if xi = 1 : wi wj, else , wi wj
Subset-Sum problem - 2
The subset-sum problem (w, S) is known to
be NP-Complete
However if the initial weight vector w has
a super increasing, the problem (w, S) can
be solved in O(n).
Merkle-Hellman Knapsack
Cryptosystem: Idea
Encoded message as solution to knapsack
problem.
n-bit message
Choose a super increasing vector
ai : {a1, a2,, an}
, 0 bi < q
MH -> Encryption
n-bit message mi : { m1 , m2 ,, mn}
Public key bi : {b1, b2,, bn}
Encrypted message is: C = mi bi
(E)
MH -> Decryption
MH -> Decryption -2
We compute C = C r-1 mod(q)
=> C = mi bi r-1 mod(q), with bi = r aimod(q)
=> ai = r-1 bi mod(q)
=> C = mi ai mod(q)
q > ai and mi {0,1}, mi ai < q
=> C= mi ai (E')
(E') easy to solve as ai has a super
increasing.
MH -> Example
MH -> Example - 2
l = 1101100 => Cl= libi = 30 + 50 + 250 +
101 = 431
o = 1101111 => Cl= libi = 30 + 50 + 250 +
101 + 222 + 55 = 708
So the encrypted message is M = (280, 236,
431, 431, 708).
Decryption of Ch = 280
r-1 of r modulo q is 44 (10x44 = 1 mod(q))
MH -> Example - 3
Ch' = Ch r-1 mod (q)
=> Ch' = 280x44 mod (439) = 28
ai : {3, 5, 15, 25, 54, 110, 225}
Algo to solve the super increasing
knapsack problem:
- The largest element
for j = n downto 1
of ai Ch' is 25 => h4 = 1 { If s a then { xi = 1; s = s - ai; } else
xi = 0; }
Ch' = 28 - 25 = 3
return (x1, x2,..., xn).
a1 Ch' => h1 = 1, Ch' = 3 - 3 = 0
=> hi : 1001000
i
MH - Cryptanalysis : Step 3
We pick l bi curves
the pth minimum of b1 is pq0/b1,
we don't have q0
Observation: the location of accumulation
points depend on b1 and not on tq0
MH-Cryptanalysis : step 3 - 2
we can get rid of q0 by dividing the
function by q0
=> biv mod(1) with v = w/q0 , 0 v < 1
=> slope is unchanged: bi
=> the distance between two consecutives
minima : 1/bi
=> distance between wo and the bi minima
will be reduced by 2dn, => vo -vi 2-dn-n+i-1
MH-Cryptanalysis : step 3 - 3
for i=1, the pth minimum of b1 curve is an
accumulation point if it is closed enough to all other
neighboring bi minima
MH-Cryptanalysis : step 3 - 4
=> This gives the following system :
(l-1) inequalities equations
l unknow value p, q , rintegers
, : allowable deviation between pth
minimum and other minima.
2 < p/b1 q/b2 < - 2
3 < p/b1 r/b3 < - 3
MH-Cryptanalysis : step 3 - 5
Multiplying the inequalities by their denominators
gives:
MH-Cryptanalysis : step 3 - 6
Using the Lenstra integer programming will
output all possible value of p, satisfying the
inequalities system
The number of accumulation points k should
not exceed 100 else the algorithm is aborted.
This condition make sure the algorithm runs in
polynomial time.
Example: all bi are similar => all minima are
accumulation points
MH-Cryptanalysis : step 4
p found in step 3:
[p/b1, (p+1)/b1]: interval between 2
successive minima of b1
v1,...,v1 : the list of coordinates of
discontinuity points of all n curves lying in
the sorted order in this interval
We divide [p/b1, (p+1)/b1] in subintervals
such as [vt, vt+1).
MH-Cryptanalysis : step 4 - 2
in [vt, vt+1), each bi curves is a line
segment.
=> the ith linear segment : vbi + Cti where Cti
: number of bi minima in (0, vt] , vt v < vt+1
MH-Cryptanalysis : step 4 - 3
v = Cti/bi
Conditions: v trapdoor ratio w/q if:
modulus Size: (vbi + Cti ) < 1 i: 1,...,n
Superincreasing: (vbi + Cti ) >(vbj + Ctj )
for i: 2,...,n and j: 1,...,i-1
The solution to this system of linear inequalities
in v, is possible non empty subinterval of
[vt, vt+1).
MH-Cryptanalysis : step 4 -4
There would be at least one non empty
subintervals by construction
The membership of w/q to this subinterval
for some p, t value is a necessary and
sufficient condition for w and q to be a
trapdoor pair.
MH-Cryptanalysis : step 5
We have the ratio (s) w/p = k, with k real
value
We need w, p
Diophantine approximation: For a given real
value k, output the rational number w/q such
that w/q is an approximated value of k.