Tuesday, May 31, 2011

Googling for Code

You need a piece of code to implement a very standard algorithm. You could write it yourself, but instead you Google for it. No need to re-invent the wheel you say to yourself. Then frustration sets in..
My particular need was for a function in C++ to calculate the determinant of a square NxN integer matrix. Ideally I want something non-recursive and which does not need to allocate any memory.

Doesn’t seem like a lot to ask. However the solutions I find are all recursive, some very poorly written, some hundreds of lines long. Many are specific to the trivial 2x2 or 3x3 case. Most allocate a lot of memory from the heap. Now I hate recursion – does my head in - but I had assumed that a recursive algorithm was optional and that a non-recursive alternative always existed. Some websites held out the promise of a solution, but only if I signed up to join some group or other which would probably expose me to requests for payments, annoying ads and a deluge of emails. No thanks.

Anyway my search resulted in failure, so I resorted to writing my own – something which really should not be happening at this stage in the game. It does use recursion, and it allocates a very small amount of memory, but its less than 20 lines long.

int determinant(int n,int *matrix[])
{
     int i,j,k,sign=1,det=0;
     int **minor;
     if (n==1) return matrix[0][0];
     minor=new int* [n-1];
     for (i=0;i<n;i++)
     {
         for (j=k=0;j<n-1;j++)
         {
             if (j==i) k++; // skip i-th row
             minor[j]=&matrix[k++][1];
         }
         det+=sign*matrix[i][0]*determinant(n-1,minor);
         sign=-sign;
     }
     delete [] minor;
     return det;
}

Monday, May 23, 2011

Securing the Cloud

The potential benefits of cloud computing are amazing. Imagine for example your medical records being in the cloud, accessible immediately from anywhere in an emergency...

But wait a minute. What if the cloud is not secure? Already there have been a couple of instances where a cloud was hacked, or where there was a sustained loss of service. The cloud represents a single point of failure, and thus must not be allowed to fail. And what about privacy - you don't want anyone and everyone poking around in your medical records. The solution here is encryption, but a particularly sophisticated type of encryption. For example you might want your medical records to be completely available to you and your surgeon, and partially available to your GP and nurse, and somewhat available to your medical insurer. What's wanted in fact is known as "Attribute-Based Cryptography", where your access to the data depends on who you are and what attributes you have.

Well cometh the hour cometh the solution. As often happens in research, in a completely seperate development from cloud computing, mathematicians have recently come up with the perfect solution to the problem of attribute-based cryptography, based on the mathematics of "pairing-based cryptography". Previous efforts floundered on the problem of "collusion attacks". Say one needs attribute A and attribute B to access certain data. I have attribute A only, you have attribute B only, each of us individually does not have sufficient attributes to access the data, but if the two of us get together... The new methods prevents this. This is a very hot research area.

If you want to read more, see

http://eprint.iacr.org/2010/565

and

http://ece.wpi.edu/~mingli/papers/Li_SecureComm10.pdf

But academics having solved a problem do not linger long on it. There are other problems of interest. Unfortunately commercial exploitation of such ideas is often delayed, as knowledge of these new techniques is not widespread.
Here is another problem of particular interest to an Irish audience - Electronic Voting. We in Ireland dabbled with it before but the proposed method then was totally insecure. Ideally we would like to encrypt each vote and yet still be able to count it. However normally you can't do maths (like counting) on encrypted data. The solution is "homomorphic cryptography". Google for it. We don't quite have a perfect solution for it yet, but we are getting there... Another fascinating and hyperactive research area.

Wednesday, May 4, 2011

What do you expect from us?

There was a time when an academic was just expected to be a good researcher and a competent teacher.

Now however an academic is expected to be an active researcher, an excellent teacher, an entrepreneur, an innovator, an accountant, an administrator, an inventor, a fund-raiser, a media performer, a businessperson.... In short there is a lot being expected from the poor overloaded academic. However I don't have an entrepreneurial bone in my body. And I actually don't know of anyone who ticks all of those boxes (although I know of a couple who tick most of them).

In truth many of us became academics precisely so as not to become business people. Growing up in our rather snobby academic household I clearly recall the term "businessman" being used as a form of put-down. Our own self image as academics was (is?) as financially disinterested and personally unambitious, but with a noble curiosity about science, and/or literature and/or the arts.

However the expected attribute that worries me most is that of "innovator". The reason being that nowadays innovation is being entrusted solely to academia, and frankly in the past most innovation has come from outside of the universities. Think of a famous inventor and phrases like "college drop-out" and "no formal education" come rather uncomfortably to mind. The problem is that by implying that innovation is somehow the reserve of the universities, others may feel that their own ideas are not worthy of consideration. That would be a shame.