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

You are not logged in.

- Topics: Active | Unanswered

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

im trying to get the value of mu as shown in the stuff below, but im getting a completely different value

from http://liris.cnrs.fr/~ohasan/pprs/paillierdemo/index.html?pt1=10&pt2=21 (dont bother going there. the values change everytime)

# Select two random and distinct primes p and q of length k/2

p = 33581 <-- given

q = 53299 <-- given# Compute n = p*q

n = 1789833719 <-- got this# Compute lambda = lcm(p-1,q-1) = (p-1)*(q-1) / gcd(p-1,q-1)

lambda = 894873420 <-- got this# Select a random integer g in Z*_{n^2}

g = 3082513844323755387 <-- given# Compute mu = (L(g^lambda mod n^2))^-1 mod n, where L(u) = (u-1)/n <-- im getting the inside stuff to be 1323971239912197708, L(u) = 739717453

mu = 1430230768

im getting mu to be 148619716. yet, the values produced work, while mine dont. what am i doing wrong?

Visit calccrypto.wikidot.com for detailed descriptions of algorithms and other crypto related stuff (not much yet, so help would be appreciated).

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

Hi cal;

His mu is correct.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

edit: okay. i fail. i reversed the values. sorry for wasting your time

*Last edited by calccrypto (2010-07-23 09:20:33)*

Visit calccrypto.wikidot.com for detailed descriptions of algorithms and other crypto related stuff (not much yet, so help would be appreciated).

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

No problem! Good to see ya!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

Thanks

Visit calccrypto.wikidot.com for detailed descriptions of algorithms and other crypto related stuff (not much yet, so help would be appreciated).

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

What are you working on?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

im trying to write the Paillier cryptosystem. it seems easy enough, but its not working for some reason or another

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

quick thing: what does it mean when a integer symbol has a little star next to it? i cant seem to remember and cant think of how to search for it

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

What's the integer symbol? You mean Z or N?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

the z, but this one also has a * next to it

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

I think it is a multiplicative group modulo n.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

Thanks! now... how do i chose random integers from the set? i cant list out all the possible values every time. the O(n) would be ridiculous

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

To produce random numbers from any set is not difficult. Either you have the rule or law that creates the set or if the set is finite. You create it and store it once as an array or whatever random access container your language supports.

P = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47} This is the the set P such that n is prime and n<50. To draw numbers from this set, you would choose a random number from 1 to 15 and access the array element using that number:

Begin loop:

k = random(1,15): 10 - >k

P[k] is P[10] which yields 29.

loop

Next iteration:

k = random(1,15): 3 - >k

P[k] is P[3] which yields 5.

etc.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

yes, but what if the upper limits are large?

do you know java?

http://liris.cnrs.fr/~ohasan/pprs/paillierdemo/Paillier.java

*Last edited by calccrypto (2010-07-24 05:45:19)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

If k is large than you will need the rule that creates the set.

S = { 1,3,5,7,9,11,13,17,19,...1000000000001} This set contains the odd numbers [1,1000000000001]

We certainly don't want to create an array that big. But there is a rule that generates those numbers it is 2n-1 for n = 1 to 500 000 000 001.

in pseudocode:

k = random(1,500 000 000 001): 512 - >k

P[k] is P[512] which yields 1023

Next iteration:

k = random(1,500 000 000 001): 1000000 - >k

P[k] is P[1000000] which yields 2(1000000) - 1 = 1999999

etc

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

interesting...

i think i found another way: im going to get a random number and add 1 until the value is coprime to k

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

How will you test for coprime?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

i have a small function i wrote in my personal math library.

```
def pair_coprime(numberlist):
for x in numberlist:
for y in xrange(len(numberlist)):
if x != numberlist[y]:
out = gcd(x,numberlist[y])
if out != 1:
return False #Some values are not coprime
return True #List is pairwise coprime
```

it could be faster, i think, but for now, its alright

i have another question:

can (a^b * c^d) mod e be done as [(a^b mod e) * (c^d mod e)] mod e? if not, whats an efficient way to do this on a computer? the exponentiation by squaring thing will still go through the second equation

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

Hi;

can (a^b * c^d) mod e be done as [(a^b mod e) * (c^d mod e)] mod e?

Yes.

To do it efficiently you use modular exponentiation. Described here:

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

cool! thanks

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

Your welcome!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

scratch that. i messed up again

*Last edited by calccrypto (2010-07-24 07:25:53)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

Did you get the point of modular exponentiation? It pops up a lot in computational number theory.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**calccrypto****Member**- Registered: 2010-03-06
- Posts: 96

yeah, but something is just not working

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 100,459

Nothing in computational math ever works, you have to force it.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline