COSC2536 Practical Week 04
ElGamal encryption
Q1 Read the following and answer the question that follows:
Alice has a message M=25 to send to Bob securely using ElGamal encryption algorithm. Bob chooses p=83, g=39,
x=66. Alice chooses r=28.
Show the encryption and decryption steps.
Paillier encryption
Q2 Read the following and answer the question that follows:
Alice has a message M=1 to send to Bob securely using Paillier encryption algorithm. Bob chooses p=5, q=7, and
selects an integer g =164. Alice selects a random number r=17.
Show the encryption and decryption steps.
Note: Feel free to use any of listed mathematical calculators here:
https://rmit.instructure.com/courses/131922/pages/list-of-mathematical-calculators
Installation of Python & Visual Studio Code
Q3 We will move to programming of cryptography from next week. You will need this for assessment 2 (kindly note no
programming is needed for assessment 1). We will be using the following for this course:
Programming language: Python
IDE: Visual Studio Code
You need to make sure that both free software(s) are installed on your laptop.
Step 1 Install Visual Studio Code
• Visual Studio Code: kindly install via this URL: https://code.visualstudio.com
COSC2536 | Semester 2, 2024 Page 1 of 4
COSC2536 Practical Week 04
Step 2 Install Python
Mac:
Note: sometimes Python is already installed- open Terminal and type
python3 --version
• Press enter and if you see a version number, it is installed on your mac. If you see a version # then it is already
installed on your mac. If you want to upgrade it to latest version, browse to https://www.python.org/downloads/
• Download latest version and upgrade.
Note: if it is not installed on the Mac
• Browse to https://www.python.org/downloads/
• Download latest version and install and then open terminal and type
python3 --version
Do you see this?
Python 3.12.4
Windows:
It is slightly trickier to install on windows as you have to set the path of installed Python interpreter as well. Best to follow
the instructions here:
• How to install Python on Windows?
o [https://www.digitalocean.com/community/tutorials/install-python-windows-10]
• Once installed, check the version on the terminal window by typing
python --version
COSC2536 | Semester 2, 2024 Page 2 of 4
COSC2536 Practical Week 04
Step 3 Install Python extension in Visual Studio Code
You can install plugins within Visual Studio Code, that will make your Python coding a lot simpler and more fun. Install
via Extensions tab in Visual Studio Code.
Open Visual Studio code- click on Extensions tab on the left-hand side:
Extensions tab
Search for Python extension
Choose the very first extension in the list, it is Microsoft’s Python Extension and install. Wait for few minutes and you
are done!
COSC2536 | Semester 2, 2024 Page 3 of 4
COSC2536 Practical Week 04
Step 4 Write first Python code and run
Create a new file – New File… - Python File
The Python extension then provides shortcuts to run Python code using the currently selected interpreter
(Python: Select Interpreter in the Command Palette). To run the active Python file, click the Run Python
File in Terminal play button in the top-right side of the editor.
You can also run individual lines or a selection of code with the Python: Run Selection/Line in Python
Terminal command (Shift+Enter). If there isn't a selection, the line with your cursor will be run in the Python Terminal.
COSC2536 | Semester 2, 2024 Page 4 of 4