public byte[] getAgreedSecret(ECPublicKey pubkey) {
try {
KeyAgreement ka = null;
ka = KeyAgreement.getInstance("ECDH", curve.kaProvider);
ka.init(key.getPrivate());
ka.doPhase(pubkey, true);
return ka.generateSecret();
} catch (InvalidKeyException e) {
Logger.error(this, "InvalidKeyException : "+e.getMessage(),e);
e.printStackTrace();