To install Competition Patch, you need to install ModLoader first. This post will focus more on technical details, so for general description and instructions regarding to Competition Patch usage are available on donadigo site here.
Competition Patch 2.0 works by changing the inputs coming from the player before they are used for simulation. Input changes based on a random seed, but even small changes should make simulation unpredictable due to chaoticness of the physics
Keyboard inputs have always been very problematic to validate, especially with Low Input Strategies (LIS). Therefore, Competition Patch 2.0 converts them to analog input first. But instead of going from max steer to zero, the input smoothly approaches the new value across multiple ticks. This is necessary to make sure that the input alterations will change the simulation outcome.
On the start of the race, the game requests a new random seed from the server. This seed will be used as a seed in a PRNG (Pseudorandom number generator) to modify steer inputs. The input modification works by changing (setting) a few of least significant bits of the steer input to the generated random number. The algorithm is a bit more complex to fulfill additional constraints, like:
The mod also stores the original inputs anyway, but they do not affect the gameplay. They can be recovered, currently the only tool that can do that is BigBang’s Clip Input.
The server is needed, because it acts as a trusted source of time and randomness. The server uses a high quality, cryptographically secure randomness.
The server works by cryptographically signing the random seed, timestamp and provided input hash from the game. This proves that the hash (and so the inputs) existed at this particular timestamp and that the seed and timestamp are not modified. This concept is called cryptographic timestamping. This approach also allows the server to be stateless, as it doesnt need to store anything. Everything what is needed is sent to the game and is saved in the replay for verification using a public key. Theoretically these inputs could be even publicly verifiable.
Competition Patch also stores some additional data, but everything is encrypted using asymmetric encryption. Usually it is very inefficient or impossible to encrypt something just using public keys, so a common approach is to exchange keys between parties to establish a common, symmetric key (shared secret). Such key exchange usually happens between hosts which can talk to each other, but in this case i wanted to encrypt something even offline. The key exchange consists of a few steps:
So basically the key exchange is spread across downloading the software (getting the public key) and sending the replay (sending the public key). This way, any data can be safely encrypted such that it can be only decrypted with specific private key.
Many of the most common AntiCheats in popular games use low level drivers, which are pretty invasive to the system and are (in my opinion) a threat to system security. Competition Patch is different, it works on cryptographic principles instead of scanning entire system to find cheats. And it works on Linux.
An Anti-Cheat modification for TrackMania Forever