implement key agreement