How to verify if g is a generator for p?How large should a Diffie-Hellman p be?Why is it impractical to generate a semiprime dictionary?Help with example RSA problemObtaining Diffie-Hellman generator“Prime conspiracy”'s effect on cryptographyHow is it possible that $g^q equiv 1 pmod p$ for a generator g?What algorithm does .NET use to generate primes for RSA and how can I verify it?How to find a generator g for a large prime p?RSA finding p and q integer with conditionEl-Gamal like encryption, how can i guess the key?

Modulo 2 binary long division in European notation

What would happen if the UK refused to take part in EU Parliamentary elections?

Greatest common substring

Can I convert a rim brake wheel to a disc brake wheel?

Efficiently merge handle parallel feature branches in SFDX

Failed to fetch jessie backports repository

Is there any reason not to eat food that's been dropped on the surface of the moon?

How to verify if g is a generator for p?

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

Using parameter substitution on a Bash array

Opposite of a diet

Go Pregnant or Go Home

Implement the Thanos sorting algorithm

How does a character multiclassing into warlock get a focus?

Is there a problem with hiding "forgot password" until it's needed?

How could Frankenstein get the parts for his _second_ creature?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

What is the oldest known work of fiction?

Best way to store options for panels

Your magic is very sketchy

Is there an Impartial Brexit Deal comparison site?

Why did Kant, Hegel, and Adorno leave some words and phrases in the Greek alphabet?

Can I use my Chinese passport to enter China after I acquired another citizenship?



How to verify if g is a generator for p?


How large should a Diffie-Hellman p be?Why is it impractical to generate a semiprime dictionary?Help with example RSA problemObtaining Diffie-Hellman generator“Prime conspiracy”'s effect on cryptographyHow is it possible that $g^q equiv 1 pmod p$ for a generator g?What algorithm does .NET use to generate primes for RSA and how can I verify it?How to find a generator g for a large prime p?RSA finding p and q integer with conditionEl-Gamal like encryption, how can i guess the key?













2












$begingroup$


For learning purpose, supposed I have a 16-digit prime which is 2685735182215187, how do I verify if g is a generator? (p is supposedly a special kind of prime)










share|improve this question









$endgroup$











  • $begingroup$
    The special kind of prime that you have is called a safe prime. it's a prime of the form $p = 2q + 1$ where $q$ is also prime (as shown by poncho's answer).
    $endgroup$
    – puzzlepalace
    1 hour ago










  • $begingroup$
    @puzzlepalace sorry, I'm still confused about q. Where do I actually get the q?
    $endgroup$
    – Ken
    26 mins ago










  • $begingroup$
    You can derive $q$ from $p$. In other words, to check if $p$ is a safe prime, you check if $q = fracp-12$ is also prime.
    $endgroup$
    – puzzlepalace
    15 mins ago










  • $begingroup$
    @puzzlepalace Thank you for your swift reply. I have computed and checked q=(p-1)/2 and my program returns true (it is indeed a prime). So I'm safe to say that q is also a prime, which means that p is a special kind of prime.
    $endgroup$
    – Ken
    6 mins ago










  • $begingroup$
    @puzzlepalace However, I'm still confused about g. I have computed g^(p-1)/2 mod p and g^p-1/(p-1/2) like what poncho has mentioned. The first output is 1342867591052455, and the second output is 0. I'm a little confused about these numbers, do they mean that g is a generator?
    $endgroup$
    – Ken
    4 mins ago















2












$begingroup$


For learning purpose, supposed I have a 16-digit prime which is 2685735182215187, how do I verify if g is a generator? (p is supposedly a special kind of prime)










share|improve this question









$endgroup$











  • $begingroup$
    The special kind of prime that you have is called a safe prime. it's a prime of the form $p = 2q + 1$ where $q$ is also prime (as shown by poncho's answer).
    $endgroup$
    – puzzlepalace
    1 hour ago










  • $begingroup$
    @puzzlepalace sorry, I'm still confused about q. Where do I actually get the q?
    $endgroup$
    – Ken
    26 mins ago










  • $begingroup$
    You can derive $q$ from $p$. In other words, to check if $p$ is a safe prime, you check if $q = fracp-12$ is also prime.
    $endgroup$
    – puzzlepalace
    15 mins ago










  • $begingroup$
    @puzzlepalace Thank you for your swift reply. I have computed and checked q=(p-1)/2 and my program returns true (it is indeed a prime). So I'm safe to say that q is also a prime, which means that p is a special kind of prime.
    $endgroup$
    – Ken
    6 mins ago










  • $begingroup$
    @puzzlepalace However, I'm still confused about g. I have computed g^(p-1)/2 mod p and g^p-1/(p-1/2) like what poncho has mentioned. The first output is 1342867591052455, and the second output is 0. I'm a little confused about these numbers, do they mean that g is a generator?
    $endgroup$
    – Ken
    4 mins ago













