Adjust generate_key related functions