add function for serialize and deserialize key