//
KeyPair U1 = g.generateKeyPair();
KeyPair U2 = g.generateKeyPair();
KeyAgreement uAgree = KeyAgreement.getInstance("ECMQV", "BC");
uAgree.init(new MQVPrivateKeySpec(U1.getPrivate(), U2.getPrivate(), U2.getPublic()));
//
// V side
//
KeyPair V1 = g.generateKeyPair();
KeyPair V2 = g.generateKeyPair();
KeyAgreement vAgree = KeyAgreement.getInstance("ECMQV", "BC");
vAgree.init(new MQVPrivateKeySpec(V1.getPrivate(), V2.getPrivate(), V2.getPublic()));
//
// agreement
//
uAgree.doPhase(new MQVPublicKeySpec(V1.getPublic(), V2.getPublic()), true);