Challenges
Merkle-Hellman knapsack
Cryptography
Hard
Knapsack cryptosystem
Solves: 7
Merkle-Hellman knapsack
Author: CyberSamSU
Points
95
The Merkle-Hellman knapsack system — is one of the first public key systems. It is based on a superincreasing sequence: in it, every element is greater than the sum of all preceding ones, therefore the subset-sum problem is easily solved with a greedy approach.
Private key: superincreasing sequence w, modulus q and multiplier r. Public key: b_i = w_i · r mod q (no longer superincreasing). Each byte is encrypted as 8 bits: c = Σ b_i (by indices where the bit is 1).
The attached knapsack.txt file contains q, r, the public key b (8 numbers) and ciphertexts c (one for each byte). Using the trapdoor (private key q and r), recover each byte:
r'=mod qinverse ofr;- increasing sequence:
w_i = b_i · r' mod q; - for each
c:c' = c · r' mod q, then greedily find the bits according tow; - 8 bits to a byte:
byte = Σ bit_k · 2^(7-k).
Attached files
knapsack.txt
Log in to download
SHA-256 checksums
knapsack.txt: f3ef6d1dce425aabf547fb2d344c59a7ef71e55e3725a9fc5848bacd492bead6
Theory: learn the topic
To submit a flag, log in.