Finding the Weakness in the Encryption
Time limit1sMemory limit128 MB
Given nine XOR-encrypted 32-bit values where the last is a checksum of the others, recover the XOR key bit by bit using carry propagation.
- Level
Medium6 of 10
- Topics
- Bit manipulation, Math, Simulation
- Solved
- No attempts yet
Problem
You want to encrypt and transmit some data given as eight 32-bit unsigned integers.
First, to check that the data is correct, you compute a checksum and append it as a ninth value. (A checksum is a common way to verify data integrity.)
Then you encrypt these nine numbers with a 32-bit key . Encryption is done with the XOR operation. (XOR is an operation frequently used to encrypt data.)
If you transmit the nine values through , anyone who knows can recover the original data through . And someone who does not know can recover through as well... surprisingly!
This scheme has a weakness. Exploit it: given the nine integers through in hexadecimal, write a program that finds the key .
Input
The first line contains the number of test cases . does not exceed .
Then, for each test case, nine integers through are given in hexadecimal. Each hexadecimal number uses only the digits 0–9 and the lowercase letters a–f, with no unnecessary leading zeros. The nine numbers of a test case are not necessarily all on one line.
Output
For each test case, print the key in lowercase hexadecimal on its own line, with no unnecessary leading zeros.
Hint
Spoiler warning. The key is the relation . When you add the eight values , the parity of the bit sum at each position does not depend on that position's key bit . So, starting from the least significant bit and tracking the addition carry, you can determine each bit of uniquely, one at a time.