Update keygen.py

Adding comments to function