Skip to main content

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!

Comments

  1. Impressive! I really like this post. Keep it up!

    ReplyDelete
    Replies
    1. Thank you very much, Sumedha. I hope you found my other articles interesting too.

      Delete

Post a Comment

Popular posts from this blog

An Analysis of Car and Driver Impact on Formula 1 Success - Part 2

  In the previous part of this project, I looked at the variables I was using, and some of the trends that I identified through a preliminary analysis. Part 2 of this project is dedicated to:  - The research questions I formulated  - The statistical analyses that I used for each question  - The interpretation of my analysis  - What conclusions I was able to draw to answer each research question Research Questions Based on my preliminary analysis of the variables that I was working with, I came up with more questions that I was interested in exploring, in addition to my original goal of figuring out whether the car or driver was more crucial to Formula 1 success. One of the first things that piqued my interest was how the different points systems affected overall scoring. While it was immediately clear that the change in point scoring systems from 10 points for a win to 25 points for a win resulted in drastic changes to the point totals, my hypothesis was that the change from sys

The Car Driver Quandary

  If you were a Formula 1 team principal, would you rather have the best driver or the best car? For those of you who are regular readers of the blog, firstly, thank you for your support. It means a lot to me. Secondly, this might seem like a weird hook, considering my previous articles have all been about basketball. While that is true, I am actually a big fan of multiple sports, including football (soccer to American readers), baseball, Formula 1, and yes, basketball. Instead of creating a different blog for each sport, I figured it would be better to write about multiple different sports on the same blog. The dilemma of car or driver popped into my head while I was watching the US Grand Prix this past weekend. While Max Verstappen was comfortably on his way to another victory, the 50 th of his career, there were many interesting battles throughout the rest of the field. This got me thinking about the age-old question of whether having the best driver or the best car brings more

Statistics To Help the Spurs – A Retrospective

A little while ago, I made a post about how the San Antonio Spurs could get better using statistics. A season and change later, it’s time to re-examine the players involved in that piece and see how the Spurs are playing. As of the new year of 2022, the Spurs are 14-20, with the 5 players averaging the most minutes per game being Dejounte Murray, Keldon Johnson, Derrick White, Jakob Poeltl, and Doug McDermott. Murray is the only player who was in the starting 5 from last season. White, Johnson, Poeltl were all on the roster and have moved into bigger roles, while McDermott is a free agent signing in his first season with the Spurs. The previous starting 5 was Murray, Bryn Forbes, DeMar DeRozan, LaMarcus Aldridge, and Trey Lyles. 3 of those players (DeRozan, Aldridge, and Lyles) have moved on. Forbes, after winning an NBA championship with the Bucks, returned to the Spurs this season. The 2019-20 Spurs line-up had a win co-efficient of 0.579. The top line-up that I looked at was t