词条 | Modular multiplicative inverse |
释义 |
In mathematics, in particular the area of number theory, a modular multiplicative inverse of an integer {{mvar|a}} is an integer {{mvar|x}} such that the product {{mvar|ax}} is congruent to 1 with respect to the modulus {{mvar|m}}.[1] In the standard notation of modular arithmetic this congruence is written as which is the shorthand way of writing the statement that {{mvar|m}} divides (evenly) the quantity {{math|ax − 1}}, or, put another way, the remainder after dividing {{mvar|ax}} by the integer {{mvar|m}} is 1. If {{mvar|a}} does have an inverse modulo {{mvar|m}} there are an infinite number of solutions of this congruence which form a congruence class with respect to this modulus. Furthermore, any integer that is congruent to {{mvar|a}} (i.e., in {{mvar|a}}'s congruence class) will have any element of {{mvar|x}}'s congruence class as a modular multiplicative inverse. Using the notation of to indicate the congruence class containing {{mvar|w}}, this can be expressed by saying that the modulo multiplicative inverse of the congruence class is the congruence class such that: where the symbol denotes the multiplication of equivalence classes modulo {{mvar|m}}.[2] Written in this way the analogy with the usual concept of a multiplicative inverse in the set of rational or real numbers is clearly represented, replacing the numbers by congruence classes and altering the binary operation appropriately. As with the analogous operation on the real numbers, a fundamental use of this operation is in solving, when possible, linear congruences of the form, Finding modular multiplicative inverses also has practical applications in the field of cryptography, i.e. public-key cryptography and the RSA Algorithm.[3][4][5] A benefit for the computer implementation of these applications is that there exists a very fast algorithm (the extended Euclidean algorithm) that can be used for the calculation of modular multiplicative inverses. Modular arithmetic{{main|Modular arithmetic}}For a given positive integer {{mvar|m}}, two integers, {{mvar|a}} and {{mvar|b}}, are said to be congruent modulo {{mvar|m}} if {{mvar|m}} divides their difference. This binary relation is denoted by, This is an equivalence relation on the set of integers, {{math|ℤ}}, and the equivalence classes are called congruence classes modulo {{mvar|m}} or residue classes modulo {{mvar|m}}. Let denote the congruence class containing the integer {{mvar|a}},[6] then A linear congruence is a modular congruence of the form Unlike linear equations over the reals, linear congruences may have zero, one or several solutions. If {{mvar|x}} is a solution of a linear congruence then every element in is also a solution, so, when speaking of the number of solutions of a linear congruence we are referring to the number of different congruence classes that contain solutions. If {{mvar|d}} is the greatest common divisor of {{mvar|a}} and {{mvar|m}} then the linear congruence {{math|ax ≡ b (mod m)}} has solutions if and only if {{mvar|d}} divides {{mvar|b}}. If {{mvar|d}} divides {{mvar|b}}, then there are exactly {{mvar|d}} solutions.[7] A modular multiplicative inverse of an integer {{mvar|a}} with respect to the modulus {{mvar|m}} is a solution of the linear congruence The previous result says that a solution exists if and only if {{math|1=gcd(a, m) = 1}}, that is, {{mvar|a}} and {{mvar|m}} must be relatively prime (i.e. coprime). Furthermore, when this condition holds, there is exactly one solution, i.e., when it exists, a modular multiplicative inverse is unique.[8] When {{math|ax ≡ 1 (mod m)}} has a solution it is often denoted in this way − but this is an abuse of notation since a modular multiplicative inverse is an integer and {{math|a−1}} is not an integer when {{mvar|a}} is an integer other than 1 or - 1. The notation would be proper if {{mvar|a}} is interpreted as a token standing for the congruence class , as the multiplicative inverse of a congruence class is a congruence class with the multiplication defined in the next section. Integers modulo {{mvar|m}}The congruence relation, modulo {{mvar|m}}, partitions the set of integers into {{mvar|m}} congruence classes. Operations of addition and multiplication can be defined on these {{mvar|m}} objects in the following way: To either add or multiply two congruence classes, first pick a representative (in any way) from each class, then perform the usual operation for integers on the two representatives and finally take the congruence class that the result of the integer operation lies in as the result of the operation on the congruence classes. In symbols, with and representing the operations on congruence classes, these definitions are and These operations are well-defined, meaning that the end result does not depend on the choices of representatives that were made to obtain the result. The {{mvar|m}} congruence classes with these two defined operations form a ring, called the ring of integers modulo {{mvar|m}}. There are several notations used for these algebraic objects, most often or , but several elementary texts and application areas use a simplified notation when confusion with other algebraic objects is unlikely. The congruence classes of the integers modulo {{mvar|m}} were traditionally known as residue classes modulo m, reflecting the fact that all the elements of a congruence class have the same remainder (i.e., "residue") upon being divided by {{mvar|m}}. Any set of {{mvar|m}} integers selected so that each comes from a different congruence class modulo m is called a complete system of residues modulo {{mvar|m}}.[9] The division algorithm shows that the set of integers, {{math|{0, 1, 2, ..., m − 1} }} form a complete system of residues modulo {{mvar|m}}, known as the least residue system modulo {{mvar|m}}. In working with arithmetic problems it is sometimes more convenient to work with a complete system of residues and use the language of congruences while at other times the point of view of the congruence classes of the ring is more useful.[10] Multiplicative group of integers modulo {{mvar|m}}{{main|Multiplicative group of integers modulo n}}Not every element of a complete residue system modulo {{mvar|m}} has a modular multiplicative inverse, for instance, zero never does. After removing the elements of a complete residue system that are not relatively prime to {{mvar|m}}, what is left is called a reduced residue system, all of whose elements have modular multiplicative inverses. The number of elements in a reduced residue system is , where is the Euler totient function, i.e., the number of positive integers less than {{mvar|m}} that are relatively prime to {{mvar|m}}. In a general ring with unity not every element has a multiplicative inverse and those that do are called units. As the product of two units is a unit, the units of a ring form a group, the group of units of the ring and often denoted by {{math|R×}} if {{mvar|R}} is the name of the ring. The group of units of the ring of integers modulo {{mvar|m}} is called the multiplicative group of integers modulo {{mvar|m}}, and it is isomorphic to a reduced residue system. In particular, it has order (size), . In the case that {{mvar|m}} is a prime, say {{mvar|p}}, then and all the non-zero elements of have multiplicative inverses, thus is a finite field. In this case, the multiplicative group of integers modulo {{mvar|p}} form a cyclic group of order {{math|p − 1}}. ExampleTo illustrate the above definitions consider the following example using the modulus 10. Two integers are congruent mod 10 if and only if their difference is divisible by 10, for instance since 10 divides 32 − 12 = 20, and since 10 divides 111 − 1 = 110. Some of the ten congruence classes with respect to this modulus are: and The linear congruence {{math|4x ≡ 5 (mod 10)}} has no solutions since the integers that are congruent to 5 (i.e., those in ) are all odd while {{math|4x}} is always even. However, the linear congruence {{math|4x ≡ 6 (mod 10)}} has two solutions, namely, {{math|1=x = 4}} and {{math|1=x = 9}}. The {{math|1=gcd(4, 10) = 2}} and 2 does not divide 5, but does divide 6. Since {{math|1=gcd(3, 10) = 1}}, the linear congruence {{math|3x ≡ 1 (mod 10)}} will have solutions, that is, modular multiplicative inverses of 3 modulo 10 will exist. In fact, 7 satisfies this congruence (i.e., 21 − 1 = 20). However, other integers also satisfy the congruence, for instance 17 and −3 (i.e., 3(17) − 1 = 50 and 3(−3) − 1 = −10). In particular, every integer in will satisfy the congruence since these integers have the form {{math|7 + 10r}} for some integer {{mvar|r}} and is clearly divisible by 10. This congruence has only this one congruence class of solutions. The solution in this case could have been obtained by checking all possible cases, but systematic algorithms would be needed for larger moduli and these will be given in the next section. The product of congruence classes and can be obtained by selecting an element of , say 25, and an element of , say −2, and observing that their product (25)(−2) = −50 is in the congruence class . Thus, . Addition is defined in a similar way. The ten congruence classes together with these operations of addition and multiplication of congruence classes form the ring of integers modulo 10, i.e., . A complete residue system modulo 10 can be the set {10, −9, 2, 13, 24, −15, 26, 37, 8, 9} where each integer is in a different congruence class modulo 10. The unique least residue system modulo 10 is {0, 1, 2, ..., 9}. A reduced residue system modulo 10 could be {1, 3, 7, 9}. The product of any two congruence classes represented by these numbers is again one of these four congruence classes. This implies that these four congruence classes form a group, in this case the cyclic group of order four, having either 3 or 7 as a (multiplicative) generator. The represented congruence classes form the group of units of the ring . These congruence classes are precisely the ones which have modular multiplicative inverses. ComputationExtended Euclidean algorithm{{main|Extended Euclidean algorithm}}{{wikibooks|Algorithm Implementation|Mathematics/Extended Euclidean algorithm|Extended Euclidean algorithm}}A modular multiplicative inverse of {{math|a}} modulo {{math|m}} can be found by using the extended Euclidean algorithm. The Euclidean algorithm determines the greatest common divisor (gcd) of two integers, say {{mvar|a}} and {{mvar|m}}. If {{mvar|a}} has a multiplicative inverse modulo {{mvar|m}}, this gcd must be 1. The last of several equations produced by the algorithm may be solved for this gcd. Then, using a method called "back substitution", an expression connecting the original parameters and this gcd can be obtained. In other words, integers {{mvar|x}} and {{mvar|y}} can be found to satisfy Bézout's identity, Rewritten, this is that is, so, a modular multiplicative inverse of {{mvar|a}} has been calculated. A more efficient version of the algorithm is the extended Euclidean algorithm, which, by using auxiliary equations, reduces two passes through the algorithm (back substitution can be thought of as passing through the algorithm in reverse) to just one. In big O notation, this algorithm runs in time {{math|O(log(m)2)}}, assuming {{math|{{abs|a}} < m}}, and is considered to be very fast and generally more efficient than its alternative, exponentiation. Using Euler's theoremAs an alternative to the extended Euclidean algorithm, Euler's theorem may be used to compute modular inverses.[11] According to Euler's theorem, if {{math|a}} is coprime to {{math|m}}, that is, {{math|1=gcd(a, m) = 1}}, then where is Euler's totient function. This follows from the fact that {{math|a}} belongs to the multiplicative group × if and only if {{math|a}} is coprime to {{math|m}}. Therefore, a modular multiplicative inverse can be found directly: In the special case where {{math|m}} is a prime, and a modular inverse is given by This method is generally slower than the extended Euclidean algorithm, but is sometimes used when an implementation for modular exponentiation is already available. Some disadvantages of this method include:
ApplicationsFinding a modular multiplicative inverse has many applications in algorithms that rely on the theory of modular arithmetic. For instance, in cryptography the use of modular arithmetic permits some operations to be carried out more quickly and with fewer storage requirements, while other operations become more difficult.[12] Both of these features can be used to advantage. In particular, in the RSA algorithm, encrypting and decrypting a message is done using a pair of numbers that are multiplicative inverses with respect to a carefully selected modulus. One of these numbers is made public and can be used in a rapid encryption procedure, while the other, used in the decryption procedure, is kept hidden. Determining the hidden number from the public number is considered to be computationally infeasible and this is what makes the system work to ensure privacy.[13] As another example in a different context, consider the exact division problem in computer science where you have a list of odd word-sized numbers each divisible by {{math|k}} and you wish to divide them all by {{math|k}}. One solution is as follows:
On many machines, particularly those without hardware support for division, division is a slower operation than multiplication, so this approach can yield a considerable speedup. The first step is relatively slow but only needs to be done once. Modular multiplicative inverses are used to obtain a solution of a system of linear congruences that is guaranteed by the Chinese Remainder Theorem. For example, the system {{mvar|X}} ≡ 4 (mod 5) {{mvar|X}} ≡ 4 (mod 7) {{mvar|X}} ≡ 6 (mod 11) has common solutions since 5,7 and 11 are pairwise coprime. A solution is given by {{mvar|X}} = {{math|t1}} (7 × 11) × 4 + {{math|t2}} (5 × 11) × 4 + {{math|t3}} (5 × 7) × 6 where {{math|t1}} = 3 is the modular multiplicative inverse of 7 × 11 (mod 5), {{math|t2}} = 6 is the modular multiplicative inverse of 5 × 11 (mod 7) and {{math|t3}} = 6 is the modular multiplicative inverse of 5 × 7 (mod 11). Thus, {{mvar|X}} = 3 × (7 × 11) × 4 + 6 × (5 × 11) × 4 + 6 × (5 × 7) × 6 = 3504 and in its unique reduced form {{mvar|X}} ≡ 3504 ≡ 39 (mod 385) since 385 is the LCM of 5,7 and 11. See also
Notes1. ^{{harvnb|Rosen|1993|page=132}} 2. ^{{harvnb|Schumacher|1996|loc=p. 88}} 3. ^{{citation|first=Douglas R.|last=Stinson|title=Cryptography / Theory and Practice|year=1995|publisher=CRC Press|isbn=0-8493-8521-0|pages=124–128}} 4. ^{{harvnb|Trappe|Washington|2006|loc=pp. 164−169}} 5. ^{{Cite web|url=https://tools.ietf.org/html/rfc8017#section-3|title=PKCS #1: RSA Cryptography Specifications Version 2.2|last=Moriarty|first=K.|last2=Kaliski|first2=B.|date=|year=2016|website=Internet Engineering Task Force RFC 8017|publisher=Internet Engineering Task Force|access-date=January 21, 2017|last3=Jonsson|first3=J.|last4=Rusch|first4=A.}} 6. ^Other notations are often used, including {{math|[a]}} and {{math|[a]m}}. 7. ^{{harvnb|Ireland|Rosen|1990|page=32}} 8. ^{{citation|last=Shoup|first=Victor|title=A Computational Introduction to Number Theory and Algebra|url=https://books.google.com/books?id=-RzJs-mPfX0C&pg=PA15|year=2005|authorlink=Victor Shoup|at=Theorem 2.4, p. 15|publisher=Cambridge University Press|isbn=9780521851541}} 9. ^{{harvnb|Rosen|1993|page=121}} 10. ^{{harvnb|Ireland|Rosen|1990|page=31}} 11. ^Thomas Koshy. [https://books.google.com/books?id=d5Z5I3gnFh0C&pg=PA346 Elementary number theory with applications], 2nd edition. {{isbn|978-0-12-372487-8}}. P. 346. 12. ^{{harvnb|Trappe|Washington|2006|loc=p. 167}} 13. ^{{harvnb|Trappe|Washington|2006|loc=p. 165}} References
External links
2 : Modular arithmetic|Binary operations |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。