Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫  π  -¹ ² ³ °

You are not logged in.

## #1 2013-09-21 14:30:45

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Large Prime

Is there a effective quick way to generate a large prime of a given length?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #2 2013-09-21 20:48:32

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

I know where you are going with this and it is not necessary.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #3 2013-09-21 21:14:34

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

Where am I going?

``````while True:
randomnumber = random.randrange(2**(length-1),(2**(length))-1)
if primep(randomnumber):
print randomnumber
break``````

Thats all I got from stackoverflow

Last edited by Agnishom (2013-09-21 21:16:47)

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #4 2013-09-21 21:27:06

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

You think you need a large prime to learn Diffie- Hellman. I can denmonstrate the procedure using a small one.

Thats all I got from stackoverflow

Hohohohohohohahahaha, they are always good for a laugh. To think that such brilliant people can still have a wonderful sense of humor gives me much hope for the human race.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #5 2013-09-22 00:53:29

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

bobbym wrote:

You think you need a large prime to learn Diffie- Hellman. I can denmonstrate the procedure using a small one.

I can too. But that is not secure enough.

Sorry, I did not get the humor

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #6 2013-09-22 03:49:36

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

I agree. But I thought you wanted to see how it worked?

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #7 2013-09-22 04:04:58

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

I think the only problem is - after Alice and Bob have the shared secret, how do they exchange messages using it?

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #8 2013-09-22 04:13:47

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

I have been waiting to answer that one since yesterday. But it seems I have missed Agnishom today.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #9 2013-09-22 13:43:16

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

anonimnystefy wrote:

I think the only problem is - after Alice and Bob have the shared secret, how do they exchange messages using it?

They use a symmetric cypher, like RC4 with the key.

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #10 2013-09-22 14:48:10

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

Let us take the generally accepted p from http://tools.ietf.org/html/rfc2409#section-6.2

``179769313486231590770839156793787453197860296048756011706444423684197180216158519368947833795864925541502180565485980503646440548199239100050792877003355816639229553136239076508735759914822574862575007425302077447712589550957937778424442426617334727629299387668709205606050270810842907692932019128194467627007``

The generator g is

``2``

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #11 2013-09-22 14:52:04

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Hi Agnishom

My number:

``170889576082067697731054176601909874828559452754928289693960008087616417613737398548717155229171096112124599345710842437121675819339812482513978573388985033018038377053945453188374711735023121936105534290646082341664680937820085667262891263915428892361981765346083422852575547729295502827704976423861860303103``

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #12 2013-09-22 16:25:55

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

Hi anonymnesty,

g[sup]b[/sup] (mod p)

``173419298906489863864646388281941306843742681293608592957943679413527102401811311961611828206757391788738800024670641247258673805804085888390828078173388181181530749311360724611386280929348614725682444473741887149211776384725911058474047582365359321545094524307293842804350322782081718297375589621859722244791``

Last edited by Agnishom (2013-09-22 16:34:05)

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #13 2013-09-22 17:36:04

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Hm, just call me Stefy. It's easier for everybody that way.

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #14 2013-09-23 00:55:52

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

Hi Stefy,

Sorry for the typo. Is what you posted in #11 g[sup]a[/sup] (mod p) ?

How should I use the secret key to message you now? What about RC4?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #15 2013-09-23 01:47:39

auyeungyat
Member
Registered: 2013-09-23
Posts: 22

### Re: Large Prime

I have tested on my computer(Mac on Terminal).That doesn't generate any numbers!

Offline

## #16 2013-09-23 02:43:32

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,808
Website

### Re: Large Prime

auyeungyat wrote:

I have tested on my computer(Mac on Terminal).That doesn't generate any numbers!

I am sorry, primep is defined externally. Do you want the full working code?

Last edited by Agnishom (2013-09-23 03:02:37)

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

## #17 2013-09-23 06:33:03

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Agnishom wrote:

Hi Stefy,

Sorry for the typo. Is what you posted in #11 g[sup]a[/sup] (mod p) ?

How should I use the secret key to message you now? What about RC4?

It is.

Is there something more simple we could try first?

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #18 2013-09-23 08:22:28

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

I have a nice tut on this if you need to see how it is done.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #19 2013-09-23 08:23:01

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Hi bobbym

You can post them, if you want.

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #20 2013-09-23 08:29:01

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

It uses baby sized numbers but maybe that is best for an example.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #21 2013-09-23 08:39:11

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Sure. Any example would suffice, seeing how I am not sure at all how to use the shared secret.

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #22 2013-09-23 08:44:43

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #23 2013-09-23 09:35:07

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Their?

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

## #24 2013-09-23 09:53:22

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Large Prime

The video I have. They use an example. They go through the technique step by step. Should be easy to do with a real problem later on.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #25 2013-09-23 12:38:11

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,037

### Re: Large Prime

Could you post the link to the video?

Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline