Posted in

Guess Who? (A lesson in Cryptography)

Guess Who? (A lesson in Cryptography)

 

In the last few years, there has been a growing
shift towards the analytics side of basketball. Formerly unknown analytics
maestros like Daryl Morey are now becoming more recognized, and their
principles are being used to build teams that can contend for championships.

A core tenet of sports analytics is stripping away
the bias that is inherently present in humans, allowing for an evaluation of
players at face value. Though the sports analytics movement has gained traction
in NBA circles, many fans still haven’t embraced it, which precludes them from
understanding certain trades and signings made by their favorite teams.

One way to eliminate bias without the benefit of supercomputers and reams of data is through using cryptography to encrypt players’
names. This ensures that players are evaluated only based on their stats.

Cryptography
involves coding the plain text to make it secure and decoding the coded text to
retrieve the plain text. The coding and decoding processes are accomplished using keys.

There are primarily two types of encryption: Symmetric key and Asymmetric key encryption.

Symmetric key encryption
involves the use of the same key for both encryption and decryption. Symmetric
key encryption can be broken if others know the key, which makes it vulnerable.
One example of Symmetric key encryption is the Advanced Encryption Standard (AES).

Asymmetric key encryption
involves the use of two keys, a public key to encrypt the plain text and a private
key to decrypt the coded text. Asymmetric key encryption is harder to break
than symmetric key encryption, but it also takes more time and computing power,
due to the magnitude of the numbers involved. One example of Asymmetric key
encryption is the RSA cryptosystem.


The RSA cryptosystem
was invented by Ron Rivest, Adi Shamir, and Leonard Adleman in 1977. The name
RSA comes from the first letter of the authors’ last names. The keys to
encrypt and decrypt are generated by multiplying two large prime numbers. Though
the formulae to generate the public and private keys are common knowledge, the
difficulty in deriving the public and private keys lies in the time and
computing power required to factorize the product of two large prime numbers.

In the RSA system, every participant uses two keys, public and private, to encrypt and decrypt plain text. As the names suggest, a private key is known only to the person while the public key of a person is known to all participants. The person encrypting the text uses the recipient’s public key to encrypt the plain text. The recipient uses their private key to decrypt the encrypted text. As the recipient’s private key is known only to the recipient, no one other than the recipient can decrypt the message easily.

Using
the RSA module
in a simple Python program, I generated
public and private keys. I then encrypted a plain text, like the name Kawhi
Leonard, resulting in the following bytes. The public key used to encrypt the
plain text is this:



The
plain text, Kawhi Leonard, when encrypted with the public key, looks something
like this:



 To decrypt
the bytes to get the plain text, I use the private key. Of course, I am not
publishing the private key here as it is supposed to be private.

In a previous article, I wrote about how the San
Antonio Spurs, using a linear regression model, can aim for another NBA championship.
The table in this article listed combinations of the Spurs starting five and
their predicted win-coefficients. Encrypting the players’ names will give us this
table:

For reference, this is the table with the players’ names:

If the encrypted text is too large to fit in a page
or sometimes even store efficiently, we can use Base64 encoding to create coded
text that is smaller than encrypted text. This is space friendly, but it is easy
to reverse, and does not provide much in the way of security.

For example, encoding the text Kawhi Leonard via
Base64 results in the encoded text:


Using a Base64 decoder, we can get the plain text
from the encoded text.

Thus, using cryptography, we can strip out the bias
that is inherent in humans, allowing for a more objective evaluation of
players’ talents, and maybe even learn a thing or two about coding, a very
interesting subject in its own right!

Leave a Reply

Your email address will not be published. Required fields are marked *