RSA: Show how to factor $n=pq$, the product of two primes, given $(p-1)(q-1)$












2












$begingroup$


As an exercise in my discrete mathematics textbook, for my first-year course, the following question is asked, on the topic of RSA encryption:
Show that we can easily factor $n$ when we know that $n$ is the product of two primes, $p$ and $q$, and we know the value of $(p-1)(q-1)$.



So far my attempted solution has been to expand $(p-1)(q-1)$, to lay a foundation of the known value.
$$(p-1)(q-1)=pq-p-q+1$$
and rewrite
$$(p-1)(q-1)=pq-(p+q)+1$$
The book suggests calling $p+q=s$
and then attempting to use that to find the product $n$, since $q=s-p$, we can write the product as $n=p(s-p)$. Expanding this leads to the quadratic equation
$$0=p^2-ps+n$$
Using the quadratic formula to solve this leads to the following solution:
$$p=frac{spmsqrt{s^2-4n}}{2}$$
As shown by @misterriemann in the comments, the discriminant can not be negative, which leaves out any complex solutions, however i am unsure how to extract $q$ from this, after being given $p$ as a function of $s$.
Any help on this would be appreciated.










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n. $$
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:18












  • $begingroup$
    ^That's an answer.
    $endgroup$
    – Randall
    Dec 7 '18 at 18:19










  • $begingroup$
    Ah of course, thank you. I will revise my original question, and refer to this.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:22










  • $begingroup$
    "i have no idea how to extract q from this, after being given p as a function of s" .You already know that $q=s-p$
    $endgroup$
    – Federico
    Dec 7 '18 at 18:23
















2












$begingroup$


As an exercise in my discrete mathematics textbook, for my first-year course, the following question is asked, on the topic of RSA encryption:
Show that we can easily factor $n$ when we know that $n$ is the product of two primes, $p$ and $q$, and we know the value of $(p-1)(q-1)$.



So far my attempted solution has been to expand $(p-1)(q-1)$, to lay a foundation of the known value.
$$(p-1)(q-1)=pq-p-q+1$$
and rewrite
$$(p-1)(q-1)=pq-(p+q)+1$$
The book suggests calling $p+q=s$
and then attempting to use that to find the product $n$, since $q=s-p$, we can write the product as $n=p(s-p)$. Expanding this leads to the quadratic equation
$$0=p^2-ps+n$$
Using the quadratic formula to solve this leads to the following solution:
$$p=frac{spmsqrt{s^2-4n}}{2}$$
As shown by @misterriemann in the comments, the discriminant can not be negative, which leaves out any complex solutions, however i am unsure how to extract $q$ from this, after being given $p$ as a function of $s$.
Any help on this would be appreciated.










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n. $$
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:18












  • $begingroup$
    ^That's an answer.
    $endgroup$
    – Randall
    Dec 7 '18 at 18:19










  • $begingroup$
    Ah of course, thank you. I will revise my original question, and refer to this.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:22










  • $begingroup$
    "i have no idea how to extract q from this, after being given p as a function of s" .You already know that $q=s-p$
    $endgroup$
    – Federico
    Dec 7 '18 at 18:23














2












2








2





$begingroup$


As an exercise in my discrete mathematics textbook, for my first-year course, the following question is asked, on the topic of RSA encryption:
Show that we can easily factor $n$ when we know that $n$ is the product of two primes, $p$ and $q$, and we know the value of $(p-1)(q-1)$.



So far my attempted solution has been to expand $(p-1)(q-1)$, to lay a foundation of the known value.
$$(p-1)(q-1)=pq-p-q+1$$
and rewrite
$$(p-1)(q-1)=pq-(p+q)+1$$
The book suggests calling $p+q=s$
and then attempting to use that to find the product $n$, since $q=s-p$, we can write the product as $n=p(s-p)$. Expanding this leads to the quadratic equation
$$0=p^2-ps+n$$
Using the quadratic formula to solve this leads to the following solution:
$$p=frac{spmsqrt{s^2-4n}}{2}$$
As shown by @misterriemann in the comments, the discriminant can not be negative, which leaves out any complex solutions, however i am unsure how to extract $q$ from this, after being given $p$ as a function of $s$.
Any help on this would be appreciated.










