Work on key generation algorithm