refactor privkey