share|cite|improve this question











$endgroup$




As an exercise in my discrete mathematics textbook, for my first-year course, the following question is asked, on the topic of RSA encryption:
Show that we can easily factor $n$ when we know that $n$ is the product of two primes, $p$ and $q$, and we know the value of $(p-1)(q-1)$.



So far my attempted solution has been to expand $(p-1)(q-1)$, to lay a foundation of the known value.
$$(p-1)(q-1)=pq-p-q+1$$
and rewrite
$$(p-1)(q-1)=pq-(p+q)+1$$
The book suggests calling $p+q=s$
and then attempting to use that to find the product $n$, since $q=s-p$, we can write the product as $n=p(s-p)$. Expanding this leads to the quadratic equation
$$0=p^2-ps+n$$
Using the quadratic formula to solve this leads to the following solution:
$$p=frac{spmsqrt{s^2-4n}}{2}$$
As shown by @misterriemann in the comments, the discriminant can not be negative, which leaves out any complex solutions, however i am unsure how to extract $q$ from this, after being given $p$ as a function of $s$.
Any help on this would be appreciated.







discrete-mathematics prime-numbers cryptography






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 10 '18 at 16:17









Ilmari Karonen

19.6k25183




19.6k25183










asked Dec 7 '18 at 18:14









ms_ms_

154




154








  • 1




    $begingroup$
    The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n. $$
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:18












  • $begingroup$
    ^That's an answer.
    $endgroup$
    – Randall
    Dec 7 '18 at 18:19










  • $begingroup$
    Ah of course, thank you. I will revise my original question, and refer to this.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:22










  • $begingroup$
    "i have no idea how to extract q from this, after being given p as a function of s" .You already know that $q=s-p$
    $endgroup$
    – Federico
    Dec 7 '18 at 18:23














  • 1




    $begingroup$
    The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n. $$
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:18












  • $begingroup$
    ^That's an answer.
    $endgroup$
    – Randall
    Dec 7 '18 at 18:19










  • $begingroup$
    Ah of course, thank you. I will revise my original question, and refer to this.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:22










  • $begingroup$
    "i have no idea how to extract q from this, after being given p as a function of s" .You already know that $q=s-p$
    $endgroup$
    – Federico
    Dec 7 '18 at 18:23








1




1




$begingroup$
The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n. $$
$endgroup$
– MisterRiemann
Dec 7 '18 at 18:18






$begingroup$
The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n. $$
$endgroup$
– MisterRiemann
Dec 7 '18 at 18:18














$begingroup$
^That's an answer.
$endgroup$
– Randall
Dec 7 '18 at 18:19




$begingroup$
^That's an answer.
$endgroup$
– Randall
Dec 7 '18 at 18:19












$begingroup$
Ah of course, thank you. I will revise my original question, and refer to this.
$endgroup$
– ms_
Dec 7 '18 at 18:22




$begingroup$
Ah of course, thank you. I will revise my original question, and refer to this.
$endgroup$
– ms_
Dec 7 '18 at 18:22












$begingroup$
"i have no idea how to extract q from this, after being given p as a function of s" .You already know that $q=s-p$
$endgroup$
– Federico
Dec 7 '18 at 18:23




$begingroup$
"i have no idea how to extract q from this, after being given p as a function of s" .You already know that $q=s-p$
$endgroup$
– Federico
Dec 7 '18 at 18:23










1 Answer
1






active

oldest

votes


















4












$begingroup$

The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n quad Rightarrow quad s^2-4n geq 0.$$



Furthermore, since you know the value of $(p-1)(q-1),$ (as well as $n=pq)$, you also know $s$, since
$$ s = p+q = pq-(p-1)(q-1)+1. $$



