Fix pub_key attribute scope