reduced code redundancy in DHkeypair