首页 > 编程语言 >FIT3155 S1 加解密算法

FIT3155 S1 加解密算法

时间:2023-05-28 17:55:40浏览次数:47  
标签:exponent S1 加解密 two public will program FIT3155 your


FIT3155 S1/2023: Assignment 3
(Due midnight 11:55pm on Sunday 28 May 2023)
[Weight: 10 = 5 + 5 marks.]
Your assignment will be marked on the performance/efficiency of your programs. You must
write all the code yourself, and should not use any external library routines that interferes
with the assessable items, except those that are considered standard. The usual input/output
and other unavoidable routines are exempted. Importing random (for q1) and numpy (for
using Matrix and numpy arrays to handle q2) is allowed.
Follow these procedures while submitting this assignment:
The assignment should be submitted online via moodle strictly as follows:
ˆ All your scripts MUST contain your name and student ID.
ˆ Bundle and upload your work as a ⟨studentid⟩.tar.gz or ⟨studentid⟩.zip archive.
– Your archive should extract to a single directory which is your student ID.
– This directory should contain a subdirectory for each of the two questions, named
as: q1/ and q2/.
– Your corresponding scripts and work should be tucked within those subdirectories.
ˆ Submit your zipped-archive electronically via Moodle.
Academic integrity, plagiarism and collusion
Monash University is committed to upholding high standards of honesty and academic
integrity. As a Monash student your responsibilities include developing the knowledge
and skills to avoid plagiarism and collusion. Read carefully the material available at
https://www.monash.edu/students/academic/policies/academic-integrity (click) to understand your responsibilities. As per FIT policy, all submissions will be scanned via MOSS
(click) and/or JPlag (click).
Generative AI not allowed!
This unit fully restricts you from availing/using generative AI to answer these assessed
questions.
1
Question 1: Generating a public key [5 marks]
Background
RSA (Rivest–Shamir–Adleman) is a public-key encryption system that is popular in modern
internet communications. A public key as the word suggests is publicly advertised. A system
using RSA generates a public key in the form of a modulus n and exponent e using two large
prime numbers. While n and e are public, the two prime numbers that were used to generate
them are held secretly away from the public eye. Anyone wanting to communicate with the
system uses the public key information to encrypt any message. A secure message can only
be unlocked using the knowledge of the prime numbers behind the public key. The reliability
of such a cryptosystem is purely due to the infeasibility of factorizing any number (especially
large ones) into its prime factors on classical computers.1
Task on hand
In this exercise, inspired by RSA (but not exactly the same in details), we will be generating
two integers, modulus n and exponent e, as a public key.2
The steps you need to follow to generate n and e are described in the corresponding sections
below. To pull this off, you will have to implement on your own the following:
1. Modular exponentiation with repeated squaring.
2. Miller-Rabin randomized primality test with appropriate level of confidence that the test
is probably correct.
3. Euclid algorithm to compute the greatest common divisor of any two numbers.
You are free to use the built-in basic arithmetic operations (addition, subtraction, multiplication, division and modulo division). However, note, as indicted above (see enumerated item 1),
you will have to implement your own modular exponentiation using repeated squaring method.
Generating the modulus n
In this exercise, the modulus of the public key n = p × q is a product of two special kind of
prime numbers p and q we will use in this exercise.
How are these prime numbers selected in this exercise? Suppose d > 2 ∈ Z
+ is an
input parameter to your program. Then p and q respectively are the smallest two prime integers
of the form 2x − 1 where x ≥ d. For all practical purposes, you are free to assume d ≤ 2000 for
this exercise.
1Unless, in the foreseeable future, a quantum computer with sufficient number of ‘qubits’ becomes a reality,
to be able run a well-established integer factorization algorithm (Shor’s algorithm) on it. It is claimed that what
takes quadrillion years to factorize on a classical computer would only take seconds (!) using Shor’s algorithm
on a quantum computer.
2To keep things simple, we will not worry about the actual encryption and decryption of messages in this
exercise, but for the more keen ones, you are encouraged to explore the mathematics behind these processes
that will inform a fuller implementation of what you started here, for your own further learning.
2
Generating the exponent e
The exponent e is computed using p and q as follows. First a value λ is calculated such that
λ =
(p−1)(q−1)
gcd(p−1,q−1) . (You will have to implement Euclid’s algorithm to compute gcd.)
The exponent e is randomly chosen in the range [3, λ − 1] such that gcd(e, λ) = 1, that is e
and λ are relatively prime.
Strictly follow the specification below to address this question:
Program name: mykeygen.py
Arguments to your program: input integer d ≥ 1
Command line usage of your script:
python mykeygen.py <d>
Output files: You will have to write out two files:
1. publickeyinfo.txt giving 代写 iFIT3155 S nformation of the modulus n and exponent e.
2. secretprimes.txt giving the information of the two primes p and q
Output formats: See example below.
Example: For d = 10,
publickeyinfo.txt will contain:
# modulus (n)
1073602561
# exponent (e)
3187811
secretprimes.txt will contain:
# p
8191
# q
131071
(Note, in the publickeyinfo.txt file, the exponent is randomly chosen, so its value will
vary each time you run your program with the same argument. Also note that, in both
the output files, the markup lines starting with # should also be printed as shown in the
example above.
Question 2: Implementing Tableau Simplex [5 Marks]
In this exercise you are required to implement Dantzig’s Tableau simplex algorithm to solve a
linear program in its standard form, that was covered in the Week 10 lecture.
Your program will read an input text file (see input format below) specifying a linear
program. The linear program by default will be in a standard form. This means that the goal
3
is always to maximize a given linear objective function, involving decision variables that are
always non-negative, subject to a set of linear constraints on the decision variables that are
expressed in the form: LHS ≤ RHS.
Your goal is to find an optimal set of values for the decision variables and the resultant
evaluation of the objective function given those values. To report these, you will have to
implement the exact same Tableau method that we discussed during the week 10 lecture.
Strictly follow the specification below to address this question:
Program name: mysimplex.py
Argument to your program: Filename of an input file giving the details of the linear program in a specific format (see example below).
Command line usage of your script:
python mysimplex.py <filename of a file specifying LP>
Input format: As an example, if the linear program being considered is the following:
maximize z = x + 2y
subject to the constraints
4x + y ≤ 44
3x + 2y ≤ 39
2x + 3y ≤ 37
y ≤ 9
−x + y ≤ 6
(with the implicit constraints that both x and y decision variables are non-negative (≥ 0)) then the input specification
format for this linear programming problem will be as follows (including the # lines):
# numDecisionVariables
2
# numConstraints
5
#objective
1, 2
# constraintsLHSMatrix
4, 1
3, 2
2, 3
0, 1
-1, 1
# constraintsRHSVector
44
39
37
9
6
Output file name: lpsolution.txt (see format below)
Output format For the above example LP problem specified as input, the output would be
in the following form (including the # lines):
# optimalDecisions
5, 9
# optimalObjective
23
-=o0o=-
END
-=o0o=-

 WX:codehelp

标签:exponent,S1,加解密,two,public,will,program,FIT3155,your
From: https://www.cnblogs.com/simpleyfc/p/17438565.html

相关文章

  • 转载-如何结合FT2232HL/CMSIS-DAP+Eclipse+OpenOCD软硬件工具使用SWD调试接口在Window
    原文链接:https://blog.csdn.net/zhuwade/article/details/121944736由于我们公司自己需要开发烧录工具,本人通过google搜相关文档和看ARM公司的技术文档,终于实现了这个功能。因为涉及的内容知识点比较多,对于玩嵌入式MCU的小白来说要普及的知识,逐个介绍篇幅会比较长,本文中只介绍......
  • 尝试使用硬件电路来解释CRC计算(DS1820或者DS1822的CRC计算)
       之前在培训讲解DS1822的测试时,CRC计算都是以C语言进行讲解的。今天在练习Verilog的时候,觉得也可以使用硬件电路来讲解。   DS1820的CRC计算硬件电路示意图如下:   这个是示意图,方框代表寄存器,XOR代表异或门。Verilog的硬件描述如下:1moduleD_FF2(3......
  • windows11 安装 Rancher Desktop
    从官网下载了最新版的Rancher.Desktop.Setup.1.8.1.msi安装包,安装很顺利。但是安装完,启动时报错Thek3scacheisemptyandthereisnonetworkconnection.不明所以,网上查了,原来是github访问不了的原因,具体看这个#issue3741,大意就是网络问题,而提这个问题的哥们自己用代理......
  • 【K8s入门推荐】K8s1.24版本部署全教程,轻松掌握技巧kubeadm丨Kubernetes丨容器编排丨
    通过kubeadm方式极速部署Kubernetes1.24版本前言在Kubernetes的搭建过程中,繁琐的手动操作和复杂的配置往往会成为制约部署效率的关键因素。而使用kubeadm工具可以避免这些问题,大大提高集群的部署效率和部署质量。本文将为大家详细介绍如何使用kubeadm工具快速搭建Kubernetes1.24......
  • kettlle9.3 密码加解密
    kettlecmdencr.sh-kettle123kettle客户端javascript组件核心对象->新建->javascript脚本->获取变量->限制1->生成记录1//Scripthere//加密varsetValue;setValue=Packages.org.pentaho.di.core.encryption.Encr.encryptPassword('123456');javaimp......
  • arduino esp32 ds18b20 实例代码
    #include<OneWire.h>#include<DallasTemperature.h>//引脚定义#defineONE_WIRE_BUS15//库引用实例OneWireoneWire(ONE_WIRE_BUS);DallasTemperaturesensors(&oneWire);voidsetup(void){Serial.begin(9600);sensors.begin();}voidloop(vo......
  • 【GiraKoo】在U盘中安装Windows11系统(WindowsToGo)
    在U盘中安装Windows11系统(WindowsToGo)本文介绍如何利用Rufus工具,将Windows安装到U盘中。在尝试过多款所谓的WindowsToGo工具,均遇到了无法引导的情况。最终使用Rufus工具成功安装启动。下载RufusRufus是非常棒的U盘格式化,制作启动盘,系统盘的优秀工具。并且当前已经支持WindowsT......
  • 《MS17-010(永恒之蓝)—漏洞复现及防范》
    作者:susususuao免责声明:本文仅供学习研究,严禁从事非法活动,任何后果由使用者本人负责。一.什么是永恒之蓝?-永恒之蓝永恒之蓝(EternalBlue)是一种利用Windows系统的SMB协议漏洞来获取系统的最高权限,以此来控制被入侵的计算机。而SMB服务是一个协议名,它能被用于Web连接和客......
  • Windows10 无法更新密码。为新密码提供的值不符合字符域的长度、复杂性或历史要求
    域账号死活无法修改密码,说要求不足,可是AD域几乎不限制密码条件。Ctrl+Alt+Del改自己管理员密码唯一找到的解决方法:只有在勾选"下次变更密码"时使用者换密码系统才会认定符合複杂度要求,这样操作可以正常修改密码    ......
  • 2、yum安装postgres15.3
    目录yum安装postgres15.31、选择安装的版本1.532、创建postgres用户3、执行yum安装命令4、修改配置文件4.1、修改postgresql.conf4.2、修改pg_hba.confyum安装postgres15.31、选择安装的版本1.53参考官网文档:https://www.postgresql.org/download/linux/redhat/2、创建postgr......