How to calculate mod inverse
up vote
0
down vote
favorite
Given a number set of integers $mathbb{Z}$, how do I find the inverse of a given number?
I am trying to test an algorithm to extract the $k$ and $x$ values from the Elgamal Signature algorithm given that $k$ is repeated.
What I have is
$k$ congruent to $(m_1 - m_2)times(s_1 - s_2)^{-1} mod p - 1$
given $k$ is used twice.
I am not sure how to calculate the mod inverse though?
_
Is the above formula the same thing as $((m_1 - m_2) mod p -1 times (s_1 - s_2)^{-1} mod p -1) mod p -1$
I am not sure if it is any different since I am doing a mod inverse.
PS. I am a programmer, not a mathematician so please elaborate.
number-theory
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
|
show 3 more comments
up vote
0
down vote
favorite
Given a number set of integers $mathbb{Z}$, how do I find the inverse of a given number?
I am trying to test an algorithm to extract the $k$ and $x$ values from the Elgamal Signature algorithm given that $k$ is repeated.
What I have is
$k$ congruent to $(m_1 - m_2)times(s_1 - s_2)^{-1} mod p - 1$
given $k$ is used twice.
I am not sure how to calculate the mod inverse though?
_
Is the above formula the same thing as $((m_1 - m_2) mod p -1 times (s_1 - s_2)^{-1} mod p -1) mod p -1$
I am not sure if it is any different since I am doing a mod inverse.
PS. I am a programmer, not a mathematician so please elaborate.
number-theory
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Use the Extended Euclidean Algorithm, e.g. see here
– Bill Dubuque
2 days ago
I know how to find a mod inverse. But if I have a number A*B^-1 mod p-1 is that equivalent to A mod p-1 * B mod p-1 mod p-1. That is what I found online but I wasn't sure.
– User
2 days ago
$ab$ is invertible $iff a,b$ are invertible $iff a,b,$ are coprime to the modulus. When so we have $(ab)^{-1}equiv b^{-1}a^{-1},$ by $ b^{-1}a^{-1} (ab) equiv b^{-1}(a^{-1}a)bequiv b^{-1}b equiv 1 $ (inverses are always unique)
– Bill Dubuque
2 days ago
So what if I have a number * an inverse mod p -1. How would I break that down?
– User
2 days ago
Calculate the inverse then modular_multiply the two as you would any pair of (modular) integers - using the mod prodcut rule
– Bill Dubuque
2 days ago
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Given a number set of integers $mathbb{Z}$, how do I find the inverse of a given number?
I am trying to test an algorithm to extract the $k$ and $x$ values from the Elgamal Signature algorithm given that $k$ is repeated.
What I have is
$k$ congruent to $(m_1 - m_2)times(s_1 - s_2)^{-1} mod p - 1$
given $k$ is used twice.
I am not sure how to calculate the mod inverse though?
_
Is the above formula the same thing as $((m_1 - m_2) mod p -1 times (s_1 - s_2)^{-1} mod p -1) mod p -1$
I am not sure if it is any different since I am doing a mod inverse.
PS. I am a programmer, not a mathematician so please elaborate.
number-theory
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Given a number set of integers $mathbb{Z}$, how do I find the inverse of a given number?
I am trying to test an algorithm to extract the $k$ and $x$ values from the Elgamal Signature algorithm given that $k$ is repeated.
What I have is
$k$ congruent to $(m_1 - m_2)times(s_1 - s_2)^{-1} mod p - 1$
given $k$ is used twice.
I am not sure how to calculate the mod inverse though?
_
Is the above formula the same thing as $((m_1 - m_2) mod p -1 times (s_1 - s_2)^{-1} mod p -1) mod p -1$
I am not sure if it is any different since I am doing a mod inverse.
PS. I am a programmer, not a mathematician so please elaborate.
number-theory
number-theory
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 days ago