2












2








2





$begingroup$


For learning purpose, supposed I have a 16-digit prime which is 2685735182215187, how do I verify if g is a generator? (p is supposedly a special kind of prime)










share|improve this question









$endgroup$




For learning purpose, supposed I have a 16-digit prime which is 2685735182215187, how do I verify if g is a generator? (p is supposedly a special kind of prime)







rsa prime-numbers elgamal-encryption






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 hours ago









KenKen

261




261











  • $begingroup$
    The special kind of prime that you have is called a safe prime. it's a prime of the form $p = 2q + 1$ where $q$ is also prime (as shown by poncho's answer).
    $endgroup$
    – puzzlepalace
    1 hour ago










  • $begingroup$
    @puzzlepalace sorry, I'm still confused about q. Where do I actually get the q?
    $endgroup$
    – Ken
    26 mins ago










  • $begingroup$
    You can derive $q$ from $p$. In other words, to check if $p$ is a safe prime, you check if $q = fracp-12$ is also prime.
    $endgroup$
    – puzzlepalace
    15 mins ago










  • $begingroup$
    @puzzlepalace Thank you for your swift reply. I have computed and checked q=(p-1)/2 and my program returns true (it is indeed a prime). So I'm safe to say that q is also a prime, which means that p is a special kind of prime.
    $endgroup$
    – Ken
    6 mins ago










  • $begingroup$
    @puzzlepalace However, I'm still confused about g. I have computed g^(p-1)/2 mod p and g^p-1/(p-1/2) like what poncho has mentioned. The first output is 1342867591052455, and the second output is 0. I'm a little confused about these numbers, do they mean that g is a generator?
    $endgroup$
    – Ken
    4 mins ago
















  • $begingroup$
    The special kind of prime that you have is called a safe prime. it's a prime of the form $p = 2q + 1$ where $q$ is also prime (as shown by poncho's answer).
    $endgroup$
    – puzzlepalace
    1 hour ago










  • $begingroup$
    @puzzlepalace sorry, I'm still confused about q. Where do I actually get the q?
    $endgroup$
    – Ken
    26 mins ago










  • $begingroup$
    You can derive $q$ from $p$. In other words, to check if $p$ is a safe prime, you check if $q = fracp-12$ is also prime.
    $endgroup$
    – puzzlepalace
    15 mins ago










  • $begingroup$
    @puzzlepalace Thank you for your swift reply. I have computed and checked q=(p-1)/2 and my program returns true (it is indeed a prime). So I'm safe to say that q is also a prime, which means that p is a special kind of prime.
    $endgroup$
    – Ken
    6 mins ago










  • $begingroup$
    @puzzlepalace However, I'm still confused about g. I have computed g^(p-1)/2 mod p and g^p-1/(p-1/2) like what poncho has mentioned. The first output is 1342867591052455, and the second output is 0. I'm a little confused about these numbers, do they mean that g is a generator?
    $endgroup$
    – Ken
    4 mins ago















$begingroup$
The special kind of prime that you have is called a safe prime. it's a prime of the form $p = 2q + 1$ where $q$ is also prime (as shown by poncho's answer).
$endgroup$
– puzzlepalace
1 hour ago




$begingroup$
The special kind of prime that you have is called a safe prime. it's a prime of the form $p = 2q + 1$ where $q$ is also prime (as shown by poncho's answer).
$endgroup$
– puzzlepalace
1 hour ago












$begingroup$
@puzzlepalace sorry, I'm still confused about q. Where do I actually get the q?
$endgroup$
– Ken
26 mins ago




$begingroup$
@puzzlepalace sorry, I'm still confused about q. Where do I actually get the q?
$endgroup$
– Ken
26 mins ago












$begingroup$
You can derive $q$ from $p$. In other words, to check if $p$ is a safe prime, you check if $q = fracp-12$ is also prime.
$endgroup$
– puzzlepalace
15 mins ago




