Merkle–Hellman knapsack cryptosystem
The Merkle–Hellman knapsack cryptosystem was one of the earliest public key cryptosystems. It was published by Ralph Merkle and Martin Hellman in 1978. A polynomial time attack was published by Adi Shamir in 1984. As a result, the cryptosystem is now considered insecure.[1]:465 [2]:190
History
The concept of public key cryptography was introduced by Whitfield Diffie and Martin Hellman in 1976.[3] At that time they proposed the general concept of a "trap-door one-way function", a function whose inverse is computationally infeasible to calculate without some secret "trap-door information"; but they had not yet found a practical example of such a function. Several specific public-key cryptosystems were then proposed by other researchers over the next few years, such as RSA in 1977 and Merkle-Hellman in 1978.[4]
Description
Merkle–Hellman is a public key cryptosystem, meaning that two keys are used, a public key for encryption and a private key for decryption. It is based on the subset sum problem (a special case of the knapsack problem).[5] The problem is as follows: given a set of integers [math]\displaystyle{ A }[/math] and an integer [math]\displaystyle{ c }[/math], find a subset of [math]\displaystyle{ A }[/math] which sums to [math]\displaystyle{ c }[/math]. In general, this problem is known to be NP-complete. However, if [math]\displaystyle{ A }[/math] is superincreasing, meaning that each element of the set is greater than the sum of all the numbers in the set lesser than it, the problem is "easy" and solvable in polynomial time with a simple greedy algorithm.
In Merkle–Hellman, decrypting a message requires solving an apparently "hard" knapsack problem. The private key contains a superincreasing list of numbers [math]\displaystyle{ W }[/math], and the public key contains a non-superincreasing list of numbers [math]\displaystyle{ B }[/math], which is actually a "disguised" version of [math]\displaystyle{ W }[/math]. The private key also contains some "trapdoor" information that can be used to transform a hard knapsack problem using [math]\displaystyle{ B }[/math] into an easy knapsack problem using [math]\displaystyle{ W }[/math].
Unlike some other public key cryptosystems such as RSA, the two keys in Merkle-Hellman are not interchangeable; the private key cannot be used for encryption. Thus Merkle-Hellman is not directly usable for authentication by cryptographic signing, although Shamir published a variant that can be used for signing.[6]
Key generation
1. Choose a block size [math]\displaystyle{ n }[/math]. Integers up to [math]\displaystyle{ n }[/math] bits in length can be encrypted with this key.
2. Choose a random superincreasing sequence of [math]\displaystyle{ n }[/math] positive integers
- [math]\displaystyle{ W = ( w_1, w_2, \dots, w_n ) }[/math]
- The superincreasing requirement means that [math]\displaystyle{ w_k \gt \sum_{i = 1}^{k-1} w_i }[/math], for [math]\displaystyle{ 1 \lt k \le n }[/math].
3. Choose a random integer [math]\displaystyle{ q }[/math] such that
- [math]\displaystyle{ q \gt \sum_{i = 1}^n w_i }[/math]
4. Choose a random integer [math]\displaystyle{ r }[/math] such that [math]\displaystyle{ \gcd(r,q) = 1 }[/math] (that is, [math]\displaystyle{ r }[/math] and [math]\displaystyle{ q }[/math] are coprime).
5. Calculate the sequence
- [math]\displaystyle{ B = ( b_1, b_2, \dots, b_n ) }[/math]
- where [math]\displaystyle{ b_i = r w_i \bmod q }[/math].
The public key is [math]\displaystyle{ B }[/math] and the private key is [math]\displaystyle{ (W,q,r) }[/math].
Encryption
Let [math]\displaystyle{ m }[/math] be an [math]\displaystyle{ n }[/math]-bit message consisting of bits [math]\displaystyle{ m_1 m_2 \dots m_n }[/math], with [math]\displaystyle{ m_1 }[/math] the highest order bit. Select each [math]\displaystyle{ b_i }[/math] for which [math]\displaystyle{ m_i }[/math] is nonzero, and add them together. Equivalently, calculate
- [math]\displaystyle{ c = \sum_{i = 1}^n m_i b_i }[/math].
The ciphertext is [math]\displaystyle{ c }[/math].
Decryption
To decrypt a ciphertext [math]\displaystyle{ c }[/math], we must find the subset of [math]\displaystyle{ B }[/math] which sums to [math]\displaystyle{ c }[/math]. We do this by transforming the problem into one of finding a subset of [math]\displaystyle{ W }[/math]. That problem can be solved in polynomial time since [math]\displaystyle{ W }[/math] is superincreasing.
1. Calculate the modular inverse of [math]\displaystyle{ r }[/math] modulo [math]\displaystyle{ q }[/math] using the Extended Euclidean algorithm. The inverse will exist since [math]\displaystyle{ r }[/math] is coprime to [math]\displaystyle{ q }[/math].
- [math]\displaystyle{ r' := r^{-1} \pmod q }[/math]
- The computation of [math]\displaystyle{ r' }[/math] is independent of the message, and can be done just once when the private key is generated.
2. Calculate
- [math]\displaystyle{ c' := c r' \bmod q }[/math]
3. Solve the subset sum problem for [math]\displaystyle{ c' }[/math] using the superincreasing sequence [math]\displaystyle{ W }[/math], by the simple greedy algorithm described below. Let [math]\displaystyle{ X = (x_1, x_2, \dots, x_k) }[/math] be the resulting list of indexes of the elements of [math]\displaystyle{ W }[/math] which sum to [math]\displaystyle{ c' }[/math]. (That is, [math]\displaystyle{ c' = \sum_{i=1}^k w_{x_i} }[/math].)
4. Construct the message [math]\displaystyle{ m }[/math] with a 1 in each [math]\displaystyle{ x_i }[/math] bit position and a 0 in all other bit positions:
- [math]\displaystyle{ m = \sum_{i=1}^k 2^{n-x_i} }[/math]
Solving the subset sum problem
This simple greedy algorithm finds the subset of a superincreasing sequence [math]\displaystyle{ W }[/math] which sums to [math]\displaystyle{ c' }[/math], in polynomial time:
- 1. Initialize [math]\displaystyle{ X }[/math] to an empty list.
- 2. Find the largest element in [math]\displaystyle{ W }[/math] which is less than or equal to [math]\displaystyle{ c' }[/math], say [math]\displaystyle{ w_j }[/math].
- 3. Subtract: [math]\displaystyle{ c' := c' - w_j }[/math].
- 4. Append [math]\displaystyle{ j }[/math] to the list [math]\displaystyle{ X }[/math].
- 5. If [math]\displaystyle{ c' }[/math] is greater than zero, return to step 2.
Example
Key generation
Create a key to encrypt 8-bit numbers by creating a random superincreasing sequence of 8 values:
- [math]\displaystyle{ W = ( 2, 7, 11, 21, 42, 89, 180, 354 ) }[/math]
The sum of these is 706, so select a larger value for [math]\displaystyle{ q }[/math]:
- [math]\displaystyle{ q = 881 }[/math].
Choose [math]\displaystyle{ r }[/math] to be coprime to [math]\displaystyle{ q }[/math]:
- [math]\displaystyle{ r = 588 }[/math].
Construct the public key [math]\displaystyle{ B }[/math] by multiplying each element in [math]\displaystyle{ W }[/math] by [math]\displaystyle{ r }[/math] modulo [math]\displaystyle{ q }[/math]:
- [math]\displaystyle{ \begin{align} &(2 * 588) \bmod 881 = 295 \\ &(7 * 588) \bmod 881 = 592 \\ &(11 * 588) \bmod 881 = 301 \\ &(21 * 588) \bmod 881 = 14 \\ &(42 * 588) \bmod 881 = 28 \\ &(89 * 588) \bmod 881 = 353 \\ &(180 * 588) \bmod 881 = 120 \\ &(354 * 588) \bmod 881 = 236 \end{align} }[/math]
Hence [math]\displaystyle{ B = ( 295, 592, 301, 14, 28, 353, 120, 236 ) }[/math].
Encryption
Let the 8-bit message be [math]\displaystyle{ m = 97 = 01100001_2 }[/math]. We multiply each bit by the corresponding number in [math]\displaystyle{ B }[/math] and add the results:
0 * 295 + 1 * 592 + 1 * 301 + 0 * 14 + 0 * 28 + 0 * 353 + 0 * 120 + 1 * 236 = 1129
The ciphertext [math]\displaystyle{ c }[/math] is 1129.
Decryption
To decrypt 1129, first use the Extended Euclidean Algorithm to find the modular inverse of [math]\displaystyle{ r }[/math] mod [math]\displaystyle{ q }[/math]:
- [math]\displaystyle{ r' = r^{-1} \bmod q = 588^{-1} \bmod 881 = 442 }[/math].
Compute [math]\displaystyle{ c' = c r' \bmod q = 1129*442 \bmod 881 = 372 }[/math].
Use the greedy algorithm to decompose 372 into a sum of [math]\displaystyle{ w_i }[/math] values:
- [math]\displaystyle{ \begin{align} c' &= 372 \\ & w_8 = 354 \le 372 \\ c' &= 372-354 = 18 \\ & w_3 = 11 \le 18 \\ c' &= 18-11 = 7 \\ & w_2 = 7 \le 7 \\ c' &= 7-7 = 0 \end{align} }[/math]
Thus [math]\displaystyle{ 372 = 354 + 11 + 7 = w_8 + w_3 + w_2 }[/math], and the list of indexes is [math]\displaystyle{ X = (8,3,2) }[/math]. The message can now be computed as
- [math]\displaystyle{ m = \sum_{i=1}^3 2^{n-x_i} = 2^{8-8} + 2^{8-3} + 2^{8-2} = 1 + 32 + 64 = 97 }[/math].
Cryptanalysis
In 1984 Adi Shamir published an attack on the Merkle-Hellman cryptosystem which can decrypt encrypted messages in polynomial time without using the private key. [7] The attack analyzes the public key [math]\displaystyle{ B = (b_1, b_2, \dots, b_n) }[/math] and searches for a pair of numbers [math]\displaystyle{ u }[/math] and [math]\displaystyle{ m }[/math] such that [math]\displaystyle{ (u b_i \bmod m) }[/math] is a superincreasing sequence. The [math]\displaystyle{ (u,m) }[/math] pair found by the attack may not be equal to [math]\displaystyle{ (r',q) }[/math] in the private key, but like that pair it can be used to transform a hard knapsack problem using [math]\displaystyle{ B }[/math] into an easy problem using a superincreasing sequence. The attack operates solely on the public key; no access to encrypted messages is necessary.
Shamir's attack on the Merkle-Hellman cryptosystem works in polynomial time even if the numbers in the public key are randomly shuffled, a step which is usually not included in the description of the cryptosystem, but can be helpful against some more primitive attacks.
References
- ↑ Schneier, Bruce (1996). Applied Cryptography. New York: John Wiley & Sons. ISBN 0-471-12845-7.
- ↑ Stinson, Douglas R. (1995). Cryptography: Theory and Practice. Boca Raton: CRC Press. ISBN 0-8493-8521-0.
- ↑ Whitfield Diffie; Martin Hellman (1976). "New directions in cryptography". IEEE Transactions on Information Theory 22 (6): 644. doi:10.1109/TIT.1976.1055638.
- ↑ Merkle, Ralph; Hellman, Martin (1978). "Hiding information and signatures in trapdoor knapsacks". IEEE Transactions on Information Theory 24 (5): 525–530. doi:10.1109/TIT.1978.1055927.
- ↑ Cherowitzo, William (2002-03-02). "Merkle-Hellman Knapsack Cryptosystem". Math 5410 - Modern Cryptology. http://math.ucdenver.edu/~wcherowi/courses/m5410/ctcknap.html.
- ↑ Shamir, Adi (July 1978). "A Fast Signature Scheme". MIT Laboratory for Computer Science Technical Memorandum 79 (MIT/LCS/TM–107): 15240. Bibcode: 1978STIN...7915240S.
- ↑ Shamir, Adi (1984). "A polynomial-time algorithm for breaking the basic Merkle - Hellman cryptosystem". IEEE Transactions on Information Theory 30 (5): 699–704. doi:10.1109/SFCS.1982.5.
Original source: https://en.wikipedia.org/wiki/Merkle–Hellman knapsack cryptosystem.
Read more |