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

You are not logged in.

## #1 2013-09-22 12:30:45

Agnishom
Real Member

Offline

### 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'
'The whole person changes, why can't a habit?' -Alokananda

## #2 2013-09-22 18:48:32

bobbym
Administrator

Offline

### Re: Large Prime

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

To answer your question, there is no extremely quick way.

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #3 2013-09-22 19:14:34

Agnishom
Real Member

Offline

### Re: Large Prime

Where am I going?

#### Code:

```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-22 19: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'
'The whole person changes, why can't a habit?' -Alokananda

## #4 2013-09-22 19:27:06

bobbym
Administrator

Offline

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

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

Agnishom
Real Member

Offline

### 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'
'The whole person changes, why can't a habit?' -Alokananda

## #6 2013-09-23 01:49:36

bobbym
Administrator

Offline

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #7 2013-09-23 02:04:58

anonimnystefy
Real Member

Offline

### Re: Large Prime

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #8 2013-09-23 02:13:47

bobbym
Administrator

Offline

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #9 2013-09-23 11:43:16

Agnishom
Real Member

Offline

### 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'
'The whole person changes, why can't a habit?' -Alokananda

## #10 2013-09-23 12:48:10

Agnishom
Real Member

Offline

### Re: Large Prime

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

#### Code:

`179769313486231590770839156793787453197860296048756011706444423684197180216158519368947833795864925541502180565485980503646440548199239100050792877003355816639229553136239076508735759914822574862575007425302077447712589550957937778424442426617334727629299387668709205606050270810842907692932019128194467627007`

The generator g is

#### Code:

`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'
'The whole person changes, why can't a habit?' -Alokananda

## #11 2013-09-23 12:52:04

anonimnystefy
Real Member

Offline

### Re: Large Prime

Hi Agnishom

My number:

#### Code:

`170889576082067697731054176601909874828559452754928289693960008087616417613737398548717155229171096112124599345710842437121675819339812482513978573388985033018038377053945453188374711735023121936105534290646082341664680937820085667262891263915428892361981765346083422852575547729295502827704976423861860303103`

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #12 2013-09-23 14:25:55

Agnishom
Real Member

Offline

### Re: Large Prime

Hi anonymnesty,

gb (mod p)

#### Code:

`173419298906489863864646388281941306843742681293608592957943679413527102401811311961611828206757391788738800024670641247258673805804085888390828078173388181181530749311360724611386280929348614725682444473741887149211776384725911058474047582365359321545094524307293842804350322782081718297375589621859722244791`

Last edited by Agnishom (2013-09-23 14: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'
'The whole person changes, why can't a habit?' -Alokananda

## #13 2013-09-23 15:36:04

anonimnystefy
Real Member

Offline

### Re: Large Prime

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

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

Agnishom
Real Member

Offline

### Re: Large Prime

Hi Stefy,

Sorry for the typo. Is what you posted in #11 ga (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'
'The whole person changes, why can't a habit?' -Alokananda

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

auyeungyat
Member

Offline

### Re: Large Prime

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

## #16 2013-09-24 00:43:32

Agnishom
Real Member

Offline

### 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-24 01: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'
'The whole person changes, why can't a habit?' -Alokananda

## #17 2013-09-24 04:33:03

anonimnystefy
Real Member

Offline

### Re: Large Prime

#### Agnishom wrote:

Hi Stefy,

Sorry for the typo. Is what you posted in #11 ga (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?

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #18 2013-09-24 06:22:28

bobbym
Administrator

Offline

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #19 2013-09-24 06:23:01

anonimnystefy
Real Member

Offline

### Re: Large Prime

Hi bobbym

You can post them, if you want.

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #20 2013-09-24 06:29:01

bobbym
Administrator

Offline

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #21 2013-09-24 06:39:11

anonimnystefy
Real Member

Offline

### Re: Large Prime

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #22 2013-09-24 06:44:43

bobbym
Administrator

Offline

### Re: Large Prime

Neither am I. How about we try to follow their example?

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

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

anonimnystefy
Real Member

Offline

### Re: Large Prime

Their?

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

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

bobbym
Administrator

Offline

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #25 2013-09-24 10:38:11

anonimnystefy
Real Member

Offline

### Re: Large Prime

Could you post the link to the video?

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## Board footer

Powered by FluxBB