Then you can find $p$ from your formula, which immediately gives you $q$ as well, since
$$ p+q=s quad iff quad q=s-p, $$
or if you prefer to do division,
$$ n=pq quad iff quad q = frac{n}{p}. $$






share|cite|improve this answer









$endgroup$









  • 1




    $begingroup$
    Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:34






  • 1




    $begingroup$
    You're very welcome!
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:35











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3030203%2frsa-show-how-to-factor-n-pq-the-product-of-two-primes-given-p-1q-1%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4












$begingroup$

The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n quad Rightarrow quad s^2-4n geq 0.$$



Furthermore, since you know the value of $(p-1)(q-1),$ (as well as $n=pq)$, you also know $s$, since
$$ s = p+q = pq-(p-1)(q-1)+1. $$



Then you can find $p$ from your formula, which immediately gives you $q$ as well, since
$$ p+q=s quad iff quad q=s-p, $$
or if you prefer to do division,
$$ n=pq quad iff quad q = frac{n}{p}. $$






share|cite|improve this answer









$endgroup$









  • 1




    $begingroup$
    Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:34






  • 1




    $begingroup$
    You're very welcome!
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:35
















4












$begingroup$

The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n quad Rightarrow quad s^2-4n geq 0.$$



Furthermore, since you know the value of $(p-1)(q-1),$ (as well as $n=pq)$, you also know $s$, since
$$ s = p+q = pq-(p-1)(q-1)+1. $$



Then you can find $p$ from your formula, which immediately gives you $q$ as well, since
$$ p+q=s quad iff quad q=s-p, $$
or if you prefer to do division,
$$ n=pq quad iff quad q = frac{n}{p}. $$






share|cite|improve this answer









$endgroup$









  • 1




    $begingroup$
    Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:34






  • 1




    $begingroup$
    You're very welcome!
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:35














4












4








4





$begingroup$

The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n quad Rightarrow quad s^2-4n geq 0.$$



Furthermore, since you know the value of $(p-1)(q-1),$ (as well as $n=pq)$, you also know $s$, since
$$ s = p+q = pq-(p-1)(q-1)+1. $$



Then you can find $p$ from your formula, which immediately gives you $q$ as well, since
$$ p+q=s quad iff quad q=s-p, $$
or if you prefer to do division,
$$ n=pq quad iff quad q = frac{n}{p}. $$






share|cite|improve this answer









$endgroup$



The discriminant cannot be negative, since by AM-GM, $$ frac{p+q}{2} geq sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 geq 4pq = 4n quad Rightarrow quad s^2-4n geq 0.$$



Furthermore, since you know the value of $(p-1)(q-1),$ (as well as $n=pq)$, you also know $s$, since
$$ s = p+q = pq-(p-1)(q-1)+1. $$



Then you can find $p$ from your formula, which immediately gives you $q$ as well, since
$$ p+q=s quad iff quad q=s-p, $$
or if you prefer to do division,
$$ n=pq quad iff quad q = frac{n}{p}. $$







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Dec 7 '18 at 18:24









MisterRiemannMisterRiemann

5,8451624




5,8451624








  • 1




    $begingroup$
    Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:34






  • 1




    $begingroup$
    You're very welcome!
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:35














  • 1




    $begingroup$
    Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
    $endgroup$
    – ms_
    Dec 7 '18 at 18:34






  • 1




    $begingroup$
    You're very welcome!
    $endgroup$
    – MisterRiemann
    Dec 7 '18 at 18:35








1




1




$begingroup$
Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
$endgroup$
– ms_
Dec 7 '18 at 18:34




$begingroup$
Your third equation made me realize that i totally missed a solution for s, given in terms of "known" values. Thank you for this answer.
$endgroup$
– ms_
Dec 7 '18 at 18:34




1




1




$begingroup$
You're very welcome!
$endgroup$
– MisterRiemann
Dec 7 '18 at 18:35




$begingroup$
You're very welcome!
$endgroup$
– MisterRiemann
Dec 7 '18 at 18:35


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3030203%2frsa-show-how-to-factor-n-pq-the-product-of-two-primes-given-p-1q-1%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen