Author Topic: Diffie Hellman with color  (Read 2598 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Diffie Hellman with color
« on: May 02, 2021, 01:24:14 am »
from https://ldapwiki.com/wiki/Diffie-Hellman%20key-exchange
Bob and Alice choose yellow.

Alice mixes yellow with magenta (magenta is Alice's secret color)
255, 255, 0 +  255, 0, 255  =  255, 128, 128
and sends this to Bob

Bob mixes yellow with cyan (cyan is Bob's secret color)
255, 255, 0 +  0, 255, 255 = 128, 255, 128
and sends this to Alice

Alice mixes 128, 255, 128 with magenta
128, 255, 128  +  255, 0, 255 + 255 =  (255+128)/2, 128,  (255 +128)/2

Bob mixes 255, 128, 128 with cyan
255, 128, 128  +  0, 255, 255 =  128, (255+128)/2, (255 +128)/2

Which does not work.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Diffie Hellman with color
« Reply #1 on: May 02, 2021, 10:33:42 am »
Take 3 tubes of pain: yellow, cyan, magenta.

Mix yellow, cyan, and magenta in equal parts...   You get dark gray.

Mix yellow, magenta, cyan in equal parts...  You get dark gray.

The color visualization is there as an example to help you conceptualize the process.  As the article goes on to explain (if you read it and don't just look at the pictures...)

Quote
Essentially, each party agrees:

on a public value g and a large prime number p .
one party chooses a secret value x
the other party chooses a secret value y
Both parties use their secret values to derive public values, g x mod p and g y mod p,
they exchange the public values.
Each uses the other party's public value to calculate the shared secret key that is used by both parties for confidential communications.
A third party cannot, in theory, derive the shared secret key because they do not know either of the secret values, x or y .
For Example:

Alice chooses secret value x and sends the public value g x mod p to Bob.
Bob chooses secret value y and sends the public value g y mod p to Alice.
Alice uses the value g xy mod p as her secret key for confidential communications with Bob.
Bob uses the value g yx mod p as his secret key.

Which is quite a bit different than the math you're attempting to do.

The color example is basically saying:  X + Y + Z = X + Z + Y  (yellow + cyan + magenta = yellow + magenta + cyan)


https://trycolors.com -- Try it yourself.
« Last Edit: May 02, 2021, 10:43:55 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Diffie Hellman with color
« Reply #2 on: May 02, 2021, 11:16:33 am »
Just try a run with real numbers:
Code: QB64: [Select]
  1. DefLng A-Z
  2. Public = 37
  3. G = 100
  4. Alice = 32
  5. Bob = 16
  6.  
  7. 'Alice sends Bob
  8. ToBob = Alice * G Mod Public
  9. 'Bob sends Alice
  10. ToAlice = Bob * G Mod Public
  11.  
  12. ' Bob and Alice applies their numbers to what the other sent
  13. BobAlice = Bob * ToBob Mod Public
  14. AliceBob = Alice * ToAlice Mod Public
  15. Print "Bob, Alice keys: "; BobAlice, AliceBob
  16.  
  17.  

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Diffie Hellman with color
« Reply #3 on: May 02, 2021, 06:43:34 pm »
I will recheck my math.   What if the color set were increased to say 100 colors?  Human can only see 3 but a computer does not care. 

What if Alice and Bob were to have more than one secret color?  Eve would see the sums but she would not know the composition.  Well that is the theory.
« Last Edit: May 02, 2021, 06:48:15 pm by NOVARSEG »