[Request] Diffie-Hellman Key Object
Scenario: You want to send some encrypted message from one MMF2 application to another over a network. You could for instance use the AESFusion object to encrypt a string (using a key), and then send the encrypted string over the network with Lacewing.
Problem: How do you set up the key in the receiving program so that you can decrypt the message? You can't just send the key over the network, that would kind of ruin the point of using encryption in the first place. You could hard code a key in both programs, but that's not really a good idea either.
A solution: Before encrypting and sending the message, create a key using the Diffie-Hellman key exchange algorithm. The algorithm takes some random numbers as inputs, two are "public" and can be safely sent across the network while another is "private" and is generated independently by both sending and receiving programs. With these inputs you can magically (mathematically) generate the same key in two different places without sending any values that can be intercepted and used by a third party.
See http://en.wikipedia.org/wiki/Diffie-Hellman_key_exchange for more information and an example.
I have been able to replicate the example from Wikipedia with just events in MMF2, but I haven't been able to make it work with large enough input numbers for the resulting key to be secure.
The request: A simple object that compute the values from inputs with the Diffie-Hellman algorithm, returning strings. It should need only two actions:
1) Generate "stage 1" string from inputs
2) Generate key (as string) from "stage 1" string
Re: [Request] Diffie-Hellman Key Object
You can do this without needing an extension. What prevents you from generating the codes directly? All you need is correct exponentiation.
Re: [Request] Diffie-Hellman Key Object
I would guess that for decent security it requires numbers larger than MMF can naturally represent, eg. 128 bits.
Even without that, MMF's pow function is floating point, which would cause too many errors for the key exchange to be 100% reliable.
Re: [Request] Diffie-Hellman Key Object
I did make it work using small values like in the example on Wikipedia. When using larger prime numbers or larger values for the random integers the two keys rarely came out the same. I figured it had to be because of lack of precision, but I'm not exactly an expert. If anyone else has succeeded, I would love an example file!
Re: [Request] Diffie-Hellman Key Object
Fast exponentiation isn't possible in MMF, you'd need to use an extension. If I wasn't so busy I'd put into an extension the code I used for my cryptography unit at Uni. And someone less lazy would wrap a proper, well-tested encryption library into an extension :)
Re: [Request] Diffie-Hellman Key Object
So if it has been established that MMF2 cannot pull this off internally, I guess the request still stands. We have some working encryption objects, but we need a key exchange mechanism.
Re: [Request] Diffie-Hellman Key Object
Have you tried with the Int64 object? It's not 128 bit like said above, but it could do for some simple stuff.
Re: [Request] Diffie-Hellman Key Object
Can it do exponentiation?
Re: [Request] Diffie-Hellman Key Object
Re: [Request] Diffie-Hellman Key Object
I have now made an attempt using the Int64 object, but I seem to be running into the same problems as before. It works with really small integers (<20), but with anything larger the keys come out differently. I'm not sure how large the numbers need to be for the exchange to be reasonably secure, but I'm sure 1-20 isn't enough. :)
Have anyone else tried with the Int64 object?