In many cryptographic applications the Modular Inverse is a key operation. This programming problem involves finding the modular inverse of a number. Given 0

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Pls help and code in java!!!! Thank you so much!

In many cryptographic applications the Modular Inverse is a key operation. This programming problem
involves finding the modular inverse of a number.
Given 0 < x <m, where x and m are integers, the modular inverse of x is the unique integer n, 0 <n<m,
such that the remainder upon dividing x x n by m is 1. That is, x x n mod m = 1.
Modular inverse is a concept that extends the arithmetic inverse. For example, the inverse of 2 is ½
because 2 x 12 = 1 with decimal operation. Here the inverse number can be a fraction.
In modular inverse, we only allow integers, no fraction. So not all integer has an inverse.
For example, m = 26, x = 3, the modular inverse of 3 is 9 because 3 x 9 mod 26 1.
However, m = 26, x = 2, the modular inverse of 2 does not exist because you cannot find a number y so
that 2 x y mod 26 = 1.
Here is another example, m = 17, 4 x 13 = 52 = 17 x 3 + 1, so the remainder when 52 is divided by 17 is
1, and thus 13 is the inverse of 4 modulo 17.
You are to write a method modularlnverse() which accepts as input the two integers x and m, and outputs
either the modular inverse n, or -1 to indicate "No such integer exists." if there is no such integer n.
You may assume that m ≤ 100, x and m non-negative.
public class Modlnverse {
public static void main(String[] args) {
int m = 26;
for (int x = 0; x<m; x++) {
int n = modularlnverse(x, m);
if (n == -1){
System.out.println("The modular inverse of x " + x + " does not exit.");
} else {
System.out.println("The modular inverse of x " + x + " is: " +n + "for mod " + m);
}
}
//Expect: the mod inverse with mod 26 as follows
// 1 3 5 7 9 11 15 17 19 21 23 25
// 19 21 15 3 19 7 23 11 5 17 25
}
public static int modularlnverse(int x, int m) {
//your code
return -1;
Transcribed Image Text:In many cryptographic applications the Modular Inverse is a key operation. This programming problem involves finding the modular inverse of a number. Given 0 < x <m, where x and m are integers, the modular inverse of x is the unique integer n, 0 <n<m, such that the remainder upon dividing x x n by m is 1. That is, x x n mod m = 1. Modular inverse is a concept that extends the arithmetic inverse. For example, the inverse of 2 is ½ because 2 x 12 = 1 with decimal operation. Here the inverse number can be a fraction. In modular inverse, we only allow integers, no fraction. So not all integer has an inverse. For example, m = 26, x = 3, the modular inverse of 3 is 9 because 3 x 9 mod 26 1. However, m = 26, x = 2, the modular inverse of 2 does not exist because you cannot find a number y so that 2 x y mod 26 = 1. Here is another example, m = 17, 4 x 13 = 52 = 17 x 3 + 1, so the remainder when 52 is divided by 17 is 1, and thus 13 is the inverse of 4 modulo 17. You are to write a method modularlnverse() which accepts as input the two integers x and m, and outputs either the modular inverse n, or -1 to indicate "No such integer exists." if there is no such integer n. You may assume that m ≤ 100, x and m non-negative. public class Modlnverse { public static void main(String[] args) { int m = 26; for (int x = 0; x<m; x++) { int n = modularlnverse(x, m); if (n == -1){ System.out.println("The modular inverse of x " + x + " does not exit."); } else { System.out.println("The modular inverse of x " + x + " is: " +n + "for mod " + m); } } //Expect: the mod inverse with mod 26 as follows // 1 3 5 7 9 11 15 17 19 21 23 25 // 19 21 15 3 19 7 23 11 5 17 25 } public static int modularlnverse(int x, int m) { //your code return -1;
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Encryption and decryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education