$begingroup$
You can derive $q$ from $p$. In other words, to check if $p$ is a safe prime, you check if $q = fracp-12$ is also prime.
$endgroup$
– puzzlepalace
15 mins ago












$begingroup$
@puzzlepalace Thank you for your swift reply. I have computed and checked q=(p-1)/2 and my program returns true (it is indeed a prime). So I'm safe to say that q is also a prime, which means that p is a special kind of prime.
$endgroup$
– Ken
6 mins ago




$begingroup$
@puzzlepalace Thank you for your swift reply. I have computed and checked q=(p-1)/2 and my program returns true (it is indeed a prime). So I'm safe to say that q is also a prime, which means that p is a special kind of prime.
$endgroup$
– Ken
6 mins ago












$begingroup$
@puzzlepalace However, I'm still confused about g. I have computed g^(p-1)/2 mod p and g^p-1/(p-1/2) like what poncho has mentioned. The first output is 1342867591052455, and the second output is 0. I'm a little confused about these numbers, do they mean that g is a generator?
$endgroup$
– Ken
4 mins ago




$begingroup$
@puzzlepalace However, I'm still confused about g. I have computed g^(p-1)/2 mod p and g^p-1/(p-1/2) like what poncho has mentioned. The first output is 1342867591052455, and the second output is 0. I'm a little confused about these numbers, do they mean that g is a generator?
$endgroup$
– Ken
4 mins ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

Steps:



  • Factor $p-1$, that is, find the primes which, multiplied together, produce $p-1$. In your case, $2685735182215186 = 2 times 1342867591107593$


  • For each prime factor $q$ of $p-1$, verify that $g^(p-1)/q notequiv 1pmod p$


If every such $q$ verifies (that is, they were all not 1), then $g$ is a generator.






share|improve this answer









$endgroup$












  • $begingroup$
    Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
    $endgroup$
    – Ken
    1 hour ago










  • $begingroup$
    @Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
    $endgroup$
    – poncho
    1 hour ago











  • $begingroup$
    public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
    $endgroup$
    – Ken
    1 hour ago











  • $begingroup$
    Thank you so much @poncho
    $endgroup$
    – Ken
    1 hour ago










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: "281"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fcrypto.stackexchange.com%2fquestions%2f68317%2fhow-to-verify-if-g-is-a-generator-for-p%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









3












$begingroup$

Steps:



  • Factor $p-1$, that is, find the primes which, multiplied together, produce $p-1$. In your case, $2685735182215186 = 2 times 1342867591107593$


  • For each prime factor $q$ of $p-1$, verify that $g^(p-1)/q notequiv 1pmod p$


If every such $q$ verifies (that is, they were all not 1), then $g$ is a generator.






share|improve this answer









$endgroup$












  • $begingroup$
    Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
    $endgroup$
    – Ken
    1 hour ago










  • $begingroup$
    @Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
    $endgroup$
    – poncho
    1 hour ago











  • $begingroup$
    public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
    $endgroup$
    – Ken
    1 hour ago











  • $begingroup$
    Thank you so much @poncho
    $endgroup$
    – Ken
    1 hour ago















3












$begingroup$

Steps:



  • Factor $p-1$, that is, find the primes which, multiplied together, produce $p-1$. In your case, $2685735182215186 = 2 times 1342867591107593$


  • For each prime factor $q$ of $p-1$, verify that $g^(p-1)/q notequiv 1pmod p$


If every such $q$ verifies (that is, they were all not 1), then $g$ is a generator.






share|improve this answer









$endgroup$












  • $begingroup$
    Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
    $endgroup$
    – Ken
    1 hour ago










  • $begingroup$
    @Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
    $endgroup$
    – poncho
    1 hour ago











  • $begingroup$
    public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
    $endgroup$
    – Ken
    1 hour ago











  • $begingroup$
    Thank you so much @poncho
    $endgroup$
    – Ken
    1 hour ago













3












3








3





$begingroup$

Steps:



  • Factor $p-1$, that is, find the primes which, multiplied together, produce $p-1$. In your case, $2685735182215186 = 2 times 1342867591107593$


  • For each prime factor $q$ of $p-1$, verify that $g^(p-1)/q notequiv 1pmod p$


If every such $q$ verifies (that is, they were all not 1), then $g$ is a generator.






share|improve this answer









$endgroup$



