# Python代写 | CS 6035: Introduction to Information Security

Project3​ ​
All Things Cryptography

Spring 2021

Preface :

Before starting, make SURE you are using Python ​VERSION 3.7.x OR LOWER.​ ​Version 3.8 includes some functionality that may not be compatible with the autograder environment which runs Python Version 3.6.9. To check your version of Python, open a command prompt and run the command:

python –version

For the established algorithms that you may need to use, you are allowed to reference and implement pseudocode with ​PROPER CITATION​.

What is Pseudocode? ​https://en.wikipedia.org/wiki/Pseudocode

UNDER NO CIRCUMSTANCES ​should you copy/paste code into the project. Doing so is an honor code violation (not to mention a real world security concern) and will result in a zero.

Intro :

RSA is one of the most widely-used public key cryptosystems in the world. It’s composed of three algorithms: key generation (Gen), encryption (Enc), and decryption (Dec). In RSA, the public key is a pair of integers (e, N ) , and the private key is an integer d .

The key pair is generated by the following steps:

1. Choose two distinct big prime numbers with the same bit size, say p and q .

2.Let N = p∗q,and φ(N) = (p−1)∗(q−1).

3.Pickupaninteger e,suchthat 1 < e < φ(N) and gcd(e, φ(N)) = 1.

4. Get the modular inverse of e : d ≡ e−1 mod φ(N) (i.e., d∗e ≡ 1 mod φ(N)).

5. Return (N , e) as public key, and d as private key.

Enc -​ To encrypt integer m with public key (N, e) , the cipher integer c ≡ m e mod N . Dec​ – To decrypt cipher integer c with private key d, the plain integer m ≡ c d mod N .

Task 1 – Warm-up, Get Familiar with RSA – (​5​ points)
The goal of this task is to get you familiar with RSA. You are given an RSA key pair (N , e) and d ,

and a unique encrypted message c . You are required to get the decrypted message m .

TODO:​ In the provided p​ roject_3.py​ file, implement the stub method t​ ask_1.​ ​Hint:​ Don’t overthink it, this can be done with a single Python command…

ask 2 – Warm-up, Get Familiar with Hashes (​7​ points)

By now we’ve learned that hashes are one-way functions. Because of this unique feature, passwords are often stored as hashes in order to protect them from prying eyes. Even if a hacker infiltrated our state-of-the-art Georgia Tech security systems, he or she would not be able to derive the plaintext passwords from the hashes. But what if we made the critical mistake of using a common password? ​How safe would we be?

Let’s find out…

You are given a list of some of the most commonly-used passwords on the Internet. You are also giventheS​ HA256​hashofapasswordrandomlyselectedfromthislist.Yourjobistodiscoverthe plaintext password behind the hash.

The complete list of common passwords is pre-loaded for you in ​project_3.py​. TODO:​ In the provided p​ roject_3.py​ file, implement the stub method t​ ask_2.​

Task 3 – Kernelcoin Part 1 (​9​ points)

Background: A blockchain is a distributed, immutable ledger that derives its security, in part, from a chain of cryptographic hash values. For more detail, please read Section II of Hassan et al., Blockchain and the Future of the Internet

Today is your lucky day! You’ve discovered a brand new cryptocurrency called Kernelcoin (symbol: RTI). There are rumors that Costco will soon announce Kernelcoin as the preferred payment method in its warehouse stores. This news is sure to send the price of Kernelcoin to the moon, and Kernelcoin holders to the nearest Lamborghini dealership.

You plan to start mining Kernelcoin so that you can earn even more. In order to do so, you need to create a valid block to append to the previous block. A valid block contains the lowest nonce value that, when concatenated with the transaction string, and the hash of the previous block (in that order, i.e. nonce + transaction string + previous block hash), will produce a SHA256 hash with two leading zeros (the proof-of-work for this particular blockchain). Transaction strings have the syntax “UserID1:UserID2:X”, indicating that UserID1has transferred X Kernelcoin to UserID2. You are given all of these values, and your goal is to find the lowest possible nonce value for the resulting block.

TODO:​ In the provided p​ roject_3.py​ file, implement the method ​task_3​.

Sure enough, once /r/WallStreetBets found out about Kernelcoin the price rose to nosebleed levels. The Kernelcoin that you mined is now worth a fortune! Feeling generous, you decide to donate a small portion of your gains to Georgia Tech so that the school can give its TAs a much-deserved raise. As you prepare to send the transaction, you start to wonder how Kernelcoin verifies that transactions are valid…

After doing some research you find that a Kernelcoin transaction is hashed and encrypted with your private key to create a digital signature. This signature is broadcast to the network along with the original transaction string. If the signature checks out, then the transaction is a candidate for inclusion in the next block.

TODO:​ In the provided p​ roject_3.py​ file, finish the code for signing a Kernelcoin transaction in the method ​task_4​. (You may find the code that you wrote in Task 1 helpful for this.)

Task 5 – Attack A Small Key Space (1​ 5​ points)

The algorithm you search for is dirt simple which makes it hard for attackers to traverse the entire key space with limited resources. Now, you’re given a unique RSA public key with a relatively small key size (6​ 4 bits)​ .

Your goal is to get the private key.

TODO:​ In the provided p​ roject_3.py​ file, implement the method ​get_factors​. n is the given public key, and your goal is to get its factors.

E-mail: itcsdx@outlook.com  微信:itcsdx