Mason
1,6521325
1,6521325
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 days ago
User
1
1
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Use the Extended Euclidean Algorithm, e.g. see here
– Bill Dubuque
2 days ago
I know how to find a mod inverse. But if I have a number A*B^-1 mod p-1 is that equivalent to A mod p-1 * B mod p-1 mod p-1. That is what I found online but I wasn't sure.
– User
2 days ago
$ab$ is invertible $iff a,b$ are invertible $iff a,b,$ are coprime to the modulus. When so we have $(ab)^{-1}equiv b^{-1}a^{-1},$ by $ b^{-1}a^{-1} (ab) equiv b^{-1}(a^{-1}a)bequiv b^{-1}b equiv 1 $ (inverses are always unique)
– Bill Dubuque
2 days ago
So what if I have a number * an inverse mod p -1. How would I break that down?
– User
2 days ago
Calculate the inverse then modular_multiply the two as you would any pair of (modular) integers - using the mod prodcut rule
– Bill Dubuque
2 days ago
|
show 3 more comments
2
Use the Extended Euclidean Algorithm, e.g. see here
– Bill Dubuque
2 days ago
I know how to find a mod inverse. But if I have a number A*B^-1 mod p-1 is that equivalent to A mod p-1 * B mod p-1 mod p-1. That is what I found online but I wasn't sure.
– User
2 days ago
$ab$ is invertible $iff a,b$ are invertible $iff a,b,$ are coprime to the modulus. When so we have $(ab)^{-1}equiv b^{-1}a^{-1},$ by $ b^{-1}a^{-1} (ab) equiv b^{-1}(a^{-1}a)bequiv b^{-1}b equiv 1 $ (inverses are always unique)
– Bill Dubuque
2 days ago
So what if I have a number * an inverse mod p -1. How would I break that down?
– User
2 days ago
Calculate the inverse then modular_multiply the two as you would any pair of (modular) integers - using the mod prodcut rule
– Bill Dubuque
2 days ago
2
2
Use the Extended Euclidean Algorithm, e.g. see here
– Bill Dubuque
2 days ago
Use the Extended Euclidean Algorithm, e.g. see here
– Bill Dubuque
2 days ago
I know how to find a mod inverse. But if I have a number A*B^-1 mod p-1 is that equivalent to A mod p-1 * B mod p-1 mod p-1. That is what I found online but I wasn't sure.
– User
2 days ago
I know how to find a mod inverse. But if I have a number A*B^-1 mod p-1 is that equivalent to A mod p-1 * B mod p-1 mod p-1. That is what I found online but I wasn't sure.
– User
2 days ago
$ab$ is invertible $iff a,b$ are invertible $iff a,b,$ are coprime to the modulus. When so we have $(ab)^{-1}equiv b^{-1}a^{-1},$ by $ b^{-1}a^{-1} (ab) equiv b^{-1}(a^{-1}a)bequiv b^{-1}b equiv 1 $ (inverses are always unique)
– Bill Dubuque
2 days ago
$ab$ is invertible $iff a,b$ are invertible $iff a,b,$ are coprime to the modulus. When so we have $(ab)^{-1}equiv b^{-1}a^{-1},$ by $ b^{-1}a^{-1} (ab) equiv b^{-1}(a^{-1}a)bequiv b^{-1}b equiv 1 $ (inverses are always unique)
– Bill Dubuque
2 days ago
So what if I have a number * an inverse mod p -1. How would I break that down?
– User
2 days ago
So what if I have a number * an inverse mod p -1. How would I break that down?
– User
2 days ago
Calculate the inverse then modular_multiply the two as you would any pair of (modular) integers - using the mod prodcut rule
– Bill Dubuque
2 days ago
Calculate the inverse then modular_multiply the two as you would any pair of (modular) integers - using the mod prodcut rule
– Bill Dubuque
2 days ago
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
User is a new contributor. Be nice, and check out our Code of Conduct.
User is a new contributor. Be nice, and check out our Code of Conduct.
User is a new contributor. Be nice, and check out our Code of Conduct.
User is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3005481%2fhow-to-calculate-mod-inverse%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Use the Extended Euclidean Algorithm, e.g. see here
– Bill Dubuque
2 days ago
I know how to find a mod inverse. But if I have a number A*B^-1 mod p-1 is that equivalent to A mod p-1 * B mod p-1 mod p-1. That is what I found online but I wasn't sure.
– User
2 days ago
$ab$ is invertible $iff a,b$ are invertible $iff a,b,$ are coprime to the modulus. When so we have $(ab)^{-1}equiv b^{-1}a^{-1},$ by $ b^{-1}a^{-1} (ab) equiv b^{-1}(a^{-1}a)bequiv b^{-1}b equiv 1 $ (inverses are always unique)
– Bill Dubuque
2 days ago
So what if I have a number * an inverse mod p -1. How would I break that down?
– User
2 days ago
Calculate the inverse then modular_multiply the two as you would any pair of (modular) integers - using the mod prodcut rule
– Bill Dubuque
2 days ago