Implementation of key generator