Steps:



  • Factor $p-1$, that is, find the primes which, multiplied together, produce $p-1$. In your case, $2685735182215186 = 2 times 1342867591107593$


  • For each prime factor $q$ of $p-1$, verify that $g^(p-1)/q notequiv 1pmod p$


If every such $q$ verifies (that is, they were all not 1), then $g$ is a generator.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 hours ago









ponchoponcho

93.4k2146242




93.4k2146242











  • $begingroup$
    Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
    $endgroup$
    – Ken
    1 hour ago










  • $begingroup$
    @Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
    $endgroup$
    – poncho
    1 hour ago











  • $begingroup$
    public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
    $endgroup$
    – Ken
    1 hour ago











  • $begingroup$
    Thank you so much @poncho
    $endgroup$
    – Ken
    1 hour ago
















  • $begingroup$
    Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
    $endgroup$
    – Ken
    1 hour ago










  • $begingroup$
    @Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
    $endgroup$
    – poncho
    1 hour ago











  • $begingroup$
    public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
    $endgroup$
    – Ken
    1 hour ago











  • $begingroup$
    Thank you so much @poncho
    $endgroup$
    – Ken
    1 hour ago















$begingroup$
Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
$endgroup$
– Ken
1 hour ago




$begingroup$
Hey @poncho thanks. I do not understand "For each prime factor q of p−1, verify that g(p−1)/q≢1(mod p)" Is there anyway you can explain it simpler?
$endgroup$
– Ken
1 hour ago












$begingroup$
@Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
$endgroup$
– poncho
1 hour ago





$begingroup$
@Ken: Compute $g^2685735182215186/2 bmod p$. Compute $g^2685735182215186/1342867591107593 bmod p$. If they are both something other than 1, then $g$ is a generator
$endgroup$
– poncho
1 hour ago













$begingroup$
public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
$endgroup$
– Ken
1 hour ago





$begingroup$
public class generator public static void main (String[] args) long p = 2685735182104907l; long p2 = p - 1; long p3 = p2 / 2; long p4 = 2 ^ (p2 / 2) % p; long p5 = 2 ^ (p2 / p3) % p; System.out.println(p4); System.out.println(p5); Is it like this in? In Java.
$endgroup$
– Ken
1 hour ago













$begingroup$
Thank you so much @poncho
$endgroup$
– Ken
1 hour ago




$begingroup$
Thank you so much @poncho
$endgroup$
– Ken
1 hour ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Cryptography 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%2fcrypto.stackexchange.com%2fquestions%2f68317%2fhow-to-verify-if-g-is-a-generator-for-p%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

Era Viking Índice Início da Era Viquingue | Cotidiano | Sociedade | Língua | Religião | A arte | As primeiras cidades | As viagens dos viquingues | Viquingues do Oeste e Leste | Fim da Era Viquingue | Fontes históricas | Referências Bibliografia | Ligações externas | Menu de navegação«Sverige då!»«Handel I vikingetid»«O que é Nórdico Antigo»Mito, magia e religião na volsunga saga Um olhar sobre a trajetória mítica do herói sigurd«Bonden var den verklige vikingen»«Vikingatiden»«Vikingatiden»«Vinland»«Guerreiras de Óðinn: As Valkyrjor na Mitologia Viking»1519-9053«Esculpindo símbolos e seres: A arte viking em pedras rúnicas»1679-9313Historia - Tema: VikingarnaAventura e Magia no Mundo das Sagas IslandesasEra Vikinge

What's the metal clinking sound at the end of credits in Avengers: Endgame?What makes Thanos so strong in Avengers: Endgame?Who is the character that appears at the end of Endgame?What happens to Mjolnir (Thor's hammer) at the end of Endgame?The People's Ages in Avengers: EndgameWhat did Nebula do in Avengers: Endgame?Messing with time in the Avengers: Endgame climaxAvengers: Endgame timelineWhat are the time-travel rules in Avengers Endgame?Why use this song in Avengers: Endgame Opening Logo Sequence?Peggy's age in Avengers Endgame

Are there legal definitions of ethnicities/races? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Legal definitions in the United StatesAre there truly legal limits on US interest rates?Are gender identity and sexual orientation federally protected?Why is there an apparent legal bias against digital services?What limits are there to the powers of individual judges in the United States legal system?Are women only scholarships legal under Irish / EU law?Is the term “race” defined by Public Law enacted by Congress of the United StatesIs there a legal definition of race in the US?Neighbors are spying for landlord on Renters is it legal?Are Protected Classes Bi-directional?