This repository contains the materials of Blockchain & Web3 course at the University of Tehran ACM Chapter Summer School 2023.
The objective of this assignment is to gain practical experience in implementing symmetric and asymmetric cryptography techniques, as well as hash functions, using Python programming.
We have TinTin and Haddock on two seperate islands and they want to send messages to each other using morse codes!!
However, there is a problem over there. Roberto Rastapopoulos (Their enemy!) is listening to their conversation to figure out what they are saying to each other!
Now TinTin wants to use some encryption and decryption techniques to ensure that Roberto couldn't understand what they are saying. Help TinTin to acheive his goal!
TinTin decided to design a symmetirc encryption scheme for his connection with haddock. He asked you to design it for him using these steps:
In all steps, use AES-128 encryption method for encryption/decryption. You can use python cryptography libraries for this purpose.
- Write a function to which gives an input message and a secret key for encryption.
- Encrypt this confidential message using a random key and display the encrypted result.
- Implement a decryption function that takes the encrypted message and the secret key as input and decrypts the message.
- Verify the correctness of the decryption process by comparing the original message with the decrypted message.
After TinTin found how to use symmetric encryption using a key, he faced another problem! How to share a key with haddock without letting Roberto finds it? Therefore, he decides to use an asymmetric crypto system. help him to acheive his goal by writing a program which:
- Generate a pair of RSA keys using a cryptography library.
- Implement a program to encrypt a message using the public key and decrypt the message using the private key.
- Allow the user to input a message and encrypt it using the public key.
- Implement a decryption function that takes the encrypted message and decrypts it using the private key.
- Verify the correctness of the decryption process by comparing the original message with the decrypted message.
Now TinTin wants to send a message without encryption to haddock, to trick roberto :)
However, he wants to show haddack that the sender of thsese tricky messages is TinTin, and inform haddock to ignore this type of messages. In order to capture this goal, TinTin wants to sign these messages and send the signs beside each message. Help him to do that by coding:
- Write a function to sign a given message in the text file (Confidentail message) using private key which was made in the part 2.
You have to sign the hash of the message, not the whole message (why?). (Use SHA-256 for hashing) - Write a function to verify a message with its signature.
The goal of this assignment is to allow students to interact with the Bitcoin network and gain practical experience in broadcasting transactions. This hands-on experience will help them understand how Bitcoin transactions work, the role of network nodes and miners, and the decentralized nature of the blockchain.
After mastering the fundomentals of cryptography during his adventures, TinTin's insatiable curiosity led him down a new path: the world of cryptocurrencies. Fascinated by the potential of digital currencies like Bitcoin, he delved deeper into the intricate world of blockchain technology.
In this part of the assignment, our goal is to utilize cryptography libraries to generate Bitcoin addresses. This involves applying cryptographic techniques to create secure and unique identifiers for Bitcoin transactions, ensuring the security and privacy of the digital currency system. Generating Bitcoin addresses is a fundamental step in understanding the principles of blockchain technology and cryptocurrency transactions.
The primary objective of this assignment section is to facilitate an understanding of Bitcoin transactions through practical implementation using the python-bitcoinlib library. By creating simple Bitcoin transfers, we aim to delve into the intricate workings of transactions, including how they are structured, signed, and how Bitcoin scripts are organized within outputs. This hands-on approach will empower learners to gain insight into the inner workings of the Bitcoin network, offering a deeper comprehension of the blockchain's mechanics and the role of cryptographic signatures in securing transactions. Ultimately, this exercise will equip participants with valuable knowledge about the core principles of Bitcoin's transaction processing, enhancing their cryptocurrency expertise.
The primary objective of this assignment section is to delve into more advanced Bitcoin transfers, specifically exploring Multisignature (Multisig) transactions, and comparing them with the traditional Pay-to-Public-Key-Hash (P2PKH) scripts. By engaging in the creation and analysis of Multisig transactions, participants will gain a deeper understanding of the intricate nuances of Bitcoin's scripting capabilities. This advanced exercise aims to showcase the enhanced security and flexibility offered by Multisig, where multiple signatures are required to authorize a transaction, as opposed to the simpler P2PKH approach. Through hands-on experience, learners will discern the differences, advantages, and potential use cases of these diverse scripting methods, ultimately broadening their comprehension of Bitcoin's versatile functionality.
- Donwload the notebook file from this link, and complete your code on this notebook. You have to install jupyter notebook and python on your system.
- Provide well-commented Python code for each part of the assignment.
- Include explanations for the design choices you made in terms of algorithms and libraries.
- Write a report summarizing the concepts of symmetric and asymmetric cryptography, hash functions, and their practical applications.
- Include screenshots or examples of the program in action for each part.