Recently, there have been fewer things to do at work, so I have been browsing interesting things while slacking off. When I was looking for VDF-related information, I came across a question: how to design a puzzle that can only be solved after a specified time ? I thought about it for a while but couldn't figure out how to quantify the abstract concept of time in a puzzle. 🤔
Then I came across this referenced paper Time-lock puzzles and timed-release Crypto.
After reading the article, I realized that this problem can actually be equivalent to designing an algorithm that can only produce the correct result after calculations, and the calculation process of this algorithm cannot be accelerated by parallel computing. This means that only one machine can be used for decryption. Assuming its maximum computing power per second is , it will take seconds to obtain the correct result, achieving the goal of time-lock.
The article introduces two implementations of time-lock puzzles.
Design of the first type of time-lock puzzle#
Assuming Alice has a message to be transmitted to Bob, but it needs to be encrypted (locked) for seconds. (Here, one prerequisite is that Alice needs to know Bob's computing power in advance)
Encryption#
Step 1: Randomly select two large prime numbers and , and multiply them to get . At the same time, calculate .
Step 2: Calculate , where is the number of times Bob's single machine can perform modular exponentiation of per second (also known as computing power).
Step 3: Randomly generate a sufficiently secure key for encryption, and an encryption algorithm such as RC5.
Step 4: Use the key and encryption algorithm to encrypt the original message to obtain .
Step 5: Choose a random number and encrypt to obtain .
This step can be accelerated through the following steps: first calculate , and then calculate .
Finally, Alice publishes to Bob.
Decryption#
For Bob to obtain , he needs to decrypt using the key . However, during encryption, it has been ensured that itself is sufficiently secure. Bob can only calculate using .
At this point, only remains as an unknown variable. For Bob, there is no better way to find the correct other than brute-forcing all possible values of .
Thus, it is necessary to perform calculations for a sequence of . It can be observed that in this sequence, each calculation depends on the previous calculation result . This means that the values of the later terms cannot be calculated in advance, and the calculation cannot be accelerated in parallel. The result can only be obtained through calculations. According to the previously set , the required calculation time is , which achieves Alice's goal of locking the message for time.
(As for how Bob determines that he has found the correct , it is not part of this algorithm. One way is for the encryptor to provide for Bob to verify.)
Design of the second type of time-lock puzzle#
I didn't read the second part carefully. I directly uploaded the paper to Claude2 and asked AI to summarize it for me (highly recommended to use Claude2 when GPT-4 is not available).
ME: Please introduce the second method.
The second method proposed in the article using trusted proxies is roughly as follows:
- Set multiple trusted proxies, each proxy regularly publishes a key.
- The user encrypts the message with a random key to obtain the ciphertext.
- The user divides this random key into multiple parts using a key sharing scheme and gives each part to a different proxy.
- Each proxy encrypts the part of the key they hold using the key published at time t in the future.
- At time t, a sufficient number of proxies have published their keys at that time.
- The user can decrypt the parts of the key using these keys and reconstruct the original random key.
- Finally, use this random key to decrypt the original message.
The security of this method depends on the trusted proxies not leaking future keys in advance. At the same time, setting multiple proxies can achieve a certain degree of fault tolerance through key sharing and threshold verification. Even if individual proxies are compromised or fail, as long as there are enough proxies still functioning properly, the information can still be decrypted at the predetermined time.