Showing posts with label Groups. Show all posts
Showing posts with label Groups. Show all posts

Friday, June 21, 2013

What kind of magmas (magmae?) are cryptographic systems?

Suppose you've got a cryptographic system in which keys, plain texts and encrypted messages all exist in the same set (e.g. the set of arrays of bits).

In a situation like that, you could say that the encryption operation E, which takes a plain text block p and a key block k, forms a magma together with the set of messages and keys.  What kind of magma is it?

First, there is ideally not going to be a left-identity element I such that E(I, k) = k, because under certain circumstances you could trick an automated system into revealing the key by feeding it the identity element.  You probably don't want a right-identity element either, because you wouldn't want to accidentally use it for the key and leave your plain text unencrypted.

Ideally, you would want inverse elements to exist, because you would want the encrypted message to be dependent on every bit of the plain text and every bit of the key, and you would want the encryption function to be invertible.  However, if the message space is infinite (i.e. we're talking about all possible messages and keys of all possible lengths) then there is no guarantee that inverse elements would exist.

If I have that right, then this type of magma is a quasigroup if the inverse elements exist.

Wednesday, June 19, 2013

Magma

Magma is a big deal in functional programming.

I know this, because I have attended two study groups on functional programming, and each time someone has pulled up the Wikipedia page on Magma.

The day after the last such meeting, I spent the morning wondering whether I had made a huge mistake trying to learn a programming paradigm that required a Ph.D. in an obscure branch of mathematics in order to get started.  But then it dawned on me (I think) what it's all about:
Groups are the higher order types that higher order functions operate on.
So, a magma is a set of things (M), together with a function (.) that takes two of those things as a parameter and returns a third one.  We could start with the basic magma and build up to groups, but I would rather go backwards from abelian groups.

Abelian Groups

  • The function is commutative,  so a.b = b.a
  • There is an identity element, so a.I = a
  • The set contains inverse elements, so for any a, there is a b such that a.b = I
  • The function is associative, so a.(b.c) = (a.b).c
An example of an abelian group would be the set of integers and the addition operation.  So,

  • The function is commutative,  so a + b = b + a
  • There is an identity element 0, so a + 0 = a
  • The set contains inverse elements, so for any a, there is a b (in this case, -a) such that a + b = 0
  • The function is associative, so a + (b + c) = (a + b) + c
These are handy for higher order functions like fold.  If you wanted to fold the addition operation across a tree of integers, you just need to start with the identity (0) and add in all of the integers in any order.

But the higher order fold function cannot be used to apply any old binary operation to any old tree of values from the set that the operation applies to.  If there is no identity element in the set, then the fold function needs an additional parameter to start with.  If the function is not associative, then you will need more memory to fold over a tree, because you have to fully process each branch.

And on it goes.