{"id":17031363,"url":"https://github.com/breandan/crypto-koans","last_synced_at":"2025-03-22T20:44:18.084Z","repository":{"id":146966340,"uuid":"67366588","full_name":"breandan/crypto-koans","owner":"breandan","description":"🔏 How to share a secret message: crypto katas for kids","archived":false,"fork":false,"pushed_at":"2022-09-15T05:55:42.000Z","size":48279,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-28T00:41:54.612Z","etag":null,"topics":["cipher","crypto","education","encryption","prime-numbers"],"latest_commit_sha":null,"homepage":"https://www.meetup.com/Devoxx4Kids-BayArea/events/236826245/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/breandan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-04T20:25:33.000Z","updated_at":"2024-12-28T23:00:25.000Z","dependencies_parsed_at":"2023-05-05T22:30:46.215Z","dependency_job_id":null,"html_url":"https://github.com/breandan/crypto-koans","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breandan%2Fcrypto-koans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breandan%2Fcrypto-koans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breandan%2Fcrypto-koans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breandan%2Fcrypto-koans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/breandan","download_url":"https://codeload.github.com/breandan/crypto-koans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245020314,"owners_count":20548156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cipher","crypto","education","encryption","prime-numbers"],"created_at":"2024-10-14T08:23:54.255Z","updated_at":"2025-03-22T20:44:17.900Z","avatar_url":"https://github.com/breandan.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## How to Share a Secret Message\n\n### What’s a secret? Something meant to be kept unknown or unseen by others.\n\n\u003e ***se·cret /ˈsēkrit/***\n\u003e\n\u003e *adjective*\n\u003e\n\u003e 1. not known or seen or not meant to be known or seen by others. (\"how did you guess I had a secret plan?\")\n\u003e\n\u003e *noun*\n\u003e\n\u003e 1. something that is kept or meant to be kept unknown or unseen by others. (\"a state secret\")\n\n### Let’s say you have a secret. How do you make sure your secret will stay secret?\n\n* Do not write it down. (Even in your diary.)\n* Do not talk about it. (Even in your sleep.)\n* Do not record it. (Even on your smartphone.)\n\n### What if you need to record your secret?\n\n#### We need to turn the secret into a message.\n\n* How do we write (or *encode*) the secret into the message?\n* How do we read (or *decode*) the message into the secret?\n* How do we keep our message safe?\n\n---\n### [Exercise #1](/src/main/kotlin/exercises/4_StringExercise.kt): Let’s encode a message!\n\n*There are many ways to encode text.\nComputers often use numbers to represent characters.\nWe can think of a message as a long list of numbers (or one really big number).*\n\n---\n\n### What if you need to share your secret?\n\n#### We can share the message in person.\n\n* How do you know you are alone?\n* Is the other person who they say they are?\n* What if your friend lives far away?\n\n#### We can share the message in public.\n\n* This is the safest way to share a secret. Requires that we be very careful.\n* If you need to share a secret message, it’s best to assume everyone can read it.\n* How do we prevent those who read our message from understanding the contents?\n\n### How can you share a secret message in public without sharing the secret?\n\n#### You can hide the secret in a secret place\n\n  * How do we share the location of this place?\n  * Can we be sure that no one is watching us?\n  * What if someone finds out our hiding spot?\n\n#### You can hide the secret in plain sight\n  * This technique is called [steganography](https://en.wikipedia.org/wiki/Steganography).\n  * What happens if someone is observant?\n  * What if someone learns our technique?\n\n#### We can use a language only we understand.\n  * How can we be sure no one else listening can understand our language?\n  * What if someone else can read our language? They will know our secrets!\n  * What if someone else can write our language? They can change our messages!\n\n#### We can scramble up the message somehow.\n  * How do we scramble or (encrypt) the message?\n  * How do we unscramble or (decrypt) the message?\n  * How do we keep the secret safe?\n\n---\n### [Exercise #2](/src/main/kotlin/exercises/1_SimpleCiper.kt): Let’s write a cipher!\n\n* What is a [substitution cipher](https://en.wikipedia.org/wiki/Substitution_cipher)?\n  * Substitution ciphers are (weak) encryption schemes.\n  * They work by replacing symbols and words (ie. Strings) with other symbols.\n  * Ciphers must be reversible (when reversed they produce the original message)\n\n* What are some substitution ciphers?\n  * [Codepoint cipher](/src/main/kotlin/ciphers/4A_CodePointCipher.kt)\n  * [Caesar cipher](/src/main/kotlin/ciphers/3A_CaesarCipher.kt)\n  * [Isogram cipher](/src/main/kotlin/ciphers/3B_IsogramCipher.kt)\n\n* What is the difference between encoding and encryption?\n  * Substitution ciphers are just a fancy encoding mechanism.\n  * Encryption is an encoding that is difficult to decode.\n\n---\n\n### How safe are substitution ciphers?\n\n#### How do we communicate using ciphers?\n* We need to agree on a common method (*protocol*).\n* We need to agree on a common secret (*key*).\n* How do we agree on a common secret? Back to square one.\n\n#### What is a key?\n\n* A key is a way to keep others from knowing your secret.\n* A key is something you know, have or are.\n  * Something you know: a password\n  * Something you have: a physical key\n  * Something you are: a fingerprint\n* A key, like a message, can be encoded as a number.\n\n#### What are the risks of using this kind of cipher?\n* What happens if someone guesses our protocol? They still need to guess the key.\n* What happens if someone deciphers a single message? They learn they key.\n* What happens if someone learns our key? They can break every message.\n\n---\n### [Exercise #3](/src/main/kotlin/exercises/3_CipherBreaker.kt): Let's break a cipher!\n#### Why are substitution ciphers dangerous?\nIf someone learns a plaintext-ciphertext pair they can break every message.\n\n#### Small keys are easy to guess.\n\n* What is the only way to guarantee an unbreakable cipher?\n  * One-time pad\n\n---\n\n### How can we improve the safety of ciphers?\n\n* Use keys with longer text\n* Use keys that are difficult to guess\n\n### What is a prime number?\n\n* Prime numbers have only two factors.\n\n### What is an algorithm?\n\n* Some set of steps for a computer to take.\n\n---\n### [Exercise #4]: Computers are fast\n\nLet's calculate some prime numbers. How many can you calculate in 5 seconds?\n\n---\n\n### What makes an algorithm hard?\n\n* Numbers are easy to multiply\n* Numbers are hard to factor\n\n### What is a random number?\n\n* Can we get computers to generate random numbers?\n\n---\n### [Exercise #5](/src/main/kotlin/exercises/6_RSA.kt): RSA\n\nTurns out, we can share a secret without sharing a key.\n\n---\n\n---\n### [Exercise #6]: What is a hash function? (optional)\n\nHash functions are cool.\n\n---\n\n## Building from the source\n\nFirst ensure [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) and [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) are installed and run the following command in your terminal.\n\n```\ngit clone https://github.com/breandan/crypto-exercises \u0026\u0026 cd crypto-exercises \u0026\u0026 ./gradlew runIde\n```\n\nAfter several minutes, a program called \"IntelliJ IDEA\" should start. If you receive an error, make sure JAVA_HOME is [correctly set](https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/). Once the program loads, right click on the file called *HelloCrypto.kt* and select \"Run\". You should see the following output.\n\n```\nLet's learn about cryptology!\n```\n\n## Running from the USB\n\n### Mac OS X\n\nInsert the provided USB drive and type or paste the following command from your terminal (\u003ckbd\u003e⌘\u003c/kbd\u003e+\u003ckbd\u003eSpace\u003c/kbd\u003e, `🔍 Terminal`, \u003ckbd\u003eEnter\u003c/kbd\u003e)\n\n```\n/Volumes/USB-STICK/idea.sh\n```\n\nThis will launch an instance of IntelliJ IDEA with the project already configured.\n\nIf you see a message \"Project SDK is not defined\" on the top of your screen, click **Setup SDK | Configure... | + (Add new SDK)\" | JDK**. Add the JDK which can be found here (under your Home directory): `~/jdk/`.\n\nOnce configured, you may need to select \"Import Changes\" and wait for indexing to complete.\n\n\n\n### Windows\n\nInsert the provided USB drive and open the folder named \"Windows\", then open the folder named \"CryptoExercises\", then double click on the icon \"Launch_CryptoExercises.lnk\".\n\n### Sanity Check\n\nYou should now be able to run the `/src/main/kotlin/HelloCrypto.kt` file by right-clicking and selecting \"Run\".\n\nIf configured correctly, it should print the following output:\n\n```\nLet's learn about cryptology!\n```\n\n## Learn more\n\n* [Intuitive Advanced Cryptography](https://github.com/cryptosubtlety/intuitive-advanced-cryptography/blob/master/advancedcrypto.pdf), Quan (2019)\n* [Handbook of Applied Cryptography](https://cacr.uwaterloo.ca/hac/), Menezes et al. (2001)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreandan%2Fcrypto-koans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbreandan%2Fcrypto-koans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreandan%2Fcrypto-koans/lists"}