Skip to main content
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:

  1. r' = mod q inverse of r;
  2. increasing sequence: w_i = b_i · r' mod q;
  3. for each c: c' = c · r' mod q, then greedily find the bits according to w;
  4. 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
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −9 pts Log in
Hint 2 −19 pts Log in
Hint 3 −28 pts Log in
To submit a flag, log in.

First solvers

1. W.o.X 17.09.2026
2. Лазиз 04.10.2026
3. testrejim 09.10.2026
4. 11111tttt 09.10.2026
5. Mirjaxon Qaxxarov 26.10.2026
6. Odam 04.11.2026
7. arcanum 11